View License

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

» Watch video

Highlights from
Sparse Field Methods for Active Contours

4.1 | 7 ratings Rate this file 25 Downloads (last 30 days) File Size: 50.8 KB File ID: #23847 Version: 1.2
image thumbnail

Sparse Field Methods for Active Contours


Shawn Lankton (view profile)


21 Apr 2009 (Updated )

Very fast implementation of level sets. 2D and 3D support, written in C++/MEX with MATLAB wrapper.

| Watch this File

File Information

Active contour methods for image segmentation allow a contour to deform iteratively to partition an image into regions. Active contours are often implemented with level set methods because of their power and versatility. The primary drawback of level set methods is that they are slow to compute. This code implements the very efficient sparse field method (SFM) proposed by Whitaker. Specifically, the well-known Chan-Vese energy is minimized.
To run the MATLAB demo, simply unzip the file and run:


at the MATLAB prompt. On the first run, this will compile the MEX code on your machine and then run the demo. If the MEX compile fails, please check your MEX setup. The demo is for a 2D image, but the codes work for 3D images as well.

My hope is that other researchers wishing to quickly implement Whitaker’s method can use this information to understand the intricacies of the algorithm and enjoy the same SUBSTANTIAL speed-ups I have.

For a full technical report detailing the algorithm and implementation, please check this post:

[ ]

Required Products Image Processing Toolbox
MATLAB release MATLAB 7.7 (R2008b)
MATLAB Search Path
Other requirements C++ compiler to compile MEX files.
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (12)
12 Oct 2016 wang

wang (view profile)

it seems that the code lack the definition of function fat_contour in 'visualize_phi'.

how is it definied?

11 Jul 2016 G. Sken

G. Sken (view profile)

is there any possibility to provide your code with a segmentation threshold ?
say I like to segment to 10 one gray volume/image like this :
[xx,yy,zz] = meshgrid(1:side,1:side,1:side);
c=[h_side h_side h_side];% centre in the midle
% calculate distance from center of the cube
rr = sqrt( (xx-c(1)).^2 + (yy-c(2)).^2 + (zz-c(3)).^2 ); % gray volume

22 Jun 2016 Lipeng Jiu

How can I implement this as 3D level set?

23 Apr 2014 Muhammad Syuqrat Firdaus Nasarudin

16 Apr 2013 Vincent Gigot

It does not seem to work on my Matlab version (R2012b).
Following error message that seems to comme from the compilation, I'va got the compiler toolbox :
"""Compiling sfm_chanvese_mex...
Error: Could not detect a compiler on local system
which can compile the specified input file(s)
Error using mex (line 206)
Unable to complete successfully.

Error in compile_sfm_chanvese (line 6)
mex sfm_chanvese_mex.cpp llist.cpp energy3c.cpp lsops3c.cpp

Error in sfm_chanvese (line 26)

Error in sfm_chanvese_demo (line 18)
[seg] = sfm_chanvese(img,mask,iterations,lambda);"""

Comment only
16 Jul 2012 Robert

Robert (view profile)

24 Jan 2012 Anusha

Anusha (view profile)

How can I implement this as 3D level set?

Comment only
24 Nov 2009 Alex Kararg

Could you please help on how I could use your algorithm with 3D images? I have the x,y,z coordinates of the points. I am kind of new to matlab.

Comment only
10 Jun 2009 Shawn Lankton

Shawn Lankton (view profile)

Thanks Sebastien. The bug is FIXED now.

Comment only
01 May 2009 Sebastien PARIS

Ok I found the bug. Please add "return newll;" in the end of ll_create() function ... Compile fine with Intel ICC right now (around 41% faster than MSVC for my laptop)

Please also compile with the -v option to verbose unused variables and remove them.

Comment only
30 Apr 2009 Sebastien PARIS

Works fine. Thank you. Do you plan to include "multiphase" version ?. One point Segmentation fault when compiled with Intel compiler, ok with LCC or MSVC ... I'll look inside when I'll have time ...

22 Apr 2009 Romeil Sandhu

This is excellent! Very nicely written, and easy to integrate with an already on-going project. It does what it says -- provides a fast implementation of level sets. Great job.

29 Apr 2009 1.1

Fixed bug in the prototype for ls_iteration()

10 Jun 2009 1.2

Fixed some bugs, and updated the demo script. Thanks to Sebastien Paris for pointing out a bug in the comments! FIXED.

31 Mar 2016 1.2

Added BSD License

Contact us