Code covered by the BSD License  

Highlights from
Snake : Active Contour

4.5

4.5 | 18 ratings Rate this file 280 Downloads (last 30 days) File Size: 40.9 KB File ID: #28149
image thumbnail

Snake : Active Contour

by

 

08 Jul 2010 (Updated )

Snake Segmentation (Kass et al), 2D/3D including GVF and balloon force (Easy to read code)

| Watch this File

File Information
Description

These functions implements the basic snake segmentation contour, as introduced by Kass et al.

Algorithm:
A snake is an active (moving) contour, in which the points are attracted by edges and other image boundaries. To keep the contour smooth, a membrane and thin plate energy is used as contour regularization.

Implementation:
All code is well commented, and is probably easy readable. It includes,
- A balloon force, which is not in the original paper
- Binary image segmentation result,
- The "Gradient Vector Flow" (GVF) method.
- 3D implementation, including parameter to keep the mesh from self-intersecting

Try the example in the help of function Snake.m !

Literature:
- Michael Kass, Andrew Witkin and Demetri TerzoPoulos "Snakes Active Contour Models", 1987
- Jim Invins and John Porril, "Everything you always wanted to know about snakes (but were afraid to ask)
- Chenyang Xu and Jerry L. Prince, "Gradient Vector Flow: A New external force for Snakes
- Christoph Lurig, Leif Kobbelt, Thomas Ertl, "Hierachical solutions for the Deformable Surface Problem in Visualization"

Please report bugs, successes and other comments

Required Products Image Processing Toolbox
MATLAB release MATLAB 7.10 (R2010a)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (36)
30 Aug 2014 rain6304

How do I implement the function in MATLAB? I am just beginning to use MATLAB and need some help! Thanks!

14 Jul 2014 Christian

Great to learn how the snake works and how the parameter influence the result! Thank you very much!

15 May 2014 Chris

Hi, I am trying to run Snake3D but keep getting the following error:
"Maximum recursion limit of 500 reached. Use set(0,'RecursionLimit',N)
to change the limit. Be aware that exceeding your available stack space can
crash MATLAB and/or your computer.

Error in Snake3D"

Does anyone know how to fix this?

24 Mar 2014 IDRIS AHMED  
12 Feb 2014 Y Simson

Signal Processing ToolBox is required for the interp() function in K=InterpolateContourPoints2D(P,nPoints)

19 Aug 2013 Samuel Pedro

I don't understand how you calculate the internal force in 3d model. And I can't find a reference that supports your calculation. Can you help me?

06 May 2013 narjes

Hi, i try to use this code but i have a problem with "interp1 "

# ??? In an assignment A(:,matrix) = B, the number of elements in the subscript of A and the number
of columns in B must be the same.

Error in ==> C:\MATLAB6p5\work\InterpolateContourPoints2D.m
On line 40 ==> K(:,1) = interp1(dis,O(:,1),linspace(0,dis(end),nPoints*2));#

can you help me please !!!!!!

28 Mar 2013 Ahmed

i am try to work on active contour, but i fail although i tried different models of snake in MATLAB such as:
1-snake2D().m
2-snake().m
3-ac_segmentation().m
4-snakedeform().m

but unfortunately neither one of these methods is worked with me

please i want someone who have good experience in using it to help me how to use it.
Note:i am working on segmentation of medical H&E stains images and i need strongly to use snake to segment the nuclei(foreground) from background.

28 Mar 2013 Ahmed

i am try to work on active contour, but i fail although i tried different models of snake in MATLAB such as:
1-snake2D().m
2-snake().m
3-ac_segmentation().m
4-snakedeform().m

but unfortunately neither one of these methods is worked with me

please i want someone who have good experience in using it to help me how to use it.
Note:i am working on segmentation of medical H&E stains images and i need strongly to use snake to segment the nuclei(foreground) from background.

28 Mar 2013 Teresa

Hi,
I also have a problem with the interp error and don't know how to get rid of it. I tried interp2, interp, interpn. I think interp2 works but then I get an error in
K(:,1) = interp2(dis,O(:,1),linspace(0,dis(end),nPoints*2));
K(:,2) = interp2(dis,O(:,2),linspace(0,dis(end),nPoints*2));

Does anyone find a solution and can help me?

15 Mar 2013 Ahmed  
05 Dec 2012 Inge Schie  
27 Oct 2012 Agnes

Hi,

For the issue, perhaps you should try with

O(:,1)=interp([P(end-3:end,1);P(:,1);P(1:4,1)]',10)';
O(:,2)=interp([P(end-3:end,1);P(:,2);P(1:4,2)]',10)';
O=O(41:end-39,:);

Because I don't have any issue with it.
Thanks for the great work.

23 Jul 2012 Felix

Does somebody figure out how to get rid of the interp error?
I tried interpn and interp2 but was not able to get the code running.
Can somebody help me?

Error is in
InterpolateContourPoints2D

O(:,1)=interp2([P(end-3:end,1);P(:,1);P(:,1);P(1:4,1)],10);
O(:,2)=interp2([P(end-3:end,2);P(:,2);P(:,2);P(1:4,2)],10);

I tried to run the basic Example of the Snake2D but encountered this Problem with interp function

28 Jun 2012 Dmitry Sorokin

Hi.

Found a bug in InterpolateContourPoints2D possibly caused by using 'interp' function.

I think incorrect work of this basis function might lead to wrong functionality of the whole Shakes algorithm.

I can send you the example via email.

28 Jun 2012 nebi

Hi. what is the (P, Options) parameters for snake input. could you explain those. thanks

25 Jun 2012 Lacey

Great work, and thanks for commenting so well! I'm looking to use your code, or something like it, to extract a face from the background of an image. Is there a way to use your code to train a model using a small number of training images, so the model can then be used on other images? I'd like to not have to manually click the points on the image every time. Any help would be appreciated! Thanks!

07 Jun 2012 lili liliad

Hi,

I'm a MS student doing study of segmentation with param├ętric snake, i search the information of Multi-Target Parametric Active Contours
Would you please help me to get those infomations?
Thank you very much.

10 May 2012 Joy King

It's excellent. Thank you very much.

02 May 2012 Qasim ul-haque

??? Error: File: Snake2D.m Line: 1 Column: 24
Unexpected MATLAB expression.

??? Maximum recursion limit of 500 reached. Use set(0,'RecursionLimit',N)
to change the limit. Be aware that exceeding your available stack space can
crash MATLAB and/or your computer.

Error in ==> imformats>find_in_registry

i am getting this error.Help?

01 Mar 2012 Walid

the code does not find interp

20 Jan 2012 arron lacey

Can the GVF field be altered to create a magnetic field?

19 Nov 2011 subrajeet  
12 Oct 2011 KYAW KYAW

Dear Dirk,

I am newbie in ultrasound imaging even i had few experiences in image processing and analysis other programming languages.

Currently, I am looking for a boundary detection of noisy ultrasound images but I couldn't manage to find the right one until now.I tried out using your code but the problem is still there and please advise me.

Thanks and best regards

17 Jul 2011 Jack

Hi,
Thank you very much for your great job! It is very usefull for my master thesis, but I would like to ask some questions about your toolbox.

1) If I try your example in Snake3D, the 3D Model (SphereMesh) is growing up to the out of boundary. How could it be corrected?

2) Should this 3D Model always a increasing deformable model or could it be shrinking model too?

3)Is this parameter "Delta" for baloon force always necesarry for GVF?

4)I couldnt find the parameter "Kappa" in the papers in the Literature. Could you please put the paper which contains an equation with "Kappa"?

Thanks in advance

29 Jun 2011 Dirk-Jan Kroon

*Dan, the snake.m file is renamed to Snake2D.m in this version.

12 Apr 2011 Dan

I agree with Terrence.
Where is the snake.m file?

31 Mar 2011 Marcos Belmonte

Thanks very much, I'll try it

16 Mar 2011 Dirk-Jan Kroon

*Marcos Belmonte
The Triangulated Patch FV, can be constructed with the "isosurface function" on a (logical) 3D volume of a rough segmentation of your object.

14 Mar 2011 Marcos Belmonte

Hi, congratulations on your work. I'm in a similar situation than Hsien-Chi Kuo. I want to segment more or less spherical objects in 3D but I don't know how to generate "FV". Is it necessary to build a trianguled mesh, can't it be spherical?
Thanks very much.

15 Dec 2010 Hsien-Chi Kuo

Hi,

I'm a MS student doing tumor segmentation on 3D images.
Would you please tell me how to generate "FV" for snake3D?
Thank you very much.

23 Nov 2010 too ym

Hi,

% Interpolate points inbetween
O(:,1)=interp([P(end-3:end,1);P(:,1);P(:,1);P(1:4,1)],10);
O(:,2)=interp([P(end-3:end,1);P(:,2);P(:,2);P(1:4,2)],10);

In function InterpolateContourPoints2D, is it the 1 in O(:,2) should be write as 2.

O(:,2)=interp([P(end-3:end,2);P(:,2);P(:,2);P(1:4,2)],10);

Correct me if i am wrong and thank you for your great job.

12 Nov 2010 Yuanming Suo

Great tool. Well documented. Good for use to understand parametric deformable model.

14 Oct 2010 Vivek

Hi,
i'm Vivek, doing my masters project in BioMedical image processing,
i need to use the snake for analyzing and predicting the growth of cancer tumors, could you please let me know, how to run this illustrated example in Matlab 7.8.0 R2009?

mail me your suggestion, to
vivek.acm@gmail.com

17 Sep 2010 David

well done, easy to read and understand.

28 Jul 2010 terrence pong

where can i find the snake.m file to start?

Updates
08 Jul 2010

Added GVF. Changed some minor comment

12 Jul 2010

Also added a 3D implementation. Change line image force, to Gaussian smoothed line image force.

13 Jul 2010

Added parameter to keep the mesh from self-intersecting

27 Jul 2010

Solved 3D GVF bug, and increased 3D speed.

11 Nov 2010

Yuanming Suo reported bugs in scaling of 3D Gaussian and Mu*4. Which are corrected in this version.

24 Jan 2011

Small, Interpolate Bug Fix

08 Nov 2011

3D snake now uses the inverse internal forces matrix

Contact us