File Exchange

image thumbnail

Better Skeletonization

version (10.8 KB) by Nicholas Howe
Provides an alternative to the image toolbox skeletonization implemented in bwmorph.


Updated 19 Jul 2007

View License

The files in this package comprise the Matlab implementation of a method for skeletonizing binary images. These are my own implementation
of a skeletonization method communicated to me by Alex Telea
( See his papers for more details.

Skeletonization is (roughly speaking) the "thinning" of a binary image or silhouette to a one-pixel width spine. The image processing toolbox provides support for skeletonization via the bwmorph function, but its results do not always conform with our intuition. I have found that the approach used herein usually generates a more pleasing result.

There is also a routine for locating endpoints and junctions in skeletonized images.

(Note: This code has not been optimized for speed.)

Bug fix 7/18/07: In rare instances, isolated points would incorrectly be assigned an infinite value for skg.

Cite As

Nicholas Howe (2021). Better Skeletonization (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (31)

Muhammad Bilal

qiang zhang

a very good project. However, it don't work for three dimension mask. Will you implement a 3D version?

yongming yang

Telea, A., van Wijk, J.J.: An Augmented Fast Marching Method for Computing Skeletons and Centerlines. Proc. IEEE VisSym (2002) 251–258

I tried to run it as
>> [skr,rad] = skeleton(lala);
where lala is my image but I get the following error
Attempt to execute SCRIPT skeleton as a function:
D:\EDEN\EDEN matlab\skeleton.m
and don't know why. What am I doing wrong?

Faten Kharbat

Ben Kang

One thing not clear is how to set the threshold. Have to find it in trial-and-error manner. Once getting the threshold value, it gave me very good results.


Amazing work

Stephan Koehler

Works great - how about the function skelgrad to determine the local radius at each point? This would be very useful!


Matlab's built-in skeletonization is quirky as all hell and this is a necessary contribution, but this algorithm takes a beating on images over 512x512 with significant amounts of material to skeletonize. I cut it off after 5 minutes, which is pretty much unacceptable for a c++ file. You'll need to look elsewhere for high-throughput applications. I'll be trying this next:


Could you tell me the name of the Alex Telea's paper of the references please?

Julien Smets

Thank you but the url of Alex Telea's paper dont work.

Dwi Agung Prastya


John Booker


Has the tool & algorithm been published? If yes, would you please to mention the reference. Thanks a lot for the tool!

Athanasios Balomenos

Nice work, but can I ask you something. How we may compute the threshold (you demostrate in demo file) automatically according to the given object nowing only its shape apriori? Can you give the exact reference of the algorithm?



donny jason

i got it already. It works. Thank you

donny jason

I have try other compiler.I'm using mic studio professional 2008. It seems it is still the same..
how to solve it?

Christopher MacMinn

With regard to my question above (15 Sep 2009), I think I've figured it out -- it looks like the local radius output of the function skeleton() is actually the radius SQUARED. Take the sqrt to get the radius in pixels.

Christopher MacMinn

This package is very useful.

A question: does anyone know what the local radius values correspond to, or what units they are measured in? They are not in pixels.

Matt Fetterman

It is very good. I have suggestions for additional features if you are interested in collaboration.

Casey Ta

For those having trouble compiling skeleton.m and anaskel.m, I had the same issue at first. The Lcc-win32 C 2.4.1 compiler that comes with MATLAB wouldn't compile these files. You'll have to try a different compiler. These files compiled just fine for me after I chose Microsoft Visual Studio 2008 in mex -setup.


I am a Matlab novice, having said that, this code also doesn't work for me, i ran the mex setup, chose a compiler, changed the file path names in skeleton.m and anaskel.m to the correct ones for the cpp files (from the download) - do I need to make any modifications in the C-code? how does it read the image?
I get lots of errors from the .cpp files

elden fisher

it works. you have to modify and run first skeleton.m and anaskel.m as they contain absolute path to the two cpp files for compilation.

Fadi Bazzi

This thing do not work right. Can someone help me? I am getting those errors:

??? Attempt to execute SCRIPT skeleton as a function:

Error in ==> demo at 9

Luis Felipe

Very good.

Jinghong Low

Thanks for your contribution

Scooter NGC

Vincent Pelletier

Nice. For me it turns out that anaskel is the useful routine after all. I'm glad I tried it!

Arvin Fan

It works.

MATLAB Release Compatibility
Created with R14SP2
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!