View License

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Highlights from
Active Contour Segmentation

4.4 | 18 ratings Rate this file 180 Downloads (last 30 days) File Size: 10.5 KB File ID: #19567 Version: 1.0
image thumbnail

Active Contour Segmentation


Shawn Lankton (view profile)


12 Apr 2008 (Updated )

Finds foreground and background regions using level sets and active contours.

| Watch this File

File Information

This code implements the well-known Chan-Vese segmentation algorithm from the paper "Active Contours Without Edges."
This technique deforms an initial curve so that it separates foreground from background based on the means of the two regions. The technique is very robust to initialization and gives very nice results when there is a difference between the foreground and background means.

This code uses active contours and level sets in the implementation. It could also serve as a good framework for implementing all kinds of region-based active contour energies.

1.) Download
2.) Unzip
3.) Run >>region_seg_demo

See this site for experiments, videos, and more information on segmentation, active contours, and level sets:

[ ]

MATLAB release MATLAB 7.4 (R2007a)
MATLAB Search Path
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (27)
08 Dec 2016 diw sun

thank you

29 Jun 2016 Shashank S


Thank you for this contribution.

20 Apr 2016 Harika Basamgari

15 Apr 2016 afshin shoeibi

04 Apr 2016 Dhivya

Dhivya (view profile)

01 Apr 2016 Dhivya

Dhivya (view profile)

Very helpful code..
How initialization of mask is done in active contours?
I tried the file with a different image and not getting proper output.. Should initialization of mask be done separately for different images?

Comment only
31 Mar 2016 ELI

ELI (view profile)

Thanks for your tool, works grate.
one important bug - it's needed to add "abs" in line 60:

dt = .45/(max(abs(dphidt))+eps);

Comment only
31 Mar 2016 ELI

ELI (view profile)


send to me

Comment only
14 Dec 2013 vaishali

09 Dec 2013 vaishali

how to specify re-initialization in this code?

Comment only
13 Nov 2012 Nam

Nam (view profile)

20 Oct 2012 Irina

Irina (view profile)

hello, may be do you know algorithm that find edges of region by given one point inside the region in ultrosound image? and may be do you have the matlab code for it? thank you

Comment only
10 May 2011 Chaitanya Kumar

Sir it is easy to segment images with clear background, but when i am trying for MRI images of Prostate or brain, then the segmentation is not upto the mark, i have tried changing certain parameters of your code, but failed to achieve perfection. please advise me how can i segment the MRI images using this technique..

Comment only
01 Feb 2011 sahil dhawan

I have taken a snapshot using my laptop camera which is a 3D image but this code works only with 2D image.
How to proceed plz help!
reply asap!

Comment only
05 Aug 2010 Tong Kuan Chuah

It is a useful and fast program. I'm studying the coding of the version of region_seg.m modified on 14th Apr 2008 and hope to develop upon the code e.g. (incorporate termination criterion, use for other variation of snakes). Could you provide some insight regarding several questions listed here?

1. Problem anticipated: the program will have trouble when original image is double RGB. => all pixels become zero because of uint8(img).
Lines 140 to 143 seems not necessary.

2. Line 99, why change the level to 0.5 higher at interior of the contour, 0.5 lower at exterior of the contour?

3. Why +eps at line 51 when the values are the same without eps?

4. Line 124, for central difference of first derivative, is there a missing factor of 0.5 for the whole term? Won't this cause inconsistency in the spatial steps?

5. Line 134, why is there an additional factor (phi_x2 + phi_y2).^(1/2) for curvature (curvature formula I obtained is without this factor)?

6. How is line 60 obtained, which uses different time step each iteration?

7. Time step 0.5 for re-initialization (line 66) seems to be arbitrarily chosen. What is the bound this value can be varied within stable condition?

Thank you for your attention. Your insight is greatly appreciated!

Comment only
04 May 2010 waqar ahmed

very help ful code...thnx

07 Apr 2010 Nitin

Nitin (view profile)

28 Mar 2010 Nitin

Nitin (view profile)

03 Nov 2009 Ben

Ben (view profile)

07 Mar 2009 Jun.C ù

15 Oct 2008 Mona Elshinawy

15 Oct 2008 Mona Elshinawy

I tried the code on mammograms and it was working but the 250 iterations were not enough at all to get the breast contour, I was trying to figure out what to change in your code to have larger steps for each iteration. I use very large images(ex.4069x2084).Your cooperation is greatly appreciated

Comment only
01 Aug 2008 Puteri Sulaiman

thank you, really helps a lot with my project.. been to your web site, also really usefull.. :)

27 May 2008 wang mian

hi,profess,when I run it,it says:"Error in ==> region_seg at 70
showCurveAndPhi(I,phi,its); ",
I don't know how to deal it.Could you tell me how should I do next please.
Thank you very much!!

14 Apr 2008 James Malcolm

Great self-contained demo. It runs right out of the box, and is very fast.

15 Apr 2008

Fixed mlint errors, streamlined code, added more help, corrected typos.

31 Mar 2016 1.0

Adding BSD Licence

Contact us