1 function N=GetContourNormals2D(P)
\r
2 % This function calculates the normals, of the contour points
\r
3 % using the neighbouring points of each contour point
\r
5 % N=GetContourNormals2D(P)
\r
8 % P : List with contour coordinates M x 2
\r
11 % N : List with contour normals M x 2
\r
13 % Function is written by D.Kroon University of Twente (July 2010)
\r
15 % Use the n'th neighbour to calculate the normal (more stable)
\r
18 % From array to separate x,y
\r
19 xt=P(:,1); yt=P(:,2);
\r
21 % Derivatives of contour
\r
23 f=(1:n)+a; f(f>n)=f(f>n)-n;
\r
24 b=(1:n)-a; b(b<1)=b(b<1)+n;
\r
29 % Normals of contourpoints
\r
30 l=sqrt(dx.^2+dy.^2);
\r
33 N(:,1)=nx; N(:,2)=ny;
\r