Active contour model

Active contour model, also called snakes, is a framework in computer vision for delineating an object outline from a possibly noisy 2D image. The snakes model is popular in computer vision, and snakes are greatly used in applications like object tracking, shape recognition, segmentation, edge detection and stereo matching.

A snake is an energy minimizing, deformable spline influenced by constraint and image forces that pull it towards object contours and internal forces that resist deformation. Snakes may be understood as a special case of the general technique of matching a deformable model to an image by means of energy minimization.[1] In two dimensions, the active shape model represents a discrete version of this approach, taking advantage of the point distribution model to restrict the shape range to an explicit domain learned from a training set.

Snakes – active deformable models

Snakes do not solve the entire problem of finding contours in images, since the method requires knowledge of the desired contour shape beforehand. Rather, they depend on other mechanisms such as interaction with a user, interaction with some higher level image understanding process, or information from image data adjacent in time or space.

Motivation

In computer vision, contour models describe the boundaries of shapes in an image. Snakes in particular are designed to solve problems where the approximate shape of the boundary is known. By being a deformable model, snakes can adapt to differences and noise in stereo matching and motion tracking. Additionally, the method can find Illusory contours in the image by ignoring missing boundary information.

Compared to classical feature attraction techniques, snakes have multiple advantages:

The key drawbacks of the traditional snakes are

Energy formulation

A simple elastic snake is defined by a set of n points  \mathbf v_i where i=0 \ldots n-1 , the internal elastic energy term E_{internal} , and the external edge-based energy term E_{external} . The purpose of the internal energy term is to control the deformations made to the snake, and the purpose of the external energy term is to control the fitting of the contour onto the image. The external energy is usually a combination of the forces due to the image itself  E_{image} and the constraint forces introduced by the user  E_{con}

The energy function of the snake is the sum of its external energy and internal energy, or

 E_{snake}^*=\int\limits_0^1E_{snake}(\mathbf{v}(s))\,ds=\int\limits_0^1 ( E_{internal}(\mathbf{v}(s))+E_{image}(\mathbf{v}(s))+E_{con}(\mathbf{v}(s)) )\,ds

Internal energy

The internal energy of the snake is composed of the continuity of the contour  E_{cont} and the smoothness of the contour  E_{curv} .

E_{internal}=E_{cont}+E_{curv} [3]

This can be expanded as

E_{internal}=\frac{1}{2}(\alpha\,\!(s)\left | \mathbf{v}_s(s) \right \vert^2) + \frac{1}{2} (\beta\,\!(s)\left | \mathbf{v}_{ss}(s) \right \vert ^2) =\frac{1}{2} \bigg(\alpha\,\!(s) \left \| \frac{d\bar v}{ds}(s) \right \Vert^2 + \beta\,\!(s) \left \| \frac{d^2\bar v}{ds^2}(s) \right \Vert ^2 \bigg)

Where  \alpha (s) and  \beta (s) are user-defined weights; these control the internal energy function's sensitivity to the amount of stretch in the snake and the amount of curvature in the snake, respectively, and thereby control the number of constraints on the shape of the snake.

In practice, a large weight  \alpha (s) for the continuity term penalizes changes in distances between points in the contour. A large weight  \beta (s) for the smoothness term penalizes oscillations in the contour and will cause the contour to act as a thin plate.

Image energy

Energy in the image is some function of the features of the image. This is one of the most common points of modification in derivative methods. Features in images and images themselves can be processed in many and various ways.

For an image  I(x,y) , lines, edges, and terminations present in the image, the general formulation of energy due to the image is

E_{image}=w_{line}E_{line}+w_{edge}E_{edge}+w_{term}E_{term},

where w_{line}, w_{edge}, w_{term} are weights of these salient features. Higher weights indicate that the salient feature will have a larger contribution to the image force.

Line functional

The line functional is the intensity of the image, which can be represented as

E_{line}= I(x,y)

The sign of w_{line} will determine whether the line will be attracted to either dark lines or light lines.

Some smoothing or noise reduction may be used on the image, which then the line functional appears as

E_{line}= filter (I(x,y))

Edge functional

The edge functional is based on the image gradient. One implementation of this is

E_{edge}=-\left | \nabla I(x,y)\right \vert ^2

A snake originating far from the desired object contour may erroneously converge to some local minimum. Scale space continuation can be used in order to avoid these local minima. This is achieved by using a blur filter on the image and reducing the amount of blur as the calculation progresses to refine the fit of the snake. The energy functional using scale space continuation is

E_{edge}=-\left | G_{\sigma} * \nabla ^2 I \right \vert ^2

where  G_{\sigma} is a Gaussian with standard deviation  \sigma . Minima of this function fall on the zero-crossings of  G_{\sigma} \nabla ^2 I which define edges as per Marr–Hildreth theory.

Termination functional

Curvature of level lines in a slightly smoothed image can be used to detect corners and terminations in an image. Using this method, let  C(x,y) be the image smoothed by

 C(x,y)= G_{\sigma}*I(x,y)

with gradient angle

 \theta = \arctan \Bigg ( \frac {C_y}{C_x} \Bigg ),

unit vectors along the gradient direction

 \mathbf n = (\cos \theta,\sin \theta),

and unit vectors perpendicular to the gradient direction

\mathbf n_{\perp}= (-\sin \theta,\cos \theta) .

The termination functional of energy can be represented as

 E_{term}={\partial \theta\over\partial n_{\perp}} = {\partial^2 C / \partial^2 n_{\perp} \over  \partial C / \partial n} = {{C_{yy}C_x^2-2C_{xy}C_xC_y+C_{xx}C_y^2}\over(1+C_x^2+C_y^2)^{3/2}}

Constraint energy

Some systems, including the original snakes implementation, allowed for user interaction to guide the snakes, not only in initial placement but also in their energy terms. Such constraint energy  E_{con} can be used to interactively guide the snakes towards or away from particular features.

Optimization through gradient descent

Given an initial guess for a snake, the energy function of the snake is iteratively minimized. Gradient descent minimization is one of the simplest optimizations which can be used to minimize snake energy.[4] Each iteration takes one step in the negative gradient of the point with controlled step size  \gamma to find local minima. This gradient-descent minimization can be implemented as

\bar v_i \leftarrow \bar v_i + F_{snake}(\bar v_i)

Where  F_{snake}(\bar v_i) is the force on the snake, which is defined by the negative of the gradient of the energy field.

 F_{snake}(\bar v_i) = - \nabla E_{snake} (\bar v_i) = - \Bigg( w_{internal} \nabla E_{internal} (\bar v_i)+w_{external} \nabla E_{external} (\bar v_i) \Bigg)

Assuming the weights  \alpha(s) and  \beta(s) are constant with respect to  s , this iterative method can be simplified to

\bar v_i= \leftarrow \bar v_i - \gamma \Bigg\{ w_{internal} \bigg[ \alpha \frac{\partial ^2 \bar v}{\partial s^2} (\bar v_i)+\beta \frac{\partial ^4 \bar v}{\partial s^4} (\bar v_i) \bigg] + \nabla E_{ext} (\bar v_i) \Bigg\}

Discrete approximation

In practice, images have finite resolution and can only be integrated over finite time steps  \tau . As such, discrete approximations must be made for practical implementation of snakes.

The energy function of the snake can be approximated by using the discrete points on the snake.

E_{snake}^*\approx \displaystyle \sum_1^n E_{snake}(\bar v_i)

Consequentially, the forces of the snake can be approximated as

F_{snake}^*\approx -\displaystyle \sum_1^n \nabla E_{snake} (\bar v_i)

Gradient approximation can be done through any finite approximation method with respect to s, such as Finite difference.

Numerical instability due to discrete time

The introduction of discrete time into the algorithm can introduce updates which the snake is moved past the minima it is attracted to; this further can cause oscillations around the minima or lead to a different minima being found.

This can be avoided through tuning the time step such that the step size is never greater than a pixel due to the image forces. However, in regions of low energy, the internal energies will dominate the update.

Alternatively, the image forces can be normalized for each step such that the image forces only update the snake by one pixel. This can be formulated as

 F_{image} = - k \frac{\nabla E_{image}}{\|\nabla E_{image}\|}

where  \tau k is near the value of the pixel size. This avoids the problem of dominating internal energies that arise from tuning the time step.[5]

Numerical instability due to discrete space

The energies in a continuous image may have zero-crossing that do not exist as a pixel in the image. In this case, a point in the snake would oscillate between the two pixels that neighbor this zero-crossing. This oscillation can be avoided by using interpolation between pixels instead of nearest neighbor.[5]

Implementation

The following pseudocode implements the snakes method in a general form

function v = snakes (I, v)
  % INPUT: N by M image I, a contour v of n control points
  % OUTPUT: converged contour v of n control points

  E_image = generateImageEnergy (I);

  while not converged
    F_cont = weight.alpha * contourDerivative(v, 2);
    F_curv = weight.beta * contourDerivative(v, 4);
    F_image = interp2 (E_image, v(:,2), v(:,1));
    F_image_norm = weight.k * F_image ./ norm (F_image);
    F_con = inputForces();

    F_internal = F_cont + weight.external * F_curv;
    F_external = weight.external * (F_image + F_con);

    v = updateSnake(v, F_internal, F_external);

    checkConvergence ();
  end

end

Where generateImageEnergy (I) can be written as

function E_image = generateImageEnergy (I)
  [C, Cx, Cy, Cxx, Cxy, Cyy] = generateGradients (I);

  E_line = I;
  E_edge = -(Cx.^2 + Cy.^2)^0.5;
  E_term = (Cyy.*Cx.^2 - 2*Cxy.*Cx.*Cy + Cxx.*Cy.^2)./((1 + Cx.^2 + Cy.^2).^(1.5));

  E_image = weight.line * E_line + weight.edge * E_edge + weight.term * E_term;
end

Some variants of snakes

The default method of snakes has various limitation and corner cases where the convergence performs poorly. Several alternatives exist which addresses issues of the default method, though with their own trade-offs. A few are listed here.

GVF snake model

The gradient vector flow (GVF) snake model[6] addresses two issues with snakes:

In 2D, the GVF vector field  F_{GVF} minimizes the energy functional

 E_{GVF} = \int \int \mu(u_x^2+u_y^2+v_x^2+v_y^2)+|\nabla f|^2|\mathbf v-\nabla f|^2 dx dy

where  \mu is a controllable smoothing term. This can be solved by solving the Euler equations

 \mu \nabla^2 u - \Bigg (u - \frac{\partial}{\partial x}F_{ext}\Bigg )\Bigg (\frac{\partial}{\partial x}F_{ext}(x,y)^2 + \frac{\partial}{\partial y}F_{ext}(x,y)^2\Bigg ) = 0
 \mu \nabla^2 v - \Bigg (v - \frac{\partial}{\partial y}F_{ext}\Bigg )\Bigg (\frac{\partial}{\partial x}F_{ext}(x,y)^2 + \frac{\partial}{\partial y}F_{ext}(x,y)^2\Bigg ) = 0

This can be solved through iteration towards a steady-state value.

 u_{i+1} = u_i + \mu \nabla^2 u_i - \Bigg (u_i - \frac{\partial}{\partial x}F_{ext}\Bigg )\Bigg (\frac{\partial}{\partial x}F_{ext}(x,y)^2 + \frac{\partial}{\partial y}F_{ext}(x,y)^2\Bigg )
 v_{i+1} = v_i + \mu \nabla^2 v_i - \Bigg (v_i - \frac{\partial}{\partial y}F_{ext}\Bigg )\Bigg (\frac{\partial}{\partial x}F_{ext}(x,y)^2 + \frac{\partial}{\partial y}F_{ext}(x,y)^2\Bigg )

This result replaces the default external force.

 F_{ext}^* = F_{GVF}

The primary issue with using GVF is the smoothing term  \mu causes rounding of the edges of the contour. Reducing the value of  \mu reduces the rounding but weakens the amount of smoothing.

The balloon model

The balloon model[5] addresses these problems with the default active contour model:

The balloon model introduces an inflation term into the forces acting on the snake

F_{inflation} = k_1 \vec n (s)

where  \vec n (s) is the normal unitary vector of the curve at  v(s) and  k_1 is the magnitude of the force.  k_1 should have the same magnitude as the image normalization factor  k and be smaller in value than  k to allow forces at image edges to overcome the inflation force.

Three issues arise from using the balloon model:

Diffusion snakes model

The diffusion snake model[7] addresses the sensitivity of snakes to noise, clutter, and occlusion. It implements a modification of the Mumford–Shah functional and its cartoon limit and incorporates statistical shape knowledge. The default image energy functional  E_{image} is replaced with


E_{image}^* = E_i + \alpha E_c

where  E_i is based on a modified Mumford–Shah functional


E[J,B] = \frac{1}{2} \int _D (I(\vec x) - J(\vec x))^2 d \vec x  + \lambda \frac{1}{2} \int _{D/B} \vec \nabla J(\vec x) \cdot \vec \nabla J(\vec x) d \vec x + \nu \int _0^1 \Bigg ( \frac{d}{ds}B(s) \Bigg )^2 ds

where  J(\vec x) is the piecewise smooth model of the image  I(\vec x) of domain  D . Boundaries  B(s) are defined as


B(s) = \sum_{n=1}^N \vec p_n B_n (s)

where  B_n (s) are quadratic B-spline basis functions and  \vec p_n are the control points of the splines. The modified cartoon limit is obtained as  \lambda \to \infty and is a valid configuration of  E_i .

The functional E_c is based on training from binary images of various contours and is controlled in strength by the parameter  \alpha . For a Gaussian distribution of control point vectors  \vec z with mean control point vector  \vec z_0 and covariance matrix  \Sigma , the quadratic energy that corresponds to the Gaussian probability is


E_c(\vec z) = \frac{1}{2} (\vec z - \vec z_0)^t \Sigma^*(\vec z - \vec z_0)

The strength of this method relies on the strength of the training data as well as the tuning of the modified Mumford–Shah functional. Different snakes will require different training data sets and tunings.

Geometric active contours

Geometric active contour, or geodesic active contour (GAC)[8] or conformal active contours[9] employs ideas from Euclidean curve shortening evolution. Contours split and merge depending on the detection of objects in the image. These models are largely inspired by level sets, and have been extensively employed in medical image computing.

For example, the gradient descent curve evolution equation of GAC is [8]


\frac{\partial C}{\partial t} = g(I)(c+\kappa)\vec{N}-\langle\nabla g,\vec{N}\rangle\vec{N}

where  g(I) is a halting function, c is a Lagrange multiplier, 
\kappa
is the curvature, and 
\vec{N}
is the unit inward normal. This particular form of curve evolution equation is only dependent on the velocity in the normal direction. It therefore can be rewritten equivalently in an Eulerian form by inserting the level set function  \Phi into it as follows


\frac{\partial \Phi}{\partial t} = |\nabla \Phi| {\rm div} \Bigg ( g(I)\frac{ \nabla \Phi}{|\nabla \Phi|} \Bigg ) + c g(I) |\nabla \Phi|

This simple yet powerful level-set reformation enables active contours to handle topology changes during the gradient descent curve evolution. It has inspired tremendous progress in the related fields, and using numerical methods to solve the level-set reformulation is now commonly known as the level set method. Although the level set method has become quite a popular tool for implementing active contours, Wang and Chan argued that not all curve evolution equations should be directly solved by it.[10]

More recent developments in active contours address modeling of regional properties, incorporation of flexible shape priors and fully automatic segmentation, etc.

Statistical models combining local and global features have been formulated by Lankton and Allen Tannenbaum.[11]

Relations to graph cuts

Graph cuts, or max-flow/min-cut, is a generic method for minimizing a particular form of energy called Markov random field (MRF) energy. The Graph cuts method has been applied to image segmentation as well, and it sometimes outperforms the level set method when the model is MRF or can be approximated by MRF.

References

  1. Kass, M.; Witkin, A.; Terzopoulos, D. (1988). "Snakes: Active contour models" (PDF). International Journal of Computer Vision 1 (4): 321. doi:10.1007/BF00133570.
  2. Snakes: an active model,Ramani Pichumani,http://homepages.inf.ed.ac.uk/rbf/CVonline/LOCAL_COPIES/RAMANI1/node31.html
  3. Dr. George Bebis,University of Nevada,http://www.cse.unr.edu/~bebis/CS791E/Notes/DeformableContours.pdf
  4. Image Understanding,Bryan S. Morse,Brigham Young University,1998-2000 http://homepages.inf.ed.ac.uk/rbf/CVonline/LOCAL_COPIES/MORSE/iu.pdf
  5. 1 2 3 Laurent D. Cohen, On active contour models and balloons, CVGIP: Image Understanding, Volume 53, Issue 2, March 1991, Pages 211-218, ISSN 1049-9660, doi:10.1016/1049-9660(91)90028-N
  6. C. Xu and J.L. Prince, "Gradient Vector Flow: A New External Force for Snakes," Proc. IEEE Conf. on Comp. Vis. Patt. Recog. (CVPR), Los Alamitos: Comp. Soc. Press, pp. 66–71, June 1997, http://iacl.ece.jhu.edu/pubs/p087c.pdf
  7. Cremers, D.; Schnorr, C.; Weickert, J. "Diffusion-snakes: combining statistical shape knowledge and image information in a variational framework". Proceedings. IEEE Workshop on 50: 137–144. doi:10.1109/VLSM.2001.938892.
  8. 1 2 Geodesic Active Contours, V. Caselles, R. Kimmel, G. Sapiro http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.21.2196
  9. Conformal curvature flows: From phase transitions to active vision, Satyanad Kichenassamy, Arun Kumar, Peter Olver, Allen Tannenbaum and Anthony Yezzi http://www.springerlink.com/content/u457157212872201/
  10. Wang, Junyan; Chan, Kap Luk (2014-07-08). "Active Contour with a Tangential Component". Journal of Mathematical Imaging and Vision 51 (2): 229–247. doi:10.1007/s10851-014-0519-y. ISSN 0924-9907.
  11. Lankton, S.; Tannenbaum, A., "Localizing Region-Based Active Contours," Image Processing, IEEE Transactions on , vol.17, no.11, pp.2029,2039, Nov. 2008 doi: 10.1109/TIP.2008.2004611 http://ieeexplore.ieee.org/xpls/abs_all.jsp?arnumber=4636741&tag=1

External links

Sample code

This article is issued from Wikipedia - version of the Wednesday, January 20, 2016. The text is available under the Creative Commons Attribution/Share Alike but additional terms may apply for the media files.