bwlabel
Label connected components in a binary image.
📝Syntax
L = bwlabel(BW)
L = bwlabel(BW, conn)
[L, num] = bwlabel(...)
📥Input Arguments
Parameter Description
BW Input binary image. Nonzero values are treated as true.
conn Connectivity passed to bwconncomp.
📤Output Arguments
Parameter Description
L Label matrix with one positive label per connected component.
num Number of connected components.
📄Description

Label connected components in a binary image.

💡Examples
Label connected components
BW=false(64,64); BW(8:20,8:20)=true; BW(36:52,32:48)=true;
L=bwlabel(BW);
figure; imagesc(L); title('Labels');
Example illustration
🔗See Also
bwconncomplabelmatrixregionprops
🕔Version History
Version Description
2.0.0 initial version
Edit this page on GitHub