Skip to content

Skeleton thinning

Algorithm atlasMorphology

Iteratively remove boundary pixels while trying to preserve the connectivity of a binary shape.

Try it on your image ↓

VISUAL WALKTHROUGHMorphology
REFERENCE INPUTBinary mask

Two objects and a single-pixel speck make growth, shrinkage and cleanup easy to compare.

RESULTChanged foreground

100 foreground pixels become 10. Zhang-Suen sub-iterations remove boundary pixels while preserving connectivity. The final skeleton is computed from this mask.

STEP 03 / 03

Repeat until no more pixels can be removed.

Computed teaching example on a 24 × 16 image. Small kernels and simplified settings keep each change visible; use the image laboratory for native OpenCV.

Try it on an image

YOUR IMAGE · REAL OPENCV

Experiment at pixel level

Open full lab ↗

Skeletonize the thresholded white foreground.

The engine loads on your first run. Your images stay in this browser.

Input448 × 320
OutputWaiting for a result

Scroll over either image to zoom at the pointer. Use the scrollbars to pan both views over the same relative area. Zoom is relative to the input; pixel coordinates belong to each image. Warps can change scene correspondence.

Pixel inspector RGBA · native values · matched scale · 9 × 9 output pixels
Hover to inspect. Click to pin a pixel.
Input
Select a pixel

Output
Select a pixel

Sample models and licenses

When to use it

Reduce strokes or elongated regions to a compact centreline representation.

How it works

  1. 01Identify removable boundary pixels.
  2. 02Apply topology-preserving deletion rules in sub-iterations.
  3. 03Repeat until no more pixels can be removed.

thick connected region → topology-preserving thin strokes

What to tune

Use a binary 8-bit image and choose the supported Zhang-Suen or Guo-Hall method.

Where it breaks down

Small boundary defects can create skeleton branches. A skeleton is not necessarily the same as a medial axis from Euclidean distances.

TypeScript API

Open an entry for its exact overloads, parameter descriptions, result ownership and pinned upstream source.

All of these calls execute on the CPU. Native objects need explicit disposal. See matrices and ownership and build compatibility.