Wolfram Language & System 10.3 (2015)|Legacy Documentation

This is documentation for an earlier version of the Wolfram Language.View current documentation (Version 11.2)


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.

Details and OptionsDetails and Options

  • MorphologicalComponents assigns sequential integers to different connected components and 0 to pixels that correspond to the background in the image.
  • MorphologicalComponents[image] is equivalent to MorphologicalComponents[image,0].
  • MorphologicalComponents works with binary, grayscale, and other images.
  • The following options can be specified:
  • CornerNeighborsTruewhether to include corner neighbors
    Method"Connected"connectivity method
    Padding0padding method to use
  • The following Method settings can be specified:
  • "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.

ExamplesExamplesopen allclose all

Basic Examples  (3)Basic Examples  (3)

Find the connected components in a binary image:

Click for copyable input

Connected component labels:

Click for copyable input

Connected components of a 3D image:

Click for copyable input
Introduced in 2008
| Updated in 2012