bwlabeln
Label connected components in binary image
Description
Examples
Input Arguments
Output Arguments
Tips
This function sorts the connected components from left to right based on the
top-leftextremum of each component. When multiple components have the same horizontal position, the function then sorts those components from top to bottom, and again along any higher dimensions. This figure illustrates the extrema of two different 2-D regions.The functions
bwlabel,bwlabeln, andbwconncompall compute connected components for binary images.bwconncompuses significantly less memory and is sometimes faster than the other functions.Function Input Dimension Output Form Memory Use Connectivity bwlabel2-D Label matrix with double-precision High 4 or 8 bwlabelnN-D Double-precision label matrix High Any bwconncompN-D CCstructLow Any To extract features from a binary image using
regionpropswith default connectivity, passBWdirectly intoregionpropsusing the commandregionprops(BW).
Algorithms
bwlabeln uses the following general procedure:
Scan all image pixels, assigning preliminary labels to nonzero pixels and recording label equivalences in a union-find table.
Resolve the equivalence classes using the union-find algorithm [1].
Relabel the pixels based on the resolved equivalence classes.
References
[1] Sedgewick, Robert, Algorithms in C, 3rd Ed., Addison-Wesley, 1998, pp. 11-20.
Extended Capabilities
Version History
Introduced before R2006aSee Also
bwconncomp | bwlabel | labelmatrix | label2rgb | regionprops




