Loadable Function: [l, num] = bwlabel(BW)
Loadable Function: [l, num] = bwlabel(BW, n)

Label binary 2 dimensional image.

Labels foreground objects in the binary image bw. The output l is a matrix where 0 indicates a background pixel, 1 indicates that the pixel belongs to object number 1, 2 that the pixel belongs to object number 2, etc. The total number of objects is num.

Two pixels belong to the same object if they are neighbors. By default the algorithm uses 8-connectivity to define a neighborhood, but this can be changed through the argument n, which can be either 4, 6, or 8.

See also: bwconncomp, bwlabeln, regionprops.

Package: image