Can anyone give some tips how to obtain Skeleton from distance map?

I already managed to obtain skeleton using erased method (e.g. zhang suen) but it's time consuming because it's an iterative method (the thicker the object the longer it takes).

OpenCV has well optimized distance transform function than can be calculated in O(n) time. Is there any paper or even better code sample that achieves that (ideally quite fast)?


1 Answer 1


The skeleton is a connected set of ridges of the distance transform. It is not a local maximum. The image should be analyzed through derivatives. See Haralick's pioneering work on that: http://haralick.org/journals/ridges_and_valleys.pdf http://haralick.org/journals/topographic_primal_sketch.pdf

And some MATLAB source code is here: http://www.cs.utah.edu/~tch/notes/matlab/tchlib/tpslab.m (and here of course: http://www.cs.utah.edu/~tch/notes/matlab/analysis/) The source code obtains a Topographic Primal Sketch as described by Haralick. Ridges are only a part of that.

Optionally, you could invert the depth map as in $D^{-1}=1/D$, where $D$ is the distance map and $D^{-1}$ denotes the inverse distance function. Then start from a point with the highest distance and compute the shortest distance map using $D^{-1}$ as weights of the undirected graph. You should then select the points on the boundary to compute the shortest path from/to.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.