drawing a gray circle in white rectangle.

1 view (last 30 days)
Rose M
Rose M on 12 May 2014
Commented: Image Analyst on 17 May 2014
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));

Answers (2)

Image Analyst
Image Analyst on 12 May 2014
Let us know if you can't figure out how to adapt it.
  11 Comments
Rose M
Rose M on 17 May 2014
Edited: Rose M on 17 May 2014
The picture is 1250*2300, then I save it with .bmp but when I recall it, it's 503*930.
figure(4); imshow(fftshift(H)); colormap([0.49 0.49 0.49; 1 1 1]); title('High pass filter'); saveas (gcf,'C:\Users\Desktop\22.bmp');
Image Analyst
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.

Sign in to comment.


Rose M
Rose M on 14 May 2014
I added this line to my code: colormap([0.2 0.2 0.2; 1 1 1]); so my circle turns to gray, but I think the circle itself does not turn to gray,the way that we see it is gray.I mean if I want to use the circle in next line of program, it is still black not gray. Am I correct?

Categories

Find more on Images in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!