numboundaries

Number of boundaries of a polyshape, counting outer boundaries and holes.

Category: Mathematics > Computational Geometry

Syntax

n = numboundaries(pshape)

Returns the total number of boundaries.

Description

Each solid piece has one outer boundary, and every hole inside it adds another boundary. A rectangle with a hole therefore has two boundaries but only one region. Boundaries are the units addressed by rmboundary, sortboundaries and ishole.

Input arguments

pshape
A polyshape object.

Output arguments

n
Non-negative integer. It equals pshape.NumRegions + pshape.NumHoles.

Example

Boundaries versus regions

P = polyshape([0 4 4 0], [0 0 3 3]);
H = polyshape([1 2 2 1], [1 1 2 2]);
D = subtract(P, H);
numboundaries(D)
D.NumRegions
Output
ans = 2
ans = 1

See also

regions holes ishole rmboundary