Skip to main content
Back to the graphics atlas
FoundationsSegmentation & edgesMorphology Technique Advanced

Skeletonization

Reduce a thick binary shape to a thin centerline while trying to preserve its topology.

Morphology is nested under Segmentation & edges , so the broader pipeline usually still applies here.

graphicsimage-processingmorphologyshape

Interactive playground

Tweak the operator or scene live so the article connects to an immediate visual result.

Skeletonization

Peel away outer layers of a thick mask while preserving topology so the medial structure remains.

Thick binary shape

Skeleton

96 × 96 live preview

More passes push the shape closer to a one-pixel-wide centerline, but only while connectivity stays intact.

Family

Foundations -> Segmentation & edges -> Morphology

Binary-mask operators such as dilation, erosion, opening, and closing.

Builds on

3 topics

Read these first if you want the surrounding pipeline context.

Unlocks

0 next topics

Use these follow-ups when you want to keep turning the image-processing pipeline forward.

Learning paths

1

This topic appears in curated graphics progressions so the next step is obvious.

Problem

A mask may contain a useful shape, but the full thick region is not always the representation you want. Sometimes the informative object is the centerline: roads, vessels, strokes, or elongated structures.

Intuition

Skeletonization repeatedly removes boundary pixels that are not structurally essential, trying to leave behind a one-pixel-wide representation that preserves connectivity and general shape layout.

Core idea

  • Start from a cleaned binary mask.
  • Iteratively remove boundary pixels according to a thinning rule, but only when doing so does not break connectivity.
  • Continue until no more removable pixels remain, or derive the skeleton from ridges in a distance field.

Worked example

A thick handwritten stroke can be thinned to a single-pixel path that still follows the original trajectory. The width disappears, but the topology and centerline remain.

Complexity

Iterative thinning depends on the number of passes, but each pass is linear in the number of pixels. Distance-field-based approaches often pay for the distance transform first, then extract centerline structure.

When to choose it

  • Choose it when centerlines or graph-like structure matter more than filled area.
  • Use opening and closing first if the mask still contains holes or isolated junk.
  • Use a distance transform when you need thickness values directly rather than only the final skeleton.

Key takeaways

  • Skeletonization is topology-aware thinning.
  • The goal is not just making the mask smaller, but preserving structure.
  • Clean input masks matter a lot because noise creates ugly skeleton branches.
  • Distance transforms and thinning algorithms are two common roads to a skeleton.

Practice ideas

  • Skeletonize a thick shape before and after opening/closing to see how cleanup changes spurious branches.
  • Compare a thinning-based skeleton with the ridge structure of a distance transform.
  • Measure path length on the skeleton rather than on the full mask.

Relation to other topics

  • Distance transforms expose the medial structure that skeletons try to keep.
  • Erosion shrinks shapes but does not preserve centerline structure on its own.
  • Connected-components labeling can isolate the object you want before skeletonizing it.

Build on these first

These topics supply the mental model or preceding stage that this page assumes.

Related directions

These topics live nearby conceptually, even if they are not strict prerequisites.

More from Morphology

Stay in the same family when you want parallel operators built from the same mental model.

Paths that include this topic

Follow one of these sequences if you want a guided next step instead of open-ended browsing.

Mask analysis and cleanup

Build a binary mask, explore connectivity, then repair or simplify it with morphology-aware tools.

From the blog

Pair the graphics atlas with recent writing from the broader site whenever you want a wider engineering lens.