Chris Bregler and Malcolm Slaney, "Snakes-A MatLab MEX file to demonstrate snake contour-following," Interval Technical Report #1995-017, 1995.
The code in this report computes one iteration of the energy-minimization of active contour models described in the paper "Using Dynamic Programmingfor Solving Variational Problems in Vision" by Amir A. Amini, Terry E. Weymouth, and Ramesh C. Jain, IEEE Transactions on Pattern Analysis and Machine Intelligence, Vol. 12, No. 9, September 1990, pp 855-867.
Snakes align a contour to some feature maxima in an image (for example) image boundaries) using dynamic programming. The quality of the alignment is measured by an energy function consisting of an internal "contour-smoothness-term" and an external feature term (equation 50 in the paper). Minimizing this energy term leads to a contour that trade offs these two criterias (smoothness + maximal feature responses) in some desired way.
A graphical demonstration program (in Matlab) is included.