How to get 3D Points of separate regions obtained from alphaShape?

3 次查看(过去 30 天)
Taking example from MATLAB docs regarding alphaShape:
[x1, y1, z1] = sphere(24);
x1 = x1(:); y1 = y1(:); z1 = z1(:);
x2 = x1+5; P = [x1 y1 z1; x2 y1 z1];
% if you plot 'P' you'll see two spheres
% plot3(P(:,1),P(:,2),P(:,3),'.')
P = unique(P,'rows');
shp = alphaShape(P(:,1),P(:,2),P(:,3),1);
N = numRegions(shp)
Output:
N = 2
I am interested in finding which points of P belong to which region. In other words labeling points in P. This can be done using different clustering methods, but I would like to know if it is possible with alphaShape.

回答(1 个)

Sean de Wolski
Sean de Wolski 2016-4-8
You can pass RegionID into alphaTriangulation. Loop over the region ids to grab the triangulations.
  2 个评论
Dadhichi
Dadhichi 2016-4-8
编辑:Dadhichi 2016-4-8
If I understand you correct then is it the following what you are suggesting?
tri1 = alphaTriangulation(shp,1);
tri2 = alphaTriangulation(shp,2);
idx1 = unique(tri1(:));
idx2 = unique(tri2(:))
points1 = P(idx1,:);
points2 = P(idx2,:);
Is there a better way? Or could you put the content of the link in the answer. Thanks!
Sean de Wolski
Sean de Wolski 2016-4-12
That looks right to me and matches the expectations for set intersection, i.e. no points in both but all points represented:
>>intersect(idx1,idx2)
ans =
Empty matrix: 0-by-1
>> all(ismember(alphaTriangulation(shp),union(idx1,idx2)))
ans =
1 1 1 1

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Bounding Regions 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by