# How to match voronoi area to it's point

3 Ansichten (letzte 30 Tage)
Amit Ifrach am 18 Aug. 2021
Kommentiert: Bjorn Gustavsson am 18 Aug. 2021
לק"י
Hi!
I'm trying to find a command or a code that can match the voronoi areas I get out from voronoin command to the points they enclose. I use oast of KSSV's code, so if it seems fermiliar, it's from him.
thanks!
that's the code:
[v,c] = voronoin([xroi yroi]) ;
vorareaacd45num10thin1st = zeros(length(c),1) ;
for i = 1:length(c)
v1 = v(c{i},1) ;
v2 = v(c{i},2) ;
vorarea(i) = polyarea(v1,v2) ;
end
##### 2 KommentareKeine anzeigenKeine ausblenden
Amit Ifrach am 18 Aug. 2021
לק"י
Hi Image Analyst, thanks for the answer!
I'll explain the main goal and then maybe i'll be able to explain what I need a little bit better.
I'm imaging a cell down to it's single molecule level. I want to use voronoi diagram on the cell's 'image' (it's xy csv of the points of the molecules). the problem is that the image contains alot of background noise that I need to ignore and to take only the voronois areas in the cell.
The (wrong) startegy I wanted to use was to inpolygon on points within the cell, delete everything else outside of it and afther that to do a voronoi. the problem is that allways I'll get big areas at the edge of the cell and cutting out points won't help. I want to use inpolygon to 'take out' the areas within the drawn polygon instead.
The problem is, that my code generate voronoi areas without a way to recognize which areas they are, or which point the surround. I need a way to ascribe area to dot it surrounds so I can 'take out' these points using inpolygon.
is there any way to do so? I thought to do it manually with for loop, but I don't know how the voronoin command assigns the areas to the c vector (which x and y point does it use).
thanks!
Amit.
Bjorn Gustavsson am 18 Aug. 2021
The way I recall the Voronoi-boundaries are built from the line-segments prependicular to the midpoints of the Delaunay-triangulation-edges (normals halfway on the nearest-neighbour-lines, so the dual of the Delaunay-triangulation). If you could share a typical image it might be easier to modify your aproach?

Melden Sie sich an, um zu kommentieren.

### Antworten (1)

Bjorn Gustavsson am 18 Aug. 2021
The way I interpret your question each point [xroi,yroi] will be inside one Voronoi-cell (though my QD-tests leave a couple of edge-points outside the Voronoi-cells?). It should be possible to find out which by using inpolygon:
for i1 = length(c):-1:1
v1 = v(c{i1},1);
v2 = v(c{i1},2);
idx = find(inpolygon(xroi,yroi,v1,v2));
if ~isempty(idx)
idxXYinCellj(i1) = idx(1);
end
if numel(idx) > 1
disp(['Cell ',num2str(i1),' contains ',num2str(numel(idx)),' points?'])
end
end
HTH
##### 0 Kommentare-2 ältere Kommentare anzeigen-2 ältere Kommentare ausblenden

Melden Sie sich an, um zu kommentieren.

### Kategorien

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

### Community Treasure Hunt

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

Start Hunting!

Translated by