gives an array in which each pixel of image is replaced by an integer index representing the connected foreground image component in which the pixel lies.
treats values above t as foreground.
- MorphologicalComponents assigns sequential integers to different connected components.
- MorphologicalComponents gives 0 for pixels that correspond to the background in the image.
- MorphologicalComponents[image] is equivalent to MorphologicalComponents[image, 0].
- MorphologicalComponents by default treats all eight pixels surrounding a given pixel as adjacent.
- The option setting CornerNeighbors->False treats only the four pixels in the coordinate directions as adjacent.
- MorphologicalComponents works with binary, grayscale, and other images.
- MorphologicalComponents takes a Padding option. The default setting is Padding->0, corresponding to a black background.
- MorphologicalComponents supports a Method option that specifies the connectivity of elements. Possible settings include:
"Connected" labels connected components (default) "Nested" labels nested connected components "Convex" labels objects within non-overlapping convex regions "ConvexHull" finds non-overlapping convex hulls "BoundingBox" finds non-overlapping bounding boxes "BoundingDisk" finds non-overlapping bounding disks
- MorphologicalComponents[image, Method->"Connected"] also works with Image3D objects.