Question
Hello, Please help me fill the circles with colors randomly on the following image using matlab, below is the code and the image, thank you
Hello, Please help me fill the circles with colors randomly on the following image using matlab, below is the code and the image, thank you for your help in advance
% initializing image with white background
img=255*ones(256,256);
% ring center
h=128;k=128;
t=210:30:540;
% circle max radius
r=22;
% ring radius
R=80+r;
% generating centres for circle
x=round(R*cosd(t)+h);
y=round(R*sind(t)+k);
% coloring circles
for n=1:12
r=10:22;
for i=x(n)-r(n):x(n)+r(n)
for j=y(n)-r(n):y(n)+r(n)
if sqrt((i-x(n))^2+(j-y(n))^2)
img(i,j)=200;
end
end
end
end
% converting matrix to image
img=uint8(img);
% displaying image
imshow(img)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started