File Exchange

image thumbnail

2D Line Curvature and Normals

version (8.97 KB) by Dirk-Jan Kroon
Accurate Curvature and Normals of a line/contour consisting of 2D points


Updated 17 Oct 2011

View License

Editor's Note: This file was selected as MATLAB Central Pick of the Week

LineCurvature2D, This function calculates the curvature of a 2D line. It first fits polygons to the points. Then calculates the analytical curvature from the polygons.

K = LineCurvature2D(Vertices,Lines)

Vertices : A M x 2 list of line points.
Lines : A N x 2 list of line pieces, by indices of the vertices
(if not set assume Lines=[1 2; 3 4 ; ... ; M-1 M])

K : M x 1 Curvature values

LineNormals2D, This function calculates the normals, of the line. Using the neighbouring points of each line/contour point, and forward an backward differences on the end points


V : List of points/vertices 2 x M
Lines : A N x 2 list of line pieces, by indices of the vertices
(if not set assume Lines=[1 2; 3 4 ; ... ; M-1 M])

N : The normals of the Vertices 2 x M

Comments and Ratings (27)


Aitor Arana

It's a very nice code but I would like to know the mathematical foundation. Does anybody know it??


ZQ W (view profile)

Felix Oberle

Yaoshen Yuan

linfeng yang

Ilya Belevich


Anwer khan

Ben King


Bojan (view profile)

Hi . Can this code be used to break the curved line into small line segments of appropriate size with their ends overlapped to some small extent and then take hough transform?

can the code be used to find singular points in fingerprint? if yes how plz? thx. Ajit

From what i understand the algorithm only uses the direct neighbors of the point to be evaluated correct? is it possible to include multiple nearby points to get a more accurate result?

Khalid Ali

What is meant by lines?


very useful code. i would also like to know the mathematical model used. does it use the freeman chain code Dirk?


Thank you, good code to find in my case finger tips on a hand scan



Simon (view profile)

Is there any literature to back this up??
Also, the grammar in the comments needs serious work....


Willy (view profile)

Thank you! Very usefull code! I would like to understand the maths behind the code better. Is this code based on some literature?

I would like to point out a small typo:-
L=[(1:(size(V,1)-1))' (2:size(V,1))'];
In the code I saw,the above was :-
Lines=[(1:(size(Vertices,1)-1))' (2:size(Vertices,1))'];


Corrected typo reported by Ravikiran Janardhana

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

Inspired: thick_line(x,y,thickness)

Discover Live Editor

Create scripts with code, output, and formatted text in a single executable document.

Learn About Live Editor