필터 지우기
필터 지우기

How to match voronoi area to it's point

조회 수: 3 (최근 30일)
Amit Ifrach
Amit Ifrach 2021년 8월 18일
댓글: Bjorn Gustavsson 2021년 8월 18일
לק"י
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
Amit Ifrach
Amit Ifrach 2021년 8월 18일
לק"י
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
Bjorn Gustavsson 2021년 8월 18일
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?

댓글을 달려면 로그인하십시오.

답변 (1개)

Bjorn Gustavsson
Bjorn Gustavsson 2021년 8월 18일
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

카테고리

Help CenterFile Exchange에서 Voronoi Diagram에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by