How to randomly divide an M by M region into n sub regions

1 vue (au cours des 30 derniers jours)
Shamsuddeen Abdullahi
Shamsuddeen Abdullahi le 20 Avr 2019
Modifié(e) : Image Analyst le 20 Avr 2019
I what to randomly divide a sqaure region (20 by 20) into 3 portions (not necessary square in shape).
Then randomly deploy points in the 3 regions.
I tried the code below but not getting what i want. I need random divisions (different shapes e.g one portion can be a trapezoid and so on)
m=20;
for i=1:1:m;
n(i)=rand.*0.25.*m;
b(i)=(0.25 +(0.25).*rand).*m;
c(i)=(0.5 +(0.25).*rand).*m;
end
plot (n, '+r')
hold on
plot (b, 'ok')
hold on
plot (c, 'vg')
hold off
Please help
The above code gives divisions along horizontal lines
figure 1.
I need something like the above figure 1.
  3 commentaires
Walter Roberson
Walter Roberson le 20 Avr 2019
https://en.m.wikipedia.org/wiki/Voronoi_diagram
Shamsuddeen Abdullahi
Shamsuddeen Abdullahi le 20 Avr 2019
yes

Connectez-vous pour commenter.

Réponses (1)

Image Analyst
Image Analyst le 20 Avr 2019
Modifié(e) : Image Analyst le 20 Avr 2019
Try voronoi() if you want random points, or superpixels() if you have an image and want some sort of decision-based boundaries.

Catégories

En savoir plus sur Lighting, Transparency, and Shading dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by