Voronoi diagram- ignore outer cells?
8 ビュー (過去 30 日間)
古いコメントを表示
Hi there,
I would like to determine point density statistics for my data by using voronoi cells but I get polygons along the outer edges that are not representative of the data.
Is it possible to ignore or remove these big polygons? or would it be wise to try and use the freeBoundary edges from DelaunayTri as a bounding box?
If the latter sounds reasonable, can someone suggest a function on how to get the vertices of the overlapping lines (freeboundary and voronoi)? I tried using the polyxpoly function but that returned some funny results (not all intersections were returned and some of them are not even true intersections).
An example of my code (adjusted from voronoi matlab example), with delaunay, freeboundary,voronoi and voronoin vertices as well as area calculations to show the biased values:
Thanx in advance :)
%%random data
x = gallery('uniformdata',[1 10],0);
y = gallery('uniformdata',[1 10],1);
xy = [x;y]';
%delaunay triangle
dt = DelaunayTri(xy);
% get freebound and retrieve coords for each line segment
fb = freeBoundary(dt);
%returns xy coords for line segment in fb
fbPts = [xy(fb(:,1),:), xy(fb(:,2),:)];
%voronoi vertices
[v1,c]=voronoin(xy);
v = v1(2:end,:); %chop off first row
% define points for polyxpoly function
xx1 = fbPts(:,1);
yy1 = fbPts(:,2);
% duplicate the first x,y points to close polygon
xx1(length(fbPts)+1) = xx1(1);
yy1(length(fbPts)+1) = yy1(1);
% xy from voronoin vertices
xx2 = v(:,1);
yy2 = v(:,2);
% find vertices for overlapping lines
[xi,yi] = polyxpoly(xx1,yy1,xx2,yy2);
% plot everything
% triplot(dt,'r');
hold all
voronoi(x,y,'b') %voronoi
% line(xx1,yy1) %plot fb
% plot(xi,yi,'*') %intersection from polyxpoly
plot(v(:,1),v(:,2),'g*') %vertices from voronoin
% calc area for each voronoin polygon
for i = 1:size(c,1)
ind = c{i}';
tess_area(i,1) = polyarea(v1(ind,1),v1(ind,2));
end
0 件のコメント
回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Voronoi Diagram についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!