Skeleton from distance map
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.