Code covered by the BSD License  

Highlights from
Alpha shapes

5.0

5.0 | 5 ratings Rate this file 64 Downloads (last 30 days) File Size: 3.46 KB File ID: #28851
image thumbnail

Alpha shapes

by Jonas Lundgren

 

27 Sep 2010 (Updated 08 Mar 2012)

Alpha shape of 2D/3D point set.

| Watch this File

File Information
Description

Computes the basic Alpha shape of a 2D/3D point set by Delaunay triangulation.

OUTPUT:
- Area/Volume
- Triangulation of Alpha shape
- Boundary of Alpha shape
- Plot

MATLAB release MATLAB 7.11 (2010b)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (13)
29 Sep 2010 k Z

Hi, nice code. Although the algorithm is useful when nonconvex data is used, I tested on convex data to check how robust it is. I try the sphere function. The volume of the sphere using alpha=Inf is not the same as the sphere volume, in this case the function convhulln computes more accurately the volume. It seems that summing the volume of all tetrahedron counts more that the overal volume, at least for this case. Check this please.

30 Sep 2010 Jonas Lundgren

k Z, Thank you for the feedback. It seems to be a problem with DelaunayTri and nonunique data points. DelaunauyTri is also very slow for equally spaced data. I will switch to delaunayn and remove nonunique data points - when I have the time.

15 May 2011 Ajay

Works well and easy to use, thanks much.

21 Jun 2011 HARI KRISHNAN

thanks a lot

21 Dec 2011 Yuri Kotliarov

It looks like the algorithm unequally connects point vertically and horizontally.
Try this data, for example:
n = 1000;
k = 10;
x = linspace(0,1,n)';
y(:,1) = k*x + randn(n,1) - k/2;
y(:,2) = -k*x + randn(n,1) + k/2;
xx = [x;x];
yy = y(:);
alphavol([xx yy], 0.5, 1);

22 Dec 2011 Jonas Lundgren

Yuri, try the command "axis equal".

30 Dec 2011 ping  
24 Feb 2012 Borc  
24 Feb 2012 Borc

Thanks for this nice code!
One Question:
There are some artefacts inside the volume (like rectangles). How could I avoid them?
As an example run the "3D Example - Ring" with the plotsettings 'FaceColor','r' and 'FaceAlpha',0.5 to see the artefacts inside the volume.
A solution would be very helpfully for me.
Thanks in advance

27 Feb 2012 Jonas Lundgren

Borc, Yes I am aware of these artefacts in the 3D case. Thats why the code only delivers volume and not boundary faces. I will give this some thought.

26 Apr 2012 Jorge Leandro

As I try to run one of your examples, Matlab (7.8.0 R2009) complains with the following message: "??? Error: File: alphavol.m Line: 78 Column: 3
Expression or statement is incorrect--possibly unbalanced (, {, or [."

Examining the referred line, I see:
[~,rcc] = circumcenters(TriRep(T,X));

It seems that Matlab cannot understand the tilde as an output value. I tried to change it to [cc rcc] = circumcenters... and now Matlab complains about line 194, which reads:
[~,p,r] = dmperm(C);
Again, the tilde seems to be the problem.
By the way, as far I as know, tilde is used as a negation operator in Matlab. What is its use here? Any clue on how to solve this problem?

Regards.

27 Apr 2012 Jonas Lundgren

Jorge Leandro, tilde represents an unused argument. This notation was introduced in MATLAB 2009b. You can safely replace tilde by a dummy variable.

22 May 2012 Md Wahid

hi, just a quick note. 'delaunay()' requires at least 2 inputs (x,y as a vector, probably couldnt take matrix). i was trying with the 2d example that provided in the code. changed in the 65th line as 'delaunay(X(:,1),X(:,2))'. now it works, the graph looks nice. thanks for the code. i didnt look inside or try with the theory yet, could be wrong! just to let you know...

Please login to add a comment or rating.
Updates
05 Oct 2010

DelaunayTri replaced by delaunayn. 3D plots added.

29 Sep 2011

New contact info

08 Mar 2012

More output added. DELAUNAYN replaced by DELAUNAY.

Tag Activity for this File
Tag Applied By Date/Time
alpha shape Jonas Lundgren 27 Sep 2010 10:56:48
alpha shapes Jonas Lundgren 27 Sep 2010 10:56:48
volume Jonas Lundgren 27 Sep 2010 10:56:48
area Jonas Lundgren 27 Sep 2010 10:56:48
geometry Jonas Lundgren 27 Sep 2010 10:56:48
alpha shape Benedikt 26 Jan 2011 04:51:53
alpha shapes Benedikt 26 Jan 2011 04:51:56
alpha shapes HARI KRISHNAN 08 Jun 2011 00:11:28
alpha hull Jonas Lundgren 08 Mar 2012 09:37:43
boundary Jonas Lundgren 08 Mar 2012 09:37:43
delaunay Jonas Lundgren 08 Mar 2012 09:37:43

Contact us at files@mathworks.com