WLJS LogoWLJS Notebook

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.

Examples

Skeletonize an image:

img = Binarize[ExampleData[{"TestImage", "Shapes"}]];
MorphologicalTransform[img, "Skeleton"]

Custom transformation:

MorphologicalTransform[img, If[#[[2, 2]] == 1 && Total[#, 2] > 4, 1, 0] &]

Multiple iterations:

MorphologicalTransform[img, "Thin", 5]

Please visit the official Wolfram Language Reference for more details.

On this page