1 function P=SnakeMoveIteration2D(B,P,Fext,gamma,kappa,delta)
\r
2 % This function will calculate one iteration of contour Snake movement
\r
4 % P=SnakeMoveIteration2D(S,P,Fext,gamma,kappa)
\r
7 % B : Internal force (smoothness) matrix
\r
8 % P : The contour points N x 2;
\r
9 % Fext : External vector field (from image)
\r
11 % kappa : External (image) field weight
\r
12 % delta : Balloon Force weight
\r
15 % P : The (moved) contour points N x 2;
\r
17 % Function is written by D.Kroon University of Twente (July 2010)
\r
19 % Clamp contour to boundary
\r
20 P(:,1)=min(max(P(:,1),1),size(Fext,1));
\r
21 P(:,2)=min(max(P(:,2),1),size(Fext,2));
\r
23 % Get image force on the contour points
\r
24 Fext1(:,1)=kappa*interp2(Fext(:,:,1),P(:,2),P(:,1));
\r
25 Fext1(:,2)=kappa*interp2(Fext(:,:,2),P(:,2),P(:,1));
\r
26 % Interp2, can give nan's if contour close to border
\r
27 Fext1(isnan(Fext1))=0;
\r
29 % Calculate the baloonforce on the contour points
\r
30 N=GetContourNormals2D(P);
\r
33 % Update contour positions
\r
34 ssx = gamma*P(:,1) + Fext1(:,1) + Fext2(:,1);
\r
35 ssy = gamma*P(:,2) + Fext1(:,2) + Fext2(:,2);
\r
39 % Clamp contour to boundary
\r
40 P(:,1)=min(max(P(:,1),1),size(Fext,1));
\r
41 P(:,2)=min(max(P(:,2),1),size(Fext,2));
\r