How to find specific areas in Voronoi plot? and how to enlarge the plot to choose small areas?

4 views (last 30 days)
Hi all, my name is Amit.
I'm trying to find the area of specific polygons in Voronoi's diagram which will be chosen by inpolygon command or other that can let me draw the area I wish to get.
for example:
the voronoi plot of the general chosen object is (disregard the drawn polygons):
As I mentioned, I want to get the area of polygons at a chosen circle or chosen polygon within this voronoi diagram.
the original code I tried (part of it from KSSV's previous answer - was used just to take out a large object out of the scatter plot.
% scatterplot with filled circels (points) the CSV
scatter(xnm,ynm, 1, 'filled')
% save coordinates of a polygon. polygon will have j numbers of points.
% hold plot
hold on
% take out the chosen polygon from the plot
% h = drawpolygon('FaceAlpha',0)
% mask out the ROI
yroi= ynm.*roi;
% scatterplot the chosen area
hold off
figure (1)
scatter(xroi, yroi, 1, 'filled');
axis equal
% voronoi, used code from:
vor=voronoi(xroi, yroi);
[v,c] = voronoin([xroi yroi]) ;
% figure
% hold on
% voronoi(xroi,yroi)
vorareaacd45num10thin2nd = zeros(length(c),1) ;
for i = 1:length(c)
v1 = v(c{i},1) ;
v2 = v(c{i},2) ;
% patch(v1,v2,rand(1,3))
vorareaacd45num10thin2nd(i) = polyarea(v1,v2) ;
And one last thing.. when I try to use inpolygon, I can't enlarge the picture to get high detail of the desired area. do you have a solution for that?
Here you can see the magnification button is grey and unuseable:
Thank you!

Accepted Answer

Matt J
Matt J on 15 Aug 2021
You should use polyarea().
Image Analyst
Image Analyst on 15 Aug 2021
When you're computing the area of each polygon (which you said you already can do), then simply call inpolygon() to determine if all the vertices of that polygon are within the outline you hand drew. If it is within, keep that area, if it's not in, then discard that area.

Sign in to comment.

More Answers (0)


Find more on Voronoi Diagram 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!