Skeleton thinning
Iteratively remove boundary pixels while trying to preserve the connectivity of a binary shape.
Two objects and a single-pixel speck make growth, shrinkage and cleanup easy to compare.
The orange window straddles the object boundary. Its covered pixels determine the new centre value.
Zhang-Suen sub-iterations remove boundary pixels while preserving connectivity. The final skeleton is computed from this mask.
100 foreground pixels become 10. Zhang-Suen sub-iterations remove boundary pixels while preserving connectivity. The final skeleton is computed from this mask.
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
Experiment at pixel level
Skeletonize the thresholded white foreground.
The engine loads on your first run. Your images stay in this browser.
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
Select a pixel
Select a pixel
When to use it
Reduce strokes or elongated regions to a compact centreline representation.
How it works
- 01Identify removable boundary pixels.
- 02Apply topology-preserving deletion rules in sub-iterations.
- 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.
Related methods
Erosion
Shrink a bright mask by taking the minimum under a structuring element.
Dilation
Expand a bright mask by taking the maximum under a structuring element.
Opening, closing and morphology
Compose erosions and dilations to remove small structures or measure their boundaries.
Distance transforms
For every nonzero pixel, measure the distance to the nearest zero pixel.