how do i create a concentric black and white circles on a color image with different brightness

1 view (last 30 days)
roshanak sistani
roshanak sistani on 15 Nov 2021
Edited: Adam Danz on 17 Nov 2021
how do i create a concentric black and white circles on a color image with different brightness from 0 to 255

Answers (1)

Adam Danz
Adam Danz on 15 Nov 2021
Edited: Adam Danz on 17 Nov 2021
This uses the gray colormap.
n = 20; % number of circles
r = [1,10]; % [smallest, largest] radius
center = [0,0]; % center of cirlces (x,y)
radii = linspace(r(1),r(2),n);
colors = gray(n); % to reverse colors, colors=flipud(gray(n))
th = linspace(0,2*pi,200);
hold on
for i = 1:n
x = radii(i) * cos(th) + center(1);
y = radii(i) * sin(th) + center(2);
plot(x,y,'-','color', colors(i,:), 'LineWidth', 2)
end
axis equal

Community Treasure Hunt

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

Start Hunting!