FUNCTION REFERENCE

bwlabel

Label the connected components of a binary image.

Label the connected components of a binary image.

Syntax

L = bwlabel(BW)

Syntax

L = bwlabel(BW, conn)

Syntax

[L, n] = bwlabel(...)

Returns a double label matrix of the size of the 2-D image BW (nonzero = foreground): 0 for background and 1..n for the objects, connected through the 8 neighbours (default) or the 4 edge neighbours (conn = 4). Objects are numbered in column-major order of their first pixel (scan down the first column, then the next), the numbering of the documented example.

Example

[L, n] = bwlabel(logical([1 0 1; 1 0 0; 0 1 0]))   % L = [1 0 2; 1 0 0; 0 1 0], n = 2

Example

[L, n] = bwlabel(logical([1 0; 0 1]), 4)   % n = 2

Differences from MATLAB: none known.

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