File Exchange

image thumbnail

2-D Medial Axis Computation

version 1.0.0.0 (375 KB) by Krishnan Suresh
Compute the medial axis of 2-D solids whose boundary is made-up of line segments and circular arcs.

6 Downloads

Updated 26 Sep 2006

View License

The attached Matlab routines compute the medial axis of 2-D solids whose boundary is made-up of line segments and circular arcs.
Caveats:
* The attached code is slow.
* There are also a few bugs that we are aware of, and expect to address them; use the code with caution!
* You will need the Matlab optimization toolbox.

Cite As

Krishnan Suresh (2020). 2-D Medial Axis Computation (https://www.mathworks.com/matlabcentral/fileexchange/12399-2-d-medial-axis-computation), MATLAB Central File Exchange. Retrieved .

Comments and Ratings (9)

Michael Butcho

I'm impressed with your work. It works fine also for my own objects. I found out some results from test.m look weird on my R2019b. Is it due to the mentioned bugs, or due to some changes in used toolboxes since the release?

JX Feng

Paul Zhang

It works. see 'test.m' to see demo of how it works. pdeGeom can be built with the following.
First run pdetool in command window. Use the interface to draw a shape. Remember, this toolbox only handles straight and circular arcs. No ellipses. When finished drawing, click 'draw' dropdown, and 'export'. This should create three variables in your workspace gd, sf, and ns. Then run the following.
dl = decsg(gd,sf,ns);
dl is now a pdeGeom object. Also before you use the computeMedialAxis function, you have to set global variables or nothing will come out.

global MMA_DEBUG;
global MMA_REL_TOL;
global MMA_ABS_TOL;
global MMA_FLAT_VERTEX_ON;
MMA_DEBUG = false; %set to true to MA_DEBUG
MMA_REL_TOL = 1e-6; % relative tolerance to merge nearby medial pts, etc
MMA_FLAT_VERTEX_ON = false; % set to true if you find some medial branches to be missing
% it will make the code run even slower!!

I found these parameters in the test.m file.

you can do pdegplot(dl) to plot your geometry.
plotMedialCurves(medialCurves) to plot the medial axis.
It's composed of bezier curves with 2-3 control points.

As the author says, it's not hard to uncover bugs. But it does the job for simple enough examples. Good for quick prototyping, not reliable for a large scale project though.

Zhiping Liu

Thanks for your program.

Neil Patil

Can you please tell me that what exactly is
'pdeGeom'

ntenson

I am interested in using your program. However, could you let me know how to generate the pdeGeom of an image with 2D solids?
Thanks in advance

Nolan Snell

An excellent work. The code is well done, and illustrates the theory well.

Andrea Tagliasacchi

I have to say that at least somebody has a publicly available and easy to use MAT generator :)

I searched for some applets but I didn't find anything really useful...
I was able to get my example done hacking a little bit your program.

Thanks!

scardanzan igor

you declare :
* There are also a few bugs that we are aware of, and expect to address them; use the code with caution!

please do not let bugs to go around !

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