numRegions

Number of disjoint regions of an alpha shape.

Category: Mathematics > Computational Geometry

Syntax

n = numRegions(shp)

Counts the connected pieces of the shape at its current Alpha.

Description

Lowering Alpha tends to split the shape into several pieces; raising it merges them. numRegions shows how many pieces the current choice gives. Combined with criticalAlpha(shp, 'one-region') it helps pick an Alpha with a single region.

Input arguments

shp
An alphaShape object.

Output arguments

n
Number of regions, a non-negative integer.

Example

Two clusters, two alpha values

x = [0 1 1 0 5 6 6 5]';
y = [0 0 1 1 0 0 1 1]';
shp = alphaShape(x, y, 1);
disp(numRegions(shp))
shp.Alpha = 5;
disp(numRegions(shp))
Output
     2
     1

Notes

For a polyshape the number of regions is the property NumRegions, not a function call: use P.NumRegions.

See also

alphaShape criticalAlpha regions numboundaries