How to find specific areas in Voronoi plot? and how to enlarge the plot to choose small areas?
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Amit Ifrach
el 15 de Ag. de 2021
Comentada: Image Analyst
el 15 de Ag. de 2021
לק"י
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.
0 comentarios
Respuesta aceptada
Matt J
el 15 de Ag. de 2021
You should use polyarea().
2 comentarios
Image Analyst
el 15 de Ag. de 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.
Más respuestas (0)
Ver también
Categorías
Más información sobre Voronoi Diagram en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!