# Skeleton from distance map

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)?

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.