drawing a gray circle in white rectangle.
3 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(2 个)
Image Analyst
2014-5-12
Let us know if you can't figure out how to adapt it.
11 个评论
Image Analyst
2014-5-17
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.
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!