File Exchange

image thumbnail

level set for image segmentation

version (1.82 MB) by Chunming Li
This Matlab code implements an edge based geometric active contour model without reinitialization.


Updated 03 Jun 2013

View License

This Matlab code implements a new level set formulation, called distance regularized level set evolution (DRLSE), proposed by Chunming Li et al's in the paper "Distance Regularized Level Set Evolution and its Application to Image Segmentation", IEEE Trans. Image Processing, vol. 19 (12), 2010

The main advantages of DRLSE over conventional level set formulations include the following: 1) it completely eliminates the need for dreinitialization; 2) it allows the use of large time steps to significantly speed up curve evolution, while ensuring numerical accuracy; 3) Very easy to implement and computationally more efficient than conventional level set formulations.

This package only implements an edge-based active contour model as one application of DRLSE. More applications of DRLSE can be found in other published papers in the following website:

Cite As

Chunming Li (2020). level set for image segmentation (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (56)


Duy Nguyen


very good


built in function trows erros just wiht initial values ... not even changing a single line. That't is not good. Don't waste your time here, build you own.


Dear i am working on Radial Basis Functions used in image segmentation, any have Matlab code about it.

I am a beginner for this ,I want a code for level segmentation using bone crack detection

Nick Tsui

Ander Biguri

Jasmine Tan

I'm currently testing on my dermatologist images (.jpg dimension=510x400) for my project.
However, the iterations always start at the upper left corner.
May I know any possible solution to solve it??
How can I modify the code so that it can start iterate from the whole image and converge to its ROI? Thank you.

Jun Ho Song

Chun-Yu Lin

sudha r


ya fa

Thanks a lot, I have used that code with a little changes and it is really amazing. but I have number of images and it works fine with some and not with other. any idea to make it more flexible.......

my project to segment images in skin cancer


Smith Adam

diw sun

Thank trying image segmentation

I am trying to segment the tumor in my MRI image.It is not segmenting the actual region.Can you please help me with this?My email id is

yue zhao

Excellent! Very robust and accurate, the code is simple and easy to use!


Great job!

Ligong Han


Hi! i ues this code for cardic T2 W CMR IMAGES,the target is to detect the contours of LEFT VENTRICLE but i am fail can any one help me in this stage. thanks
My EMAIL address:

I tried to use this code for my microscope images but I failed. Segmentation starts in a little region upper left corner and code cant reach all region.

abhilash B

please give us the link/code to calculate the mean error that you have used in the paper

Xidian NO.1



hi,i tried to use this code but i always get error code :
??? Error using ==> contours
Too many input arguments.

Error in ==> C:\MATLAB6p5\toolbox\matlab\specgraph\contour3.m
On line 80 ==> [c,msg] = contours(varargin{1:nin});

Error in ==> C:\MATLAB6p5\toolbox\matlab\specgraph\contour.m
On line 62 ==> [c,h,msg] = contour3(varargin{:});

Error in ==> C:\MATLAB6p5\work\level.m
On line 51 ==> contour(phi, [0,0], 'r','LineWidth',2);title('Initial level set function');
can someone help me please?


well good

Su Dongcai


thanks for your help






thanks..good work :)

thanks for ur help :)

Ankit Goyal




thanks your help.


I tried lip segmentation with this but the results are not veyr satifactory. Any suggestions as to what other algorithms can be used?


fido genial

Excellent job

Thank you. This code is very easy to use and performance is very good. This one is helpful for me.

John Smith

It does not work on realistic images, I used examples from Columbia University Image Library

shifang xu

Thank you for sharing!
Maybe there is a little bug at line 36 in Demo1_ManualBinaryInitial.m.
??? Error using ==> -
Function '-' not defined for variables of class 'uint8'.

Error in ==> E:\?????\????? ROI\Segment_1\LevelSet_ChunmingLi_v0\Demo1_ManualBinaryInitial.m
On line 36 ==> initialLSF= c0*2*(0.5-BW); % initial level set function: -c0 inside R, c0 outside R;

It can be fixed by changing BW to double(BW).

Adam W

Thank you. It was very easy to get it to work on my computer.

Ping Xiang

Good job. I have downloaded and try to modify and use it in my research.

Ronfard Guallrier

Hi, Chunmingli, thank you for your programe, I have downloaded it. I also have visited your homepage, I found your CVPR07 paper is excellet. And, your code is awsome! But it is DLL file. Chunming, can you also uploade your source code for LBF? I am waiting for your reply...

chiwister john

Excellent! I found his new work LBF is even better. It is insensitve to initlizations. His code can be downloaded from

alex z


miso yong

hmm do u use snakes to perform the energy forces? i need it because i need to track the lip movement for my project..if u did can you share your work with me?

reza goli

Hi Chunming,
Thanks for your nice program. I only have one question?
Do you use normal and curvature forces in your implementation too, like the usual level set method?
Thanks again and waiting for your reply.


Florian Jousset

jianfei ge

Very good,thank you!

Dan Hakim

very nice algorithem

Y zz

chenyu ke

Jeff Jiang

Nice work!


change "VIEW" as "view" in demo1 and demo2 for newer version of Matlab

Upgrade the old method to a new one proposed by the same authors in a recently published paper.

Added a note about an improvement of this method in the description.

This level set method has been improved by Chunming Li in a recent paper, which can be download in his homepage in the following link:


add some comments in the code



correct some typo

This new version allows user to specify initial contour/region manually.

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