SOLUTIONS

BUILTIN MATHEMATICA SYMBOL
MorphologicalTransform
MorphologicalTransform[image, f]
applies the function f to the 3×3 neighborhood of each pixel in a binary image image.
MorphologicalTransform[image, rule]
applies a morphological transformation specified by a rule number rule.
MorphologicalTransform[image, "name"]
uses a named transformation .
MorphologicalTransform[image, transformation, n]
applies n iterations of transformation on image.
Details and OptionsDetails and Options
 In MorphologicalTransform[image, f], f is a function that maps arbitrary binary 3×3 matrices to 0s and 1s.
 MorphologicalTransform[image, {f_{1}, f_{2}, ...}, n] applies the functions sequentially, iterating n times.
 MorphologicalTransform operates on a binary image or a list of binary images.
 The following named function specifications are supported:
 Finding features:

"EndPoints" find endpoints "SkeletonEndPoints" find endpoints of a skeleton object "SkeletonBranchPoints" find branch points of a skeleton  Connecting regions:

"Bridge" set the center pixel to 1 if it connects two or more disconnected neighbor regions  Filling and clearing:

"Clean" flip foreground pixels that have no direct neighbors "Flip" flip background and foreground pixels that have direct neighbors of same value "Fill" set pixels whose direct neighbors are white "Remove" clear pixels whose direct neighbors are white, leaving the perimeter "Break" clear the connecting pixel in Hshaped configurations "BoundingBoxes" fill gaps such that the object grows to its bounding box "BoundingDiamonds" fill gaps such that the object grows to its bounding diamond "DiagonalFill" fill diagonals "CornerFill" fill corners "BoundaryStraighten" clean ragged boundaries  Totalistic and outer totalistic operations:

"Max" dilation with a 3×3 box matrix "Min" erosion with a 3×3 box matrix "Commonest" set the most frequent pixel value of the neighborhood "LifeGame" Game of Life operation  Translation operations:

"Top" translate up by one pixel "Bottom" translate down by one pixel "Left" translate left by one pixel "Right" translate right by one pixel "TopLeft" translate topleft by one pixel "TopRight" translate topright by one pixel "BottomLeft" translate bottomleft by one pixel "BottomRight" translate bottomright by one pixel  MorphologicalTransform takes a Padding option. The default setting is Padding>0.
ExamplesExamplesopen allclose all
Basic Examples (6)Basic Examples (6)
Replace each pixel with the maximum value in each 3×3 neighborhood:
In[1]:= 
Out[1]= 
Use a rule that effectively finds isolated foreground pixels:
In[1]:= 
Out[1]= 
Use a sequence of operations to create a morphological opening:
In[1]:= 
Out[1]= 
Find the upper horizontal boundaries:
In[1]:= 
Out[1]= 
In[1]:= 
Out[1]= 
Iterate a transformation until convergence:
In[1]:= 
Out[1]= 
New in 8
Mathematica 9 is now available!
New to Mathematica?
Find your learning path »
Have a question?
Ask support »