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
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 regions.The functions
bwlabel,bwlabeln, andbwconncompall compute connected components for binary images.bwconncompuses significantly less memory and is sometimes faster than the other functions.To extract features from a binary image using
regionpropswith default connectivity, passBWdirectly intoregionpropsusing the commandregionprops(BW).To compute a label matrix having more memory-efficient data type (for instance,
uint8versusdouble), use thelabelmatrixfunction on the output ofbwconncomp.






