1 function Eextern = ExternalForceImage2D(I,Wline, Wedge, Wterm,Sigma)
\r
2 % Eextern = ExternalForceImage2D(I,Wline, Wedge, Wterm,Sigma)
\r
6 % Sigma : Sigma used to calculated image derivatives
\r
7 % Wline : Attraction to lines, if negative to black lines otherwise white
\r
9 % Wedge : Attraction to edges
\r
10 % Wterm : Attraction to terminations of lines (end points) and corners
\r
13 % Eextern : The energy function described by the image
\r
15 % Function is written by D.Kroon University of Twente (July 2010)
\r
17 Ix=ImageDerivatives2D(I,Sigma,'x');
\r
18 Iy=ImageDerivatives2D(I,Sigma,'y');
\r
19 Ixx=ImageDerivatives2D(I,Sigma,'xx');
\r
20 Ixy=ImageDerivatives2D(I,Sigma,'xy');
\r
21 Iyy=ImageDerivatives2D(I,Sigma,'yy');
\r
24 Eline = imgaussian(I,Sigma);
\r
25 Eterm = (Iyy.*Ix.^2 -2*Ixy.*Ix.*Iy + Ixx.*Iy.^2)./((1+Ix.^2 + Iy.^2).^(3/2));
\r
26 Eedge = sqrt(Ix.^2 + Iy.^2);
\r
28 Eextern= (Wline*Eline - Wedge*Eedge -Wterm * Eterm);
\r