System object: vision.ConnectedComponentLabeler
Label and count connected regions in input
L = step(H,BW)
COUNT = step(H,BW)
[L,COUNT] = step(H,BW)
L = step(H,BW) outputs the matrix, L for input binary image BW when the LabelMatrixOutputPort property is true.
COUNT = step(H,BW) outputs the number of distinct, connected regions found in input binary image BW when you set the LabelMatrixOutputPort property to false and LabelCountOutputPort property to true.
[L,COUNT] = step(H,BW) outputs both the L matrix and number of distinct, connected regions, COUNT when you set both the LabelMatrixOutputPort property and LabelCountOutputPort to true.
Note: The object performs an initialization the first time the step method is executed. This initialization locks nontunable properties and input specifications, such as dimensions, complexity, and data type of the input data. If you change a nontunable property or an input specification, the System object™ issues an error. To change nontunable properties or inputs, you must first call the release method to unlock the object.