Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

plot circle with gradient gray scale color in matlab

Tags:

matlab

I want to draw a circle with gradient color in matlab, but I can't. Is there any one that can help me?

the sample image can be found here

enter image description here

like image 521
Amir Ehsan Avatar asked Sep 06 '25 11:09

Amir Ehsan


1 Answers

Here's one approach -

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

Output -

enter image description here


If you would like to pad the output with white boundary as shown in the expect output image, you can do so with padarray -

padsize = 50; %// decides the boundary width
out = padarray(out,[padsize padsize],255);
like image 193
Divakar Avatar answered Sep 09 '25 01:09

Divakar