File Exchange

## Surface Curvature

version 1.0 (1.77 KB) by

Vectorized surface curvature computation

4.78261
25 Ratings

Updated

[K,H,P1,P2] = surfature(X,Y,Z) returns the gaussian curvature of a surface (K), mean curvature (H), and principal curvatures (P1,P2). The inputs (X,Y,Z) are 2D arrays corresponding to the surface being analyzed.

Example
[X,Y,Z] = peaks;
[K,H,P1,P2] = surfature(X,Y,Z);
surf(X,Y,Z,H,'facecolor','interp');
set(gca,'clim',[-1,1])

behnam tayebi

### behnam tayebi (view profile)

Hello guys. I have seen comments from many peoples here about what is 2d array. I was also wondering what is 2D array here.
We have point cloud data which is basically in n*3 form. Author created meshgrid along XY direction(output 2D matrices) and created Z matrix from meshgird of XY(also a 2D matrix).
In my view it follows something like this
mex=Mesh(:,1);
mey=Mesh(:,2);
mez=Mesh(:,3);
xmin=floor(min(mex));
xmax=floor(max(mex));
ymin=ceil(min(mey));
ymax=ceil(max(mey));
[xm, ym]=meshgrid(xmin:1:xmax,ymin:1:ymax);
Now you can create zm 2D matrix from xm and ym matrices.
Lemme know if you need help. I am sorry i am very poor in english.

Mandeep Dhanda

masyrezaei

### masyrezaei (view profile)

hi, what is 2d array, X, Y , Z are 1d array corresponding to coordinates. what is 2d array for them?
thanks

Amirali Nojoomi

hassan obeid

jiang

### jiang (view profile)

it works very well, thanks！

I will be very grateful if you inform me about the reference to this implementatiion.

Catarina Veiga

### Catarina Veiga (view profile)

Hi Andres,

Thank you very much for implementing these curvatures measures, it has been really helpful.
Is there any reference specific to this implementation?

Kind regards,
Catarina

Hi Andres,

Getting following error:
Error in ==> gradient at 49
[msg,f,ndim,loc,rflag] = parse_inputs(f,varargin);
Too many outputs

Can you just share a sample example showing how to pass parameters to run the code.

Andres Cruz

### Andres Cruz (view profile)

it works quite well aparently, will test more surfaces

Bahareh Tolooshams

Liam Morrow

Thomas Atta-Fosu

Perfect!

Hongli Yang

Hongli Yang

### Hongli Yang (view profile)

try to contact author, but email expired
do someone knows what the sign here means, for each point, the curvature could be positive or negative. If we want to have a mean curvature of the whole surface, should we consider the sign or not?

Othmani

### Othmani (view profile)

I am trying to run the code with 3D data but I gets this problem :
Error in ==> gradient at 49
[msg,f,ndim,loc,rflag] = parse_inputs(f,varargin);

??? Output argument "varargout{2}" (and maybe others) not assigned during call to "C:\Program

Error in ==> surfature at 11

abuzer

### abuzer (view profile)

thank you for code however it does not run for 3D data and the error occured.

[err,f,ndim,loc,rflag] = parse_inputs(f,varargin);

dong

### dong (view profile)

this is that I want i.e. all types of curvature.
BUT(!) I have a point cloud that every point have x,y&z(3D coordinate).
Can I calculate curvature of each point?
If yes then how?
thank U

Daniel

Caitlin

### Caitlin (view profile)

I am also wondering what the 2D input arrays corresponding to the surface are?

soudeh

### soudeh (view profile)

I am trying to obtain the principal curvatures (K1,K2) for each voxels(x,y,z) of a 3d image that has an intensity value. These values are calculated based on Gaussian and mean curvatures . How can I use your code in order to get my results.

bnu

### bnu (view profile)

very good,thanks a lot!!

vinu arasu

### vinu arasu (view profile)

Could you please explain what is 2D arrays corresponding to the surface being analyzed??

Lucas Lorensi

### Lucas Lorensi (view profile)

Excellent! Is there a way to compute principal directions?

Ted Teng

### Ted Teng (view profile)

By definition, H>0 for convex surface, so it seems negative Z corresponding to convex?

Jason Zhang

### Jason Zhang (view profile)

Cool, see how it works!

krog babuz'

Hi, could you please specify what the 2D arrays for X,Y,Z actually are?

Su Ping

cool, I'm looking for this

ewe wewe

Giancanio Sileo

Very good tool for curvature computation.

Michael Girard

COOL

mustafa yagci

Tao Ye

i've been trying to find code to perform some computational geometry tasks, this one is very much helpful. Thank you.

MATLAB 7 (R14)