Create polygons from circles x, y and radii
Show older comments
I have 11k circles with the x/y coordinates and radii, but I want to patch them all with specific colours from the 11000-by-3 RGB colour matrix. While I use patch for my other problems, it only accepts polygon input. So I want to create polygons (with many points/faces so they still look like round) from these circles. I think it can be done with `polyshape`, but I'm not really sure (maybe use sin/cos) on how to to create polygon coordinates from the x/y/radii of the circles.
EDIT
To give you an impression on what I'm working with, I plotted the circles. The circles are derived from delaunay triangles.
Accepted Answer
More Answers (1)
Image Analyst
on 21 Oct 2018
One way is to use poly2mask() several times, ORing them together, to get a binary image of all shapes. Then use bwlabel() to get each region a different ID label (number). Then use label2rgb() to give each region a unique color.
binaryImage = false(rows, columns);
for k = 1 : numRegions
% Somehow get the x and y for this particular shape
x = ....
y = ....
binaryImage = binaryImage | poly2mask(x, y, rows, columns);
end
labeledImage = bwlabel(binaryImage);
rgbImage = label2rgb(labeledImage, yourColorMap);
Create your colormap as a numRegions by 3 array of color numbers in the range 0-1.
1 Comment
YT
on 21 Oct 2018
Categories
Find more on Triangulations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



