← all repositories
LingDong-/skeleton-tracing

Skeleton Tracing That Returns Strokes, Not Just Outlines

Most skeletonizers hand back a raster image; this one returns actual stroke polylines you can work with.

604 stars C Computer Vision
skeleton-tracing
Not currently ranked — collecting fresh signals.
star history

What it does

skeleton-tracing takes a binary image, thins it with a traditional skeletonization algorithm like Zhang-Suen, then converts the result into a set of polylines — arrays of (x,y) coordinates that follow the topological skeleton. Unlike typical contour-finding methods that produce enclosing outlines, it aims to recover single strokes, even at intersections. The author provides implementations in over a dozen languages, from C and Rust to JavaScript and Unity C#.

The interesting bit

The algorithm uses a parallelizable divide-and-conquer strategy: it recursively splits the image into smaller submatrices until they hit a bottom threshold, traces the border pixels to find “outgoing” coordinates, and merges the partial polylines back together. This sidesteps the usual problem where slight variations in stroke width confuse contour tracers.

Key highlights

  • Ports everywhere: C99 (with pthreads), Go (with goroutines), Rust, Java, pure JavaScript, Python, C#/Unity, Swift, Julia, and more.
  • The C implementation traces at 1,316 FPS on a 300×149 test image on a 2015 MacBook Pro; even vanilla JavaScript manages 513 FPS in Node.js.
  • At the recursive bottom, it uses simple heuristics to distinguish straight lines from crossroads, nudging junction centers via a 3×3 convolution.
  • Developed at Carnegie Mellon’s Frank-Ratchye STUDIO for Creative Inquiry.

Caveats

  • It still depends on an initial raster thinning step; without it, the README warns that output quality is “generally reduced.”
  • The tracing is fast, but the README notes that the raster thinning step often takes longer than the tracing itself, especially on sparse images.
  • The pure Python version is essentially a reference implementation — it clocks in at 1 FPS versus 1,316 in C.

Verdict

Grab this if you need vectorized stroke paths from line art or glyphs and want an algorithm you can parallelize or embed across languages. If you only need a raster skeleton and don’t care about polyline output, it’s overkill.

Frequently asked

What is LingDong-/skeleton-tracing?
Most skeletonizers hand back a raster image; this one returns actual stroke polylines you can work with.
Is skeleton-tracing open source?
Yes — LingDong-/skeleton-tracing is open source, released under the MIT license.
What language is skeleton-tracing written in?
LingDong-/skeleton-tracing is primarily written in C.
How popular is skeleton-tracing?
LingDong-/skeleton-tracing has 604 stars on GitHub.
Where can I find skeleton-tracing?
LingDong-/skeleton-tracing is on GitHub at https://github.com/LingDong-/skeleton-tracing.

heatdrop uses Google Analytics to see which pages get read — nothing else. Your call. How we handle data.