Creating random circle patterns in an image

7 次查看(过去 30 天)
I'd like to create an image containing random placed circles, like the image I attached to this post. I know how to create the image and how to put things at a random place, but I just don't know how to create the circle itself. Is there anyone who can help me?

回答(2 个)

Thomas Koelen
Thomas Koelen 2015-5-12
编辑:Thomas Koelen 2015-5-12
Hallo Iris, je kan hier deze functie voor gebruiken.
function circle(x,y,r)
%x en y zijn de coördinaten vaan het midden van de cirkel
%r is de radius van de cirkel
%0.01 is de "hoekstap", als je met grotere cirkels werkt krijg je hiermeen soepelere cirkel, het duurt dan wel langer om deze te maken.
ang=0:0.01:2*pi;
xp=r*cos(ang);
yp=r*sin(ang);
plot(x+xp,y+yp);
end
als je meer cirkels wil kun je
hold all
of
hold on
gebruiken, de ene gebruikt telkens een andere kleur de andere dezelfde.
Hier een voorbeeld, je moet dan wel de functie die ik eerder liet zien opslaan als circle.m in je matlab path.
IM=imread('pout.tif');
imshow(IM)
hold on
for im=1:200
circle(rand*300,rand*500,rand*20)
end
resultaat:
Groetjes,
Thomas

Image Analyst
Image Analyst 2015-5-12
There are FAQ entries for creating circles, arcs, ellipses, and rings: http://matlab.wikia.com/wiki/FAQ#How_do_I_create_a_circle.3F. I attach a circle demo that I have (not customized for you though).
If you want the circles to not overlap, that is an easy modification.

Community Treasure Hunt

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

Start Hunting!

Translated by