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

1 Ansicht (letzte 30 Tage)
לק"י
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 - https://www.mathworks.com/matlabcentral/answers/446168-how-can-i-get-the-area-of-each-polygon-of-a-voronoi-diagram) was used just to take out a large object out of the scatter plot.
xnm=csvfilecontainingdots(:,1);
ynm=csvfilecontainingdots(:,2);
% scatterplot with filled circels (points) the CSV
scatter(xnm,ynm, 1, 'filled')
% save coordinates of a polygon. polygon will have j numbers of points.
[xpoly,ypoly]=ginput(10);
% hold plot
hold on
% take out the chosen polygon from the plot
% h = drawpolygon('FaceAlpha',0)
roi=inpolygon(xnm,ynm,xpoly,ypoly);
% mask out the ROI
xroi=xnm.*roi;
yroi= ynm.*roi;
% scatterplot the chosen area
hold off
figure (1)
scatter(xroi, yroi, 1, 'filled');
axis equal
% voronoi, used code from: https://www.mathworks.com/matlabcentral/answers/446168-how-can-i-get-the-area-of-each-polygon-of-a-voronoi-diagram
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) ;
end
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!
Amit.

Akzeptierte Antwort

Matt J
Matt J am 15 Aug. 2021
You should use polyarea().
  2 Kommentare
Amit Ifrach
Amit Ifrach am 15 Aug. 2021
לק"י
Hi matt, thanks! I do use it to calculate each small polygon in the voronoi plot. maybe I wasn't clear with my question. at the end goal, I want to do histogram of the voronoi polygons in specific sub areas (dense and thin of dots) in the image. is it possible to somehow draw a plygon in the image that will reffer to the specific areas contained within this drawn polygon by me?
Image Analyst
Image Analyst am 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.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Voronoi Diagram finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by