Active Contours (Snakes)

A demonstration using Java

Active contours, also called snakes, adapt to edges in an image. Instructions are given below the applet.

Your web browser either does not support Java applets, or you have Java support turned off in your browser. You will need to have a Java-capable browser with Java enabled to see this demonstration. Thank you for your interest.


To initialize a contour, click on the image and drag to form an oval. Releasing the mouse button stamps the contour in red on the image, and the points that are used in the contour are shown in green. Press any key on your keyboard to move the contour (snake) one iteration. Holding any button down will repeatedly iterate the snake. Pressing the 'return' key will iterate the snake 100 iterations. When the snake reaches steady state and no more points are moved on an iteration, the points turn yellow and the program no longer refreshes the contour. The three parameters above the image (continuity, curvature, and gradient) can be changed from zero to 'very high'. Each of these affects the behavior of the snake in a particular way. After changing one or more of the parameters, the contour is reset to the initial oval when the mouse pointer is moved back onto the image. The contour may then once again be iterated using the new parameters by pressing any key on the keyboard. This allows you to see the effect of changing the parameters using the same initial contour. Note that it is the values of these weights relative to each other that is important; setting all three values to "High" will give exactly the same results as setting them all "Low".

The snake will be more likely to be attracted to the cell boundaries if you draw the initial contour outside the cell. This is because the interiors of the cells are noisy and therefore the image gradient does not attract the snake as strongly toward the cell boundaries as it does when the snake is initialized outside the cells.


Contours are initialized with a distance between adjacent snake points ('snaxels') of approximately 3 pixels. Each snaxel moves under the influence of internal and external constraints:

An internal constraint that specifies that a snaxel should locate itself so as to make the distance between itself and its neighbors close to the average distance between snaxels. This version of the continuity constraint tends to cause the snake to shrink.
An internal constraint that specifies that a snaxel should locate itself so as to minimize the amount of curvature it introduces; that is, it should maximize the angle it defines between its neighbors.
An external constraint that specifies that a snaxel should locate itself in areas where the gradient in the image is large. The Sobel gradient is used in this example.

Several other internal and external constraints may be defined for snakes, but only these three have been implemented in this example. The numerical weights used for these three parameters corresponding to the descriptions are:

Very High2.02.02.4

See also:


  1. M. Kass, A. Witkin, and D. Terzopoulos, "Snakes: Active contour models." International Journal of Computer Vision. v. 1, n. 4, pp. 321-331, 1987.
  2. D.J. Williams, D.J. and M. Shah, "A fast algorithm for active contours." CVGIP: Image Understanding. v. 55, n. 1, pp. 14-26, 1990.
  3. F. Leymarie and M.D. Levine, "Tracking deformable objects in the plane using an active contour model." IEEE Transactions on Pattern Analysis and Machine Intelligence. v. 15, n. 6, pp. 617-634, 1993.
  4. K.-M. Lam and H. Yan, "Fast greedy algorithm for active contours." Electronics Letters. v. 30, n. 1, pp. 21-23, 1994.
  5. K.R. Castleman, T.P. Riopka, and Q. Wu, "FISH image analysis." IEEE Engineering in Medicine and Biology. v. 15, n. 1, pp. 67-75, 1996.

Mark A. Schulze

Last updated: 23 July 2003
Page created: 26 November 1996
Code last modified: 23 July 2003
Copyright © 1996-2003 by Mark A. Schulze. All Rights Reserved.