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 "name".

MorphologicalTransform[image,transformation,n]

applies n iterations of transformation on image.

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 all

Basic Examples  (6)

Replace each pixel with the maximum value in each 3×3 neighborhood:

Use a rule that effectively finds isolated foreground pixels:

Use a sequence of operations to create a morphological opening:

Find the upper horizontal boundaries:

Use a named rule:

Iterate a transformation until convergence:

Scope  (17)

Endpoints of a skeleton object:

Branch points of a skeleton object:

Fill one-pixel-wide gaps in images:

Delete isolated foreground pixels:

Delete isolated background pixels:

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

Find the perimeter of the objects:

Remove the 8-connectivity of the background:

Fill corners:

Fill corners until convergence:

Find nonoverlapping bounding diamonds of objects:

Break the H-like features of the image:

Smooth boundaries and remove noise:

Translate objects by two pixels along the specified direction:

Straighten ragged boundaries:

Find branch points in a numeric array:

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

Properties & Relations  (3)

Compute the rule number that corresponds to a general transformation:

Rule number for a set of replacement rules that remove isolated foreground pixels:

Rule number corresponding to the Min function:

Find external boundaries of an image:

Negate an image:

Neat Examples  (1)

Game of Life:

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.

CMS

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

BibTeX

@misc{reference.wolfram_2024_morphologicaltransform, author="Wolfram Research", title="{MorphologicalTransform}", year="2010", howpublished="\url{https://reference.wolfram.com/language/ref/MorphologicalTransform.html}", note=[Accessed: 26-December-2024 ]}

BibLaTeX

@online{reference.wolfram_2024_morphologicaltransform, organization={Wolfram Research}, title={MorphologicalTransform}, year={2010}, url={https://reference.wolfram.com/language/ref/MorphologicalTransform.html}, note=[Accessed: 26-December-2024 ]}