1 function Fext=GVFOptimizeImageForces3D(Fext, Mu, Iterations, Sigma)
\r
2 % This function "GVFOptimizeImageForces" does gradient vector flow (GVF)
\r
3 % on a vector field. GVF gives the edge-forces a larger capature range,
\r
4 % to make the snake also reach concave regions
\r
6 % Fext = GVFOptimizeImageForces3D(Fext, Mu, Iterations, Sigma)
\r
9 % Fext : The image force vector field N x M x 3
\r
10 % Mu : Is a trade of scalar between noise and real edge forces
\r
11 % Iterations : The number of GVF itterations
\r
12 % Sigma : Used when calculating the Laplacian
\r
15 % Fext : The GVF optimized image force vector field
\r
17 % Function is written by D.Kroon University of Twente (July 2010)
\r
19 % Squared magnitude of force field
\r
24 % Calculate magnitude
\r
25 sMag = Fx.^2+ Fy.^2 + Fz.^2;
\r
27 % Set new vector-field to initial field
\r
30 % Iteratively perform the Gradient Vector Flow (GVF)
\r
32 % Calculate Laplacian
\r
33 Uxx=ImageDerivatives3D(u,Sigma,'xx');
\r
34 Uyy=ImageDerivatives3D(u,Sigma,'yy');
\r
35 Uzz=ImageDerivatives3D(u,Sigma,'zz');
\r
37 % Update the vector field
\r
38 u = u + Mu*(Uxx+Uyy+Uzz) - sMag.*(u-Fx);
\r
39 clear('Uxx','Uyy','Uzz');
\r
41 Vxx=ImageDerivatives3D(v,Sigma,'xx');
\r
42 Vyy=ImageDerivatives3D(v,Sigma,'yy');
\r
43 Vzz=ImageDerivatives3D(v,Sigma,'zz');
\r
45 v = v + Mu*(Vxx+Vyy+Vzz) - sMag.*(v-Fy);
\r
46 clear('Vxx','Vyy','Vzz');
\r
48 Wxx=ImageDerivatives3D(w,Sigma,'xx');
\r
49 Wyy=ImageDerivatives3D(w,Sigma,'yy');
\r
50 Wzz=ImageDerivatives3D(w,Sigma,'zz');
\r
52 w = w + Mu*(Wxx+Wyy+Wzz) - sMag.*(w-Fz);
\r
53 clear('Wxx','Wyy','Wzz');
\r