bwconncomp
Find and count connected components in binary image
Description
finds and counts the connected components CC
= bwconncomp(BW
)CC
in the binary
image BW
. The CC
output structure contains
the total number of connected components, such as regions of interest (ROIs), in the
image and the pixel indices assigned to each component.
bwconncomp
uses a default connectivity of 8 for two
dimensions and 26 for three dimensions.
Examples
Input Arguments
Output Arguments
Tips
The functions
bwlabel
,bwlabeln
, andbwconncomp
all compute connected components for binary images.bwconncomp
replaces the use ofbwlabel
andbwlabeln
. It uses significantly less memory and is sometimes faster than the other functions.To extract features from a binary image using
regionprops
with default connectivity, just passBW
directly intoregionprops
using the commandregionprops(BW)
.To compute a label matrix having more memory-efficient data type (for instance,
uint8
versusdouble
), use thelabelmatrix
function on the output ofbwconncomp
.