FUNCTION REFERENCE

bwconncomp

Connected components of a binary image.

Connected components of a binary image.

Syntax

CC = bwconncomp(BW)

Syntax

CC = bwconncomp(BW, conn)

Returns a struct with the fields Connectivity (4 or 8, default 8), ImageSize ([rows cols]), NumObjects and PixelIdxList, a 1-by-NumObjects cell array of column vectors with the linear indices of each object in ascending order. Objects are ordered as bwlabel numbers them.

Example

CC = bwconncomp(logical([1 1 0; 0 0 0; 0 1 1])); CC.NumObjects   % 2

Example

CC = bwconncomp(logical([1 0; 0 1]), 4); CC.PixelIdxList{2}   % 4

Differences from MATLAB: 2-D only (no N-D connectivities).

These are the engine’s help pages. Each page keeps its compatibility notes. File operations are unavailable in the browser.