MorphologicalTransform
✖
MorphologicalTransform
applies the function f to the 3×3 neighborhood of each pixel in a binary image image.
applies a morphological transformation specified by a rule number rule.
Details and Options



- In MorphologicalTransform[image,f], f is a function that maps arbitrary binary 3×3 matrices to 0s and 1s.
- MorphologicalTransform[image,{f1,f2,…},n] applies the functions fi 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 H-shaped 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 "Life" 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 top-left by one pixel "TopRight" translate top-right by one pixel "BottomLeft" translate bottom-left by one pixel "BottomRight" translate bottom-right by one pixel - MorphologicalTransform takes a Padding option. The default setting is Padding->0.
Examples
open allclose allBasic Examples (6)Summary of the most common use cases
Replace each pixel with the maximum value in each 3×3 neighborhood:

https://wolfram.com/xid/0fq33v0ywby4i-cbbdw

Use a rule that effectively finds isolated foreground pixels:

https://wolfram.com/xid/0fq33v0ywby4i-bmii0z

Use a sequence of operations to create a morphological opening:

https://wolfram.com/xid/0fq33v0ywby4i-7clhne

Find the upper horizontal boundaries:

https://wolfram.com/xid/0fq33v0ywby4i-px19yy


https://wolfram.com/xid/0fq33v0ywby4i-hoa51w

Iterate a transformation until convergence:

https://wolfram.com/xid/0fq33v0ywby4i-l9ynu1

Scope (17)Survey of the scope of standard use cases
Endpoints of a skeleton object:

https://wolfram.com/xid/0fq33v0ywby4i-bk5rda

Branch points of a skeleton object:

https://wolfram.com/xid/0fq33v0ywby4i-c3xr99

Fill one-pixel-wide gaps in images:

https://wolfram.com/xid/0fq33v0ywby4i-dohrlx

Delete isolated foreground pixels:

https://wolfram.com/xid/0fq33v0ywby4i-6fawpi

Delete isolated background pixels:

https://wolfram.com/xid/0fq33v0ywby4i-7zxa36

Flip the background and foreground pixel values while preserving the boundaries:

https://wolfram.com/xid/0fq33v0ywby4i-bwpbum

Find the perimeter of the objects:

https://wolfram.com/xid/0fq33v0ywby4i-m7s9ua

Remove the 8-connectivity of the background:

https://wolfram.com/xid/0fq33v0ywby4i-bko6tm


https://wolfram.com/xid/0fq33v0ywby4i-y01etk

Fill corners until convergence:

https://wolfram.com/xid/0fq33v0ywby4i-c4boro

Find nonoverlapping bounding diamonds of objects:

https://wolfram.com/xid/0fq33v0ywby4i-bbwoi0

Break the H-like features of the image:

https://wolfram.com/xid/0fq33v0ywby4i-ib8x1q

Smooth boundaries and remove noise:

https://wolfram.com/xid/0fq33v0ywby4i-i3assm

Translate objects by two pixels along the specified direction:

https://wolfram.com/xid/0fq33v0ywby4i-dsjvyu


https://wolfram.com/xid/0fq33v0ywby4i-luyr7o

Find branch points in a numeric array:

https://wolfram.com/xid/0fq33v0ywby4i-e6m9o3

Replace the center pixels with the most common pixel value of the neighbors:

https://wolfram.com/xid/0fq33v0ywby4i-ed6dcr

Properties & Relations (3)Properties of the function, and connections to other functions
Compute the rule number that corresponds to a general transformation:

https://wolfram.com/xid/0fq33v0ywby4i-sj7kk8
Rule number for a set of replacement rules that remove isolated foreground pixels:

https://wolfram.com/xid/0fq33v0ywby4i-v2aq9c

Rule number corresponding to the Min function:

https://wolfram.com/xid/0fq33v0ywby4i-zp5z14

Find external boundaries of an image:

https://wolfram.com/xid/0fq33v0ywby4i-c5xaid


https://wolfram.com/xid/0fq33v0ywby4i-jbgamv

Wolfram Research (2010), MorphologicalTransform, Wolfram Language function, https://reference.wolfram.com/language/ref/MorphologicalTransform.html.
Text
Wolfram Research (2010), MorphologicalTransform, Wolfram Language function, https://reference.wolfram.com/language/ref/MorphologicalTransform.html.
Wolfram Research (2010), MorphologicalTransform, Wolfram Language function, https://reference.wolfram.com/language/ref/MorphologicalTransform.html.
CMS
Wolfram Language. 2010. "MorphologicalTransform." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/MorphologicalTransform.html.
Wolfram Language. 2010. "MorphologicalTransform." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/MorphologicalTransform.html.
APA
Wolfram Language. (2010). MorphologicalTransform. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/MorphologicalTransform.html
Wolfram Language. (2010). MorphologicalTransform. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/MorphologicalTransform.html
BibTeX
@misc{reference.wolfram_2025_morphologicaltransform, author="Wolfram Research", title="{MorphologicalTransform}", year="2010", howpublished="\url{https://reference.wolfram.com/language/ref/MorphologicalTransform.html}", note=[Accessed: 09-March-2025
]}
BibLaTeX
@online{reference.wolfram_2025_morphologicaltransform, organization={Wolfram Research}, title={MorphologicalTransform}, year={2010}, url={https://reference.wolfram.com/language/ref/MorphologicalTransform.html}, note=[Accessed: 09-March-2025
]}