Skip main navigation

Model-based Image Analysis : Active Contours or Snakes

A description of the active contour or snakes method of object-based image segmentation

A look at the model-based image analysis approach, and a more detailed description of one such approach, active contours or snakes.

Model-based image analysis

Model-based image analysis is distinguished from other approaches by its use of an explicit model of the object, or more commonly class of objects, being analysed. Of course, all image analysis programs incorporate some knowledge of the task at hand, but in most it is implicit – embedded in the sequence of processes applied and their parameters. In model-based systems the knowledge being used can be seen outside of the code, perhaps as an equation, perhaps as a data structure.

A tool that detects humans in images might, for example, rely on a stick-figure representation of an idealised human body that is overlaid on the image as analysis proceeds. As key features in the model – maybe skin-coloured regions at the ends of the arms and neck – are matched to image features the model is parameterised.

When analysis begins the model captures the possible appearances of a human, but the specific features of the person shown in the image – e.g. the lengths of and current angles between their limbs – are unknown. When it is complete, the fully parameterised model reflects the image content, and describes an individual human.

Active contours / Snakes

In the model-based approach the model also directs analysis by restricting its parameters to sets of allowable values: e.g. identifying the position of a hand limits the number of image locations which might reasonably depict an elbow. The model used might be two -or three-dimensional, in which case the position and orientation of the model in space might be determined as well at its internal parameters.

Though there is a growing literature on the construction of 3D descriptions of plants, both from sensor data and via functional-structural modelling, their physical complexity means that 3D model-based approaches to plant image analysis are rare. Two-dimensional methods are more feasible at present, with the use of active contours, or “snakes”, perhaps the most common technology.

Active contours model the boundaries of objects by imposing constraints on the relative positions of points on those boundaries. They are often referred to as snakes because an early paper use the analogy of a snake trying to make itself comfortable while lying on a surface. Though the snake can bend to fit the ridges and troughs in the surface to some degree, its physicality means that not all configurations are possible. It cannot perform e.g. a 90 degree bend. Central to the active contour approach is the notion of an energy function. This scores the current configuration of a snake on a number of criteria, assigning it an energy. During image analysis the points on the contour are moved in an effort to minimise that energy and fit the snake to a boundary in the input image.

Energy functions comprise two major components, the internal and external energies. The internal energy term captures the physical properties of the snake. A common way of computing internal energy is to estimate curvature at each point and sum these estimates to provide a measure of the smoothness of the contour. Smoother (low curvature) contours are typically assigned lower energies. The external energy assesses the fit of the contour to the image. It might, for example, estimate the image gradient under each point and give low energies to snakes which lie on points with high gradient values.

The total energy is a weighted sum of these two terms:

[E_{total} = alpha E_{internal} + beta E_{external}]

In the example above the total energy defines a model which seeks smooth contours likely to mark sharp changes in the image, with the relative importance of each criterion determined by the balance between (alpha) and (beta). If (alpha) is high and (beta) low the snake will prefer smooth contours that do not fit so well to object boundaries. Setting (alpha) low and (beta) high will force the snake to fit more closely to the image data, to reduce the larger external energy term. It will do this at the expense of smoothness.
Energy minimisation is usually achieved by hill-climbing. The points making up the contour are randomly shifted by small amounts and (E_{total}) computed for each. The configuration with the lowest energy is selected and the process repeats either until (E_{total}) reaches an acceptable value or the process has been completed a fixed number of times. To force the contour to search more widely, it is common to add a third energy term:

[E_{total} = alpha E_{internal} + beta E_{external} + chi E_{constraint}]

This assigns low energy to contours with either closely or widely-spaced points and so, when other energies are low, causes the contour to either shrink or expand across the image. The figure below shows the result of shrinking a snake seeking a smooth, high image gradient contour onto a leaf. The blue line is the starting position, red lines show the contour position after every 100 hill climbing iterations, and the green the final contour achieved after 750 iterations.

The result of shrinking a snake seeking a smooth, high image gradient contour onto an image of a leaf. The blue line is the starting position (a square around the edge of the image), red lines show the contour position after every 100 hill climbing iterations (gradually getting closer to the leaf outline), and the green the final contour achieved after 750 iterations (a good fit to the leaf outline).

Other kinds of models

We have looked at shape models here, but it is common to use other models to help segment image data. For example, we can have a model of the image features we expect an object to be composed of – things like the expected colour, texture, etc. of an object. This kind of model doesn’t match the shape, but rather the look of an object.

In the following practical we will walk you through one of these approaches, which learns to find the features like colour and texture which describe an object using machine learning, and then uses this model to mark object regions in the image. You will notice that without a model of shape (versus with Snakes) the boundaries of segmented areas with such approaches can be more noisy, and you can get different regions of segmented areas throughout the image, rather than in one place.

So sometimes it may be more appropriate to use a shape model, sometimes a feature-based model, sometimes a combination of both.

This article is from the free online

Introduction to Image Analysis for Plant Phenotyping

Created by
FutureLearn - Learning For Life

Our purpose is to transform access to education.

We offer a diverse selection of courses from leading universities and cultural institutions from around the world. These are delivered one step at a time, and are accessible on mobile, tablet and desktop, so you can fit learning around your life.

We believe learning should be an enjoyable, social experience, so our courses offer the opportunity to discuss what you’re learning with others as you go, helping you make fresh discoveries and form new ideas.
You can unlock new opportunities with unlimited access to hundreds of online short courses for a year by subscribing to our Unlimited package. Build your knowledge with top universities and organisations.

Learn more about how FutureLearn is transforming access to education