用matlab中的渐变灰度颜色绘制圆圈

时间:2014-11-07 07:23:00

标签: matlab

我想在matlab中绘制一个渐变颜色的圆圈,但我不能。有没有人可以帮助我?

the sample image can be found here

enter image description here

1 个答案:

答案 0 :(得分:5)

这是一种方法 -

N = 200; %// this decides the size of image
[X,Y] = meshgrid(-1:1/N:1, -1:1/N:1) ;
nrm = sqrt(X.^2 + Y.^2);
out = uint8(255*(nrm/min(nrm(:,1)))); %// output image

figure, imshow(out) %// show image

输出 -

enter image description here


如果您希望使用白色边框填充输出,如期望输出图像所示,您可以使用 padarray -

进行填充
padsize = 50; %// decides the boundary width
out = padarray(out,[padsize padsize],255);
相关问题