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

8 views (last 30 days)
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.

Answers (1)

Sean de Wolski
Sean de Wolski on 8 Apr 2016
You can pass RegionID into alphaTriangulation. Loop over the region ids to grab the triangulations.
  2 Comments
Dadhichi
Dadhichi on 8 Apr 2016
Edited: Dadhichi on 8 Apr 2016
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 on 12 Apr 2016
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

Sign in to comment.

Categories

Find more on Bounding Regions in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!