%画九点圆
clear;
width=1920 ; %pattern的宽
height=1080 ; %pattern的高
img_final=zeros(height,width);
r = 40;
img = zeros(r*2+1);
for m = 1:r*2+1
for n = 1:r*2+1
if (m-r-1)^2+(n-r-1)^2 < r^2
img(m,n) = 1-(((m-r-1)^2+(n-r-1)^2)/(r^2))^2;
end
end
end
imshow(img)
scale = 0.5;%偏移比例
org_X = round(scale * (height/2));
org_Y = round(scale * (width/2));
img_final(org_X-r:org_X+r,org_Y-r:org_Y+r)=img;
img_final(org_X-r:org_X+r,width/2-r:width/2+r)=img;
img_final(org_X-r:org_X+r,width-org_Y-r:width-org_Y+r)=img;
img_final(height/2-r:height/2+r,org_Y-r:org_Y+r)=img;
img_final(height/2-r:height/2+r,width/2-r:width/2+r)=img;
img_final(height/2-r:height/2+r,width-org_Y-r:width-org_Y+r)=img;
img_final(height-org_X-r:height-org_X+r,org_Y-r:org_Y+r)=img;
img_final(height-org_X-r:height-org_X+r,width/2-r:width/2+r)=img;
img_final(height-org_X-r:height-org_X+r,width-org_Y-r:width-org_Y+r)=img;
imshow(img_final)
imwrite(img_final,'nineCircle.png','png');
网友评论