Code covered by the BSD License

### Highlights from 2D Line Curvature and Normals

4.6
4.6 | 5 ratings Rate this file 107 Downloads (last 30 days) File Size: 8.97 KB File ID: #32696 Version: 1.3

# 2D Line Curvature and Normals

### Dirk-Jan Kroon (view profile)

26 Aug 2011 (Updated )

Accurate Curvature and Normals of a line/contour consisting of 2D points

### Editor's Notes:

This file was selected as MATLAB Central Pick of the Week

File Information
Description

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)

inputs,
Vertices : A M x 2 list of line points.
(optional)
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])

outputs,
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

N=LineNormals2D(V,L)

inputs,
V : List of points/vertices 2 x M
(optional)
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])

outputs,
N : The normals of the Vertices 2 x M

Acknowledgements

This file inspired Thick Line(X,Y,Thickness).

MATLAB release MATLAB 7.12 (R2011a)
23 Jun 2015 Robbin van Hoek

### Robbin van Hoek (view profile)

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?

12 Mar 2015 Khalid Ali

### Khalid Ali (view profile)

What is meant by lines?

Comment only
12 Jan 2015 rabeeah

### rabeeah (view profile)

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

Comment only
29 Aug 2014 Michael

### Michael (view profile)

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

18 Feb 2014 Yunfeng

### Yunfeng (view profile)

08 Jul 2013 Simon

### Simon (view profile)

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

Comment only
18 Jan 2013 Willy

### 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?

15 Oct 2011 Ravikiran Janardhana

### Ravikiran Janardhana (view profile)

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