主要内容

alpha 形状

R2026b

使用 alphaShape 函数查找二维点集的 alpha 形状。

alpha 形状具有用于控制细节程度或者边界在点集周围的拟合紧密度的参数。该参数称为阿尔法或阿尔法半径。在 0 到 Inf 范围内更改 alpha 半径可生成一组该点集特有的不同 alpha 形状。

创建一个二维点集。

X = [-1.5 3.2; 1.8 3.3; -3.7 1.5; -1.5 1.3; 0.8 1.2; ...
      3.3 1.5; -4.0 -1.0; -2.3 -0.7; 0 -0.5; 2.0 -1.5; ...
      3.7 -0.8; -3.5 -2.9; -0.9 -3.9; 2.0 -3.5; 3.5 -2.25];

计算并绘制此点集的 alpha 形状。

shp = alphaShape(X)
shp = 
  alphaShape with properties:

             Points: [15×2 double]
              Alpha: 1.7618
      HoleThreshold: 0
    RegionThreshold: 0

hold on
plot(shp)
plot(X(:,1),X(:,2),"r.",MarkerSize=20)
title("Nonconvex Alpha Shape")
hold off

Nonconvex alpha shape with green triangulated regions and a concavity in the lower-right area. Red dots mark the 15 data points.

更改 alpha 半径有时会产生具有多个区域的 alpha 形状,其中可能包含也可能不包含孔洞。不过,MATLAB® 中的 alphaShape 函数始终返回正则化的 alpha 形状,以防出现孤立或空悬的点、边或面。

figure
shp = alphaShape(X,1.5)
shp = 
  alphaShape with properties:

             Points: [15×2 double]
              Alpha: 1.5000
      HoleThreshold: 0
    RegionThreshold: 0

hold on
plot(shp)
plot(X(:,1),X(:,2),"r.",MarkerSize=20)
title("Alpha Shape with Multiple Regions")
hold off

Alpha shape with alpha radius 1.5, forming multiple disconnected green triangulated regions. Red dots mark the 15 data points.

点集的 alpha 形状是凸包和德劳内三角剖分子图的推广。换言之,凸包是其中一种 alpha 形状类型,完整系列的 alpha 形状可以从给定点集的德劳内三角剖分进行派生。

计算并绘制点集的凸包。在 alpha 半径设为 Inf 时,生成的 alpha 形状是点集的凸包。

shp = alphaShape(X,Inf);
hold on
plot(shp)
plot(X(:,1),X(:,2),"r.",MarkerSize=20)
title("Convex Hull")
hold off

Convex hull computed with alpha radius Inf, forming a single fully connected green triangulated region enclosing all 15 data points