File Exchange

image thumbnail

Surface Curvature

version 1.0 (1.77 KB) by

Vectorized surface curvature computation

25 Ratings



No License

[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.

[X,Y,Z] = peaks;
[K,H,P1,P2] = surfature(X,Y,Z);

Comments and Ratings (35)

Ahmad Faraz

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
[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.

Ahmad Faraz


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

hassan obeid


jiang (view profile)

it works very well, thanks!

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

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,


Nadal (view profile)

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

it works quite well aparently, will test more surfaces

Liam Morrow


Hongli Yang

Hongli Yang

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?


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
[Xu,Xv] = gradient(X);


abuzer (view profile)

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

Error in gradient (line 49)
[err,f,ndim,loc,rflag] = parse_inputs(f,varargin);


dong (view profile)


Ahmad (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 (view profile)


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


soudeh (view profile)

Thank you for your code,
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 (view profile)

very good,thanks a lot!!

vinu arasu

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

Lucas Lorensi

Excellent! Is there a way to compute principal directions?

Ted Teng

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

Jason Zhang

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


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 Release
MATLAB 7 (R14)

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Win prizes and improve your MATLAB skills

Play today