主要内容

numRegions

R2026b

alpha 形状中的区域数

描述

N = numRegions(shp) 返回构成 alpha 形状的不同区域的数量。如果 alpha 半径为 Inf,则 alpha 形状是凸包,区域数为 1。随着 alpha 半径值的减小,该形状可划分成不同的区域,具体视点集而定。

示例

示例

全部折叠

创建并绘制一个二维点集。

th = (pi/12:pi/12:2*pi)';
x1 = [reshape(cos(th)*(1:5), ...
      numel(cos(th)*(1:5)),1);
      0];
y1 = [reshape(sin(th)*(1:5), ...
      numel(sin(th)*(1:5)),1);
      0];
x = [x1;x1+15;];
y = [y1;y1];
plot(x,y,".")
axis equal

Scatter plot of two circular point sets arranged in concentric rings, one centered near the origin and one centered near x=15

使用 alpha 半径 7 创建一个 alpha 形状,并查询该形状中的不同区域数。

shp = alphaShape(x,y,7);
nregions = numRegions(shp)
nregions = 
1

使用较小的 alpha 半径 2.5 可更好地捕获边界,然后检索新的不同区域数。

shp.Alpha = 2.5;
nregions = numRegions(shp)
nregions = 
2

绘制 alpha 形状以检查边界质量。

plot(shp)

Alpha shape with two filled circular regions computed with alpha radius 2.5, one centered near the origin and one centered near x=15

输入参数

全部折叠

alpha 形状,指定为 alphaShape 对象。有关详细信息,请参阅 alphaShape。

示例: shp = alphaShape(x,y) 根据 (x,y) 点坐标创建一个二维 alphaShape 对象。

版本历史记录

在 R2014b 中推出

另请参阅