Label connected components in 2-D array (Scripts) Publisher's description
from Damien Garcia
LABEL is a generalization of BWLABEL: BWLABEL works with 2-D binary images only
LABEL is a generalization of BWLABEL: BWLABEL works with 2-D binary images only, whereas LABEL works with 2-D arrays of any class.
L = LABEL(I,N) returns a matrix L, of the same size as I, containing labels for the connected components in I. Two adjacent components (pixels), of respective indexes IDX1 and IDX2, are connected if I(IDX1) and I(IDX2) are equal.
N can have a value of either 4 or 8, where 4 specifies 4-connected objects and 8 specifies 8-connected objects; if the argument is omitted, it defaults to 8.
NaN values are ignored and considered as background. Because LABEL works with arrays of any class, the 0s are NOT considered as the background.
The elements of L are integer values greater than or equal to 0. The pixels labeled 0 are the background (corresponding to the NaN components of the input array). The pixels labeled 1 make up one object, the pixels labeled 2 make up a second object, and so on.
[L,NUM] = LABEL(...) returns in NUM the number of connected objects found in I.
[L,NUM,SZ] = LABEL(...) returns a matrix SZ, of the same size as I, that contains the sizes of the connected objects. For a pixel whose index is IDX, we have: SZ(IDX) = NNZ(L==L(IDX)).
Enter "help label" in the Matlab Command Window for two examples.
System Requirements:MATLAB 7.7 (R2008b)
Program Release Status: New Release
Program Install Support: Install and Uninstall