Function File: cc = bwconncomp (bw)
Function File: cc = bwconncomp (bw, conn)

Find connected objects.

Elements from the matrix bw, belong to an object if they have a non-zero value. The output cc is a structure with information about each object;

"Connectivity"

The connectivity used in the boundary tracing. This may be different from the input argument, e.g., if conn is defined as a matrix of 1s and size 3x3, the "Connectivity" value will still be 8.

"ImageSize"

The size of the matrix bw.

"NumObjects"

The number of objects in the image bw.

"PixelIdxList"

A cell array with linear indices for each element of each object in bw A cell array containing where each element corresponds to an object in BW. Each element is represented as a vector of linear indices of the boundary of the given object.

Element connectivity conn, to define the size of objects, can be specified with a numeric scalar (number of elements in the neighborhood):

4 or 8

for 2 dimensional matrices;

6, 18 or 26

for 3 dimensional matrices;

or with a binary matrix representing a connectivity array. Defaults to conndef (ndims (bw), "maximal") which is equivalent to conn of 8 and 26 for 2 and 3 dimensional matrices respectively.

See also: bwlabel, bwlabeln, bwboundaries, ind2sub, regionprops.

Package: image