File Exchange

image thumbnail

Snake Algorithm

version 1.0 (226 KB) by Iman
The goal is to find a contour that best approximates the perimeter of an object.


Updated 10 Feb 2016

View License

Editor's Note: This file was selected as MATLAB Central Pick of the Week

Snakes, or active contours, are curves defined within an image domain that can move under the influence of internal forces coming from within the curve itself and external forces computed from the image data. The goal is to find a contour that best approximates the perimeter of an object. It is helpful to visualize it as a rubber band of arbitrary shape that is capable of deforming during time, trying to get as close as possible to the target contour.
Please see the attached document "overview.pdf" to understand the underlying equations and algorithm used to develop this toolbox.
Please visit the following link to see an example:

Cite As

Iman (2021). Snake Algorithm (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (19)

Mehmet Turkes

saeid ghazanfari

yutong zheng

mughees ahmed


Please refer to the "Overview" document included in the package.

Mads Kristensen

Can anyone tell or explain what type of energy minimization is used?

Rahmat Ullah

Dear Iman,
Please send me the package on


just emailed it to you ;)


zip file does not work could you please send me the package to

Hamidreza Dehghan

hi, the link od download dose not work, would you please send me the package

juan ochoa gabiria

Deepak Rout

Sandra Arias

mohamad almasi


Hey Chandita. Thank you for your interest in my toolbox. The algorithm is explained in the "Overview" document. The code is not well-commented, but the names for variables and functions are very clear. If you grasp the math behind Snake, you would probably understand the code quickly. Sorry, I wish I had time to add comments to the code. Life is hectic! Best of luck.

Can you please explain in details about the source code of GUI.

Pasha Mahmoudzadeh


Hi Ibraheem, thanks for your positive and constructive feedback. I just replaced buttons'tags with appropriate self-explanatory names. Sorry for the confusion. I will add comments to the code asap.

Ibraheem Al-Dhamari

simple with nice explanation. I suggest you change the objects names e.g. buttons to have a meaningful names and put some helpful comments within your code.

MATLAB Release Compatibility
Created with R12
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!