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
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 -
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);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With