removes the outermost branches of thin objects in image by setting their values to black.


removes branches that are at most n pixels long.


removes n pixels from each branch.


treats values above t as foreground.

Details and Options

  • Morphological pruning is typically applied after morphological thinning.
  • Pruning works with binary, grayscale, and multichannel images, as well as real matrices.
  • Pruning takes a Padding option that specifies the values to assume for pixels outside the image. The default setting is Padding->0.


open allclose all

Basic Examples  (4)

Prune the outermost branches:

Prune branches that are no longer than 35 pixels:

Prune 35 pixels from branches:

Prune all branches:

Scope  (1)

Apply pruning to a numeric array of data:

Applications  (3)

Count the legs of a centipede:

Compute the difference between skeleton and pruned skeleton:

Count of legs would be equivalent to the number of pruned branches:

Find the loops of a graph:

Iteratively prune an image:

Neat Examples  (1)

Solve a maze puzzle by thinning all paths and pruning dead ends:

Wolfram Research (2010), Pruning, Wolfram Language function,


Wolfram Research (2010), Pruning, Wolfram Language function,


Wolfram Language. 2010. "Pruning." Wolfram Language & System Documentation Center. Wolfram Research.


Wolfram Language. (2010). Pruning. Wolfram Language & System Documentation Center. Retrieved from


@misc{reference.wolfram_2024_pruning, author="Wolfram Research", title="{Pruning}", year="2010", howpublished="\url{}", note=[Accessed: 14-July-2024 ]}


@online{reference.wolfram_2024_pruning, organization={Wolfram Research}, title={Pruning}, year={2010}, url={}, note=[Accessed: 14-July-2024 ]}