Mathematica > Data Manipulation > Image Processing & Analysis > Mathematical Morphology >

MorphologicalComponents

MorphologicalComponents[image]
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.
MorphologicalComponents[image, t]
treats values above t as foreground.
  • The option setting CornerNeighbors->False treats only the four pixels in the coordinate directions as adjacent.
Connected component labels as a matrix:
In[1]:=
Click for copyable input
Out[1]//MatrixForm=
Find the connected components in a binary image:
In[2]:=
Click for copyable input
Out[2]=
 
Specify an explicit threshold:
In[1]:=
Click for copyable input
Out[1]=
New in 7
Ask a question about this page  |  Suggest an improvement  |  Leave a message for the team