File Exchange

image thumbnail

ashape: a pedestrian alpha shape extractor

version (95.4 KB) by us
extracts 2d alpha shapes from a set of x/y data points


Updated 13 Apr 2010

View Version History

View License

ASHAPE is a simple wrapper for ASLIB, which implements several (optimized) subroutines to extract and display 2d alpha shapes and alpha patches from a set of x/y data points

ASLIB returns a structure, which contains all relevant parameters, data and results including graphics handles to plotted elements

furthermore, ASLIB returns function handles to all of its computational and graphics subroutines, which can be used by a programmer to create more elaborate wrappers or guis

the latest version of ASLIB can always be attached to an existing set of parameters p by
> p.f = aslib;
or by simply re-running the data
> p = ashape(p);

for general instructions see:
> help ashape
> help aslib
for explanations of subroutines and a small glossary of terms see:
> aslib -s
for explanations of fields see:
> aslib -f
for explanations of options see:
> aslib -o

look at the accompanying published m-file for a few examples

Cite As

us (2021). ashape: a pedestrian alpha shape extractor (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (21)

Johannes Korsawe

I like this code and it works fine for early releases. Could it be updated to also work for 2014b?


Hey, congrats for excellent code:]
Could you let me know where can I find the coordinates of final alpha shape? I'm asking because I don't need the line but just points.
Thanks in advance!


Daphne, I assume you solved your earlier issue. Here is how I did it.

% p.ashape contains the indices of 2 nodes for each edge; turn it into a single vector (which will have repeats).
indu=unique(ind,'rows'); %cancel doubles.

Now any hints for putting these in order going around the shape? I don't want to use line as in the example. I would like to manipulate the boundary to fit it to other data distributed on the boundary.


thanks a lot....





The code is really great!
In Matlab 2010b I get this comment, which you may want to address:

Warning: DELAUNAY will not support Qhull-specific options in a future release.
Please remove these options when calling DELAUNAY.


For a set of points, I would like to retrieve the index order for the alpha shape. How do I access this? Thanks!


Hello. When I try to run this I get the following error:

??? Error using ==> qhullmx

qhull precision error: 101 attempts to construct a convex hull
with joggled input. Increase joggle above 'QJ3.5'
or modify qh_JOGGLE... parameters in user.h

While executing: | qhull d QJ Pp

Options selected for Qhull 2003.1 2003/12/30:
delaunay Pprecision-ignore Qbbound-last-qj Pgood
_run 101 QJoggle 3.5 _joggle-seed 1537501472 _max-width 3.5e+002
Error-roundoff 7e-010 Width-outside 1.4e-009 _wide-facet 4.2e-009
_narrow-hull 1.1e-010

Last point added to hull was p8420.

At error exit:

Error in ==> delaunayn at 117
t = qhullmx(x', 'd ', opt);

Error in ==> delaunay at 48
tri = delaunayn([x(:) y(:)],options);

Error in ==> aslib>ASLIB_asdelaunay at 1199

Error in ==> aslib>ASLIB_aini at 562

Error in ==> ashape at 72

I'm running R2008B. On another system with R2010a it works with the same data. Any thoughts?


The code works really well!
I would appreciate a cheat, I am trying to get the indices of the ashape edge points and no plot. How should I call the function and what part of the structure will have the data?... Thanks!


...Any chance of a 3D version anytime soon?...
yes, work in progress...


Any chance of a 3D version anytime soon?

Seth Lutske

Hi Matlab People!

Please forgive me if my question is pedestrian, but im new to this community. I would love to try out this ashape and aslib code, but i can't quite figure out where to put the files in my MATLAB directory so as to get the code working and recognized in MATLAB. I have a feeling this is a FAQ, but i can't seem to find the answer to it on the site (though i am new.) Could someone point me in the right direction?


w s

@ S. Tiuí,

shame shame shame for premature accusations.

S. Tiuí

Always the same story. Whenever comes close to get down one position ... thousands of auto-downloads.
Shame shame shame

Ruben S

It would be nice to have a matlab package of 3D version.


Urs (us) Schwarz

i just updated the latest release for the 3rd time in several month... it just doesn't show up! sorry for this

Urs (us) Schwarz

dear matthew, and others using ASHAPE
for absolutely no intelligible reason your nice and concerned email ended up in my SPAM folder (!?!?) - and, i see it only now after a casual check...
anyhow, thank you very much for alerting me to the fact that ASHAPE has NOT been updated as it was supposed to some time ago!:
going back to the FEX entry, i just realize, that the FEX update-engine missed a recent update, which was posted a few month ago and dealt just with the problem you are pointing out...
the problem is this:
- in its recent version, the output of QHULL (most unfortunately!) has changed considerably(!), which also affects the output of DELAUNAYN, the core of DELAUNAY, and other ML stock functions...
- hence, ASDELAUNAY had to be fixed...
- your preliminary fix is NOT correct (sorry for this)
- please, download the latest version as soon as it shows up on the FEX

Matthew Eyster

Great package, gives Matlab some much needed programs for computational geometry.

However, the asdemo.m doesn't work with Matlab 2007a. Here's the fix (for ashape.m in general):

Line 906 of aslib.m:
old: b=find(s(a,:)==1);
fixed: [garbage, b]=find(s(a,:)==1);

Jan Morovic

Very nice and user-friendly package for exploring alpha shapes.

MATLAB Release Compatibility
Created with R2007a
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!