drawing a gray circle in white rectangle.
1 view (last 30 days)
Show older comments
How should I draw a gray circle in a white rectangle? can you send me a code? thanks
this is my try on drawing black circle in white rectangle, but what about gray one? u0 is radius and M and N are sides of rectangle.
u0 = 5; %
u=0:(M-1);
v=0:(N-1);
idx=find(u>M/2);
u(idx)=u(idx)-M;
idy=find(v>N/2);
v(idy)=v(idy)-N;
[V,U]=meshgrid(v,u);
D=sqrt(U.^2+V.^2);
H=double(D>=u0);
% display
figure(1);
imshow(fftshift(H));
0 Comments
Answers (2)
Image Analyst
on 12 May 2014
Let us know if you can't figure out how to adapt it.
11 Comments
Image Analyst
on 17 May 2014
That's because you're not saving the actual image H, you're saving a screenshot of it's display. So it's however big it is on your screen since it's a screenshot you're saving, not the underlying image. Try using save() to save the variable. Or use
imwrite(uint8(255*mat2gray(H)), filename);
if you want to save the image in its original size.
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!