File Exchange

image thumbnail

Chan Vese Active Contours without edges

version 1.0 (964 KB) by

Mainly implement three Chan Vese active contour ideas.

18 Ratings



View License

Implement following papers:
1. Chan, T. F., & Vese, L. A. (2001). Active contours without edges. IEEE Transactions on Image Processing, 10(2), 266‐277.
2. Chan, T.F., & Sandberg Y. B(2000). Active contours without edges for Vector‐valued Image. Journal of Visual Communication and Image Representation 11, 130–141 (2000)
3. Chan, T. F., & Vese, L. A. (2002). A Multiphase level set framework for image segmentation using the Mumford and Shah model. International Journal of Computer Vision 50(3), 271–293, (2002)
Detailed HELP file
Teach you how to play with codes and what are functions for each file.
Introduction to CV methods online
Demo video on Youtube

Comments and Ratings (26)

masyitah razi

Just downloaded it, well done. Still some bugs to fix (at least in my Ubuntu machine): 1- Change the demo file name to be one word demochenvese.m
2- Change the image name 4colors.JPG to be 4colors.jpg
please somone correct me if I am wrong. I understood that CV energy or force is a combined of an external force comes from the input image "I" and an internal force comes from the boundary (here it is represented implicitly by the level set function Phi):
F_CV= F_int + F_ext where,
F_int= w1 * Dirac(Phi)+ w2 * Heaviside(Phi)
F_ext= w3 * |I-C1|^2 + |I-C2|^2 where C1 and C2 are the average intensities inside and outside the boundary. w1,w2,w3 and w4 are weights.
In this implementation, I think there is something wrong about the internal force as it has no effect at all. I changed this line:
              %force = mu*kappa(phi0)./max(max(abs(kappa(phi0))))+1/layer.*force_image;

to be:
              force = force_image;

and still get the same result (tried it with different images).
I appreciate your input.


LE SUN (view profile)

Dipesh Gupta

Hi Yue,

Really Thankful for such pretty code !!

i am using your algorithm to find out the sclera, but i want to give 2 initial seed Points from where the contour grow as i have already find out the centre of IRIS location.
first seed Point
Crs(x, y) = (x0 + (1.35 × r), y0)
Second Seed Point
Cls(x, y) = (x0 − (1.35 × r), y0)

r=radius of iris.
x0,y0=Position of centre of Iris.

How can i do this ??

Please look at my Matlab code Once & Suggest.

Yassine RHAZ

thank you for sharing this work it's very helpful

Donny Sun

Thank you for the code, I found it help in my research.

Eloy Roura

Thank you for the code, this is an awesome tool for the level set segmentation method.

However, I would like to ask you some questions about its performance. I'm testing the code, and I'm still wondering whether the effect of the curvature is significant... it ranges btw [-1,1], once normalized. Then it is multiplied by mu, and finally the force_image is added, which its min and max values are 4 orders of magnitude higher... Any feedback on that would be very useful :)

has anybody worked out multiphase version of this method yet ?

Yanhai Ren

I'm not sure if you still can reply me or not. But I have some confusions about the code: while you calculating the curvature, the G term is multiplied by K. I don't understand why there exists the term G for curvature. If you are using G to replace dirac delt function as in reference[27] mentioned in paper"active contours without edge", why don't you multiply the other force terms by G ?


Egemen (view profile)

Does this calculate contours with sub-pixel level accuracy? Also, how can I extract the co-ordinates of detected contours?


Toan (view profile)

atefeh gh

I am a beginner matlab.
I cant run this cod
my error is "demo not found"
can you help me?



very good code, thanks a lot


Weiguang Ding


sjtu (view profile)

Thanks a lot for your work. The help file is really helpful for me to understand your code. Nevertheless, I could not understand the content and function of the maskcircle2.m, could your explain a little more about it to me?

Kwstas Tranos


Nitin (view profile)

ali reza

very good and beatiful implementation. I addition do not lose the website of authur

Jan Bergeest

Hi, thank you for making this helpful code available. I have two questions regarding the multiphase level set implementation.
Why do you use the Heaviside of phi2 in your code line
In the paper, for the computation of dPhi/dt only H(phi1) is used. Is it related to the fact that you omit the Dirac delta function? Or is it a different numerical solution for the equation since in the paper a numerical scheme using constants C1 to C4 ... is proposed?
Thanks a lot in advance

JIhan zoghbi

Thanks for this implementation, it helps me a lot understanding the chan-vez method. I don't understand some parts of the code:
1- In the file check-stop I don't undestand this condition "if Q<=dt*.18^2", why you choose "dt*.18^2". What is the condition to stop the iterations?
Thsnks a lot

JIhan zoghbi

Yue Wu

Yue Wu (view profile)

1. for question 1, I re-looked the code, you are right "im2double" that term should be omit.

2. the reason why I do normalization for both kappa term and image force term is I want to make sure that these two terms are always comparable, in other word, I do not want one of them dominate the minimization problem.

3. for me, this is OK. My understanding is: we distinguish background and foreground by their sign. I am pretty sure that even if you change my code for phi to the defnition you mentioned, you will still get the same answer.

Hello, I was checking the code and a few things are not clear for me.
1. When you are calculating the distance function, what is the reason of adding this "im2double(mask)" to 'phi0'?

2. In the calculation of the divergence and the force there is always a normalization.I couldn't exactly get the reason for that. Can't this be fixed by changing the coefficient 'mu'?

3. I think in the paper 'Active contours without edges' the normal direction is different than the implementation here. The paper states that when phi>0 we are inside the curve but in the implementation when phi>0 we are actually outside the curve C.

Thanks a lot.

MATLAB Release
MATLAB 7.6 (R2008a)

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

» Watch video