4.71429

4.7 | 7 ratings Rate this file 431 downloads (last 30 days) File Size: 3.23 MB File ID: #24998

2D/3D image segmentation toolbox

by Yan Zhang

 

11 Aug 2009 (Updated 03 Sep 2009)

Code covered by BSD License  

2D/3D image segmentation using level-set based active contour/surface with AOS scheme

Download Now | Watch this File

File Information
Description

 Features of the toolbox:
(1) The toolbox includes classic level-set methods such as geodesic active contours (GAC), Chan-Vese model and a hybrid model combining the boundary and regional terms.
(2) All the methods are implemented with the semi-implicit solver AOS which can guarantee the stability of the numerical methods even with very large time steps, thus boosting the efficiency for level-set based segmentation.
(3) All the methods can be applied to 2D and 3D data.

Required Products Image Processing Toolbox
MATLAB release MATLAB 7.2 (R2006a)
Zip File Content  
Other Files AOSLevelsetSegmentationToolboxM.rar,
license.txt
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (22)
13 Aug 2009 jichao zhao

It seems quite cool, but when I compiled mex, and I met some errors. Do not know how to fix it.

14 Aug 2009 Sebastien Paris

Works fine.

14 Aug 2009 Yan Zhang

Hi Jichao, can you tell me which compiler you are using and provide more information about the errors?

14 Aug 2009 Jackson Shen

Exellent Work. *****

18 Aug 2009 jichao zhao

Hi, Zhang Yan. Yes when I used compile_mex_codes to compile, I met the following errors:

BinaryHeap.h: In member function 'void CBinaryHeapMinSort<IndexType, WeightType>::Insert(IndexType, WeightType) [with IndexType = int, WeightType = double]':
ac_distance_transform_3d.cpp:25: instantiated from 'void DistanceTransform3D(const InputType*, OutputType*, const int*) [with InputType = unsigned char, OutputType = double]'
ac_distance_transform_3d.cpp:106: instantiated from here
BinaryHeap.h:50: error: no matching function for call to 'std::exception::exception(const char [30])'
/usr/include/c++/4.2/exception:59: note: candidates are: std::exception::exception()
/usr/include/c++/4.2/exception:57: note: std::exception::exception(const std::exception&)

    mex: compile of 'ac_distance_transform_3d.cpp' failed.

Thanks for any hint so that I can fix it and use your package, cheers, jichao

19 Aug 2009 Yan Zhang

Hi, Jichao. To fix the problem:
(1) Open BinaryHeap.h in the "mex" folder
(2) Locate "std::exception" in the file
(3) Get rid of the string "CFastMarching: Heap overflow!" (It works fine for MSVC, but for GCC std::exception class doesn't accept argument for its constructor.)
(4) Run compile_all_codes.m.

Please don't hesitate to contact me if there are any further questions.

19 Aug 2009 Ahmed

i downloaded the pre-compiled version and it worked, the thing is the documentation is not enough for me and i don't quite understand the different variables used and the inputs too

26 Aug 2009 Ning

Hi Yan, i am new to the mex feature, could you tell me how to install your toolbox?
Thx!

27 Aug 2009 Yan Zhang

Hi, Ning. Please read the 'readme.txt' file in the package, all the essential messages are there. Basically, (1) unzip the package and open matlab (2) in the matlab environment, go to the 'mex' folder and run 'compile_mex_codes', all the mex files will be automatically compiled and moved to the right directory. If this is your first time using the mex function, make sure to use 'mex -setup' command in the matlab command window to select an appropriate c++ compiler (MSVC, GCC or whatever).

28 Aug 2009 Ning

Hi Yan,thx for the quick reply. I followed the instruction, but when i tried to run the compile_mex_codes, it can not get through, i attached the msg it gave out, could you tell me how to solve this? Thx again.

 lcc preprocessor warning: ac_tridiagonal_Thomas_dll.cpp:95 No newline at end of file
Error ac_tridiagonal_Thomas_dll.cpp: 7 syntax error; found `unsigned' expecting `;'
Error ac_tridiagonal_Thomas_dll.cpp: 7 syntax error; found `unsigned' expecting `;'
Error ac_tridiagonal_Thomas_dll.cpp: 7 syntax error; found `unsigned' expecting `)'
Error ac_tridiagonal_Thomas_dll.cpp: 7 skipping `unsigned' `long' `int'
Error ac_tridiagonal_Thomas_dll.cpp: 7 undeclared identifier `i'
Warning ac_tridiagonal_Thomas_dll.cpp: 7 Statement has no effect
Warning ac_tridiagonal_Thomas_dll.cpp: 7 unreachable code
Error ac_tridiagonal_Thomas_dll.cpp: 7 syntax error; found `)' expecting `;'
Error ac_tridiagonal_Thomas_dll.cpp: 7 illegal statement termination
Error ac_tridiagonal_Thomas_dll.cpp: 7 skipping `)'
Error ac_tridiagonal_Thomas_dll.cpp: 19 undeclared identifier `new'
Error ac_tridiagonal_Thomas_dll.cpp: 19 operands of = have illegal types `pointer to double' and `int'
Warning ac_tridiagonal_Thomas_dll.cpp: 19 possible usage of new before definition
Error ac_tridiagonal_Thomas_dll.cpp: 19 syntax error; found `double' expecting `;'
Error ac_tridiagonal_Thomas_dll.cpp: 19 integer expression must be constant
Error ac_tridiagonal_Thomas_dll.cpp: 19 missing identifier
Error ac_tridiagonal_Thomas_dll.cpp: 51 undeclared identifier `delete'
Error ac_tridiagonal_Thomas_dll.cpp: 51 illegal expression
Error ac_tridiagonal_Thomas_dll.cpp: 51 syntax error; found `yy' expecting `]'
Error ac_tridiagonal_Thomas_dll.cpp: 51 type error: pointer expected
Warning ac_tridiagonal_Thomas_dll.cpp: 51 Statement has no effect
Error ac_tridiagonal_Thomas_dll.cpp: 51 syntax error; found `yy' expecting `;'
Warning ac_tridiagonal_Thomas_dll.cpp: 51 Statement has no effect
Warning ac_tridiagonal_Thomas_dll.cpp: 51 possible usage of delete before definition
Error ac_tridiagonal_Thomas_dll.cpp: 71 illegal statement termination
Error ac_tridiagonal_Thomas_dll.cpp: 71 skipping `double'
Error ac_tridiagonal_Thomas_dll.cpp: 71 too many errors
 
  C:\PROGRAM FILES\MATLAB\R2006A\BIN\MEX.PL: Error: Compile of 'ac_tridiagonal_Thomas_dll.cpp' failed.

28 Aug 2009 Yan Zhang

Hi, Ning. Can you tell me which compiler are you using? It looks to me that the compiler doesn't support C++ (can't recognize keywords 'new', 'delete' and operator overloads). If you are using gcc, make sure link to the standard c++ library using '-lstdc++' or directly use g++.

If you are using Windows system, a more complete version of the toolbox can be downloaded from the following link:
http://ecson.org/resources/software/_AOSLevelsetSegmentationToolbox.zip
which includes all the pre-compiled mex files in the right place meaning you can use the toolbox directly without having to compile the c++ source files by yourself.

Hope this can help.

28 Aug 2009 Yan Zhang

Hi, Ning. One more thing: please don't use LCC compiler, it only supports C, NOT C++.

08 Sep 2009 Marco

Hi Yan,

I tried to compile your toolbox on a linux system using gcc and still got some errors. I guess it would help linux people if you changed the following:

1. The comments in zy_binary_boundary_detection.c are not in ANSI C style. I know that double slashes are widely used, but in my case, I had to change all comments to be included in /* */ pairs. To make your code more widely compatible, changing this might help.
2. The error using std::exception is still there, because in BinaryHeap.c, line 56, you still pass an empty string to it. Replacing
 throw std::exception("");
by
 throw std::exception();
solved this for me.

After changing these two issues, everything compiled on my debian and R2008b.
Apart from that, thanks for sharing your code.

08 Sep 2009 Yan Zhang

Hi Marco,

Thanks for your advices. For your Point 1, it's a strange problem, the file did pass my gcc 4.4 compiler on MacOSX. Then I tried to compile it on Ubuntu with the same compiler and it failed as you pointed out. As for Point 2, it's totally my fault.

14 Sep 2009 Cris Luengo

This is a great starting point to explore active contours, thanks for the code!

On Marco's point 1: if you pass GCC the -std=c99 option it will allow the C++ style comments. They have only recently been added to the ANSI C standard. I agree that using /* */ comments is more portable.

20 Sep 2009 jichao zhao

Could you provide your paper? I try to get your paper online, but it seems I can not. thanks

08 Oct 2009 Eran Ukwatta

Hi Yan Zhang,
 Thanks for the code. By the way, I have a question. I am used to computing divergence of the level set function for the smoothness term. However in your code what I fould is linear diffusion. Are these two different things?
I also would like to add the edge based information to the chan-vese method for 3D segmentation. Is that straightforward as modifying the following evolving equation in the function "ac_ChanVese_model" ?

phi = phi + delta_t*image_weight*((I-mu_out).^2 - (I-mu_in).^2);

Thanks.

16 Oct 2009 Yan Zhang

Hi Eran,

To answer your first question, let' s use u to represent the level-set, normally we use curvature flow to smooth the curve
u_t = div(\nabla u/|\nabla u|)
In my implementation, I do this in two steps:
(1) Make |\nabla u| = 1 using reinitialization (ac_reinit).
(2) With (1) the above equation can be simplified to
u_t = div(\nabla u) = \del u (the Laplacian of u)
which describes the linear diffusion of the level-set.
It's more efficient than solving the more general PDE
u_t = div(g \nabla u/|\nabla u|)
which leads to the answer to your second question --- you should look into the codes in "ac_GAC_model" (AOS implementation for geodesic active contour) that tells exactly how to integrate edge information.

27 Oct 2009 Jenny

Hi,Zhang yan.Thank you for your toolbox.I have a problem.I'm trying to use your box to segment my own MRI head datas which are a series of JPEG or DICOM forms.Is your tool possible to segment this form of data.Or I must convert these formats to the supported formats.And how to?Thank you very much!

12 Nov 2009 Khin

Hi Yan Zhang, When I read your 'test_ChanVese_model_3d.m' and 'test_hybrid_model_3d.m', I have a problem that cannot read head_ct.mat file. It's showing error "??? Error using ==> load Unable to read MAT file head_ct.mat. File may be corrupt." is it because of version different? I am using Matlab 6.5 please advise. thanks

19 Nov 2009 Alex Kararg

Cannot compile running the compile_mex_codes.m . The output is :

expr: syntax error
/Applications/MATLAB_R2008a/bin/util/mex/mexutil.sh: line 13: [: too many arguments
ld warning: duplicate dylib /Applications/MATLAB_R2008a/bin/maci/libz.1.dylib
ld warning: duplicate dylib /Applications/MATLAB_R2008a/bin/maci/libz.1.dylib
ld warning: duplicate dylib /Applications/MATLAB_R2008a/bin/maci/libz.1.dylib
ld warning: duplicate dylib /Applications/MATLAB_R2008a/bin/maci/libz.1.dylib
ld warning: duplicate dylib /Applications/MATLAB_R2008a/bin/maci/libz.1.dylib
BinaryHeap.h: In member function 'void CBinaryHeapMinSort<IndexType, WeightType>::Insert(IndexType, WeightType) [with IndexType = int, WeightType = double]':
ac_distance_transform_3d.cpp:27: instantiated from 'void DistanceTransform3D(const InputType*, OutputType*, const int*) [with InputType = unsigned char, OutputType = double]'
ac_distance_transform_3d.cpp:115: instantiated from here
BinaryHeap.h:56: error: no matching function for call to 'std::exception::exception(const char [1])'
/usr/include/c++/4.0.0/exception:57: note: candidates are: std::exception::exception()
/usr/include/c++/4.0.0/exception:55: note: std::exception::exception(const std::exception&)

    mex: compile of ' "ac_distance_transform_3d.cpp"' failed.

??? Error using ==> mex at 207
Unable to complete successfully.

Error in ==> compile_mex_codes at 7
mex ac_distance_transform_3d.cpp

Any help to run the compile_mex_codes.m would be really appreciated. Thank you!

22 Nov 2009 Yan Zhang

Hi Alex,

The problem has been fully discussed before, please see the previous comments for the details. In brief, go to the source file ac_distance_transform_3d.cpp, and get rid of the string in std::exception.

Please login to add a comment or rating.
Updates
03 Sep 2009

A problem has been fixed for GCC complier.

Tag Activity for this File
Tag Applied By Date/Time
2d3d image segmentation Yan Zhang 11 Aug 2009 14:01:51
levelset Yan Zhang 11 Aug 2009 14:01:52
aos Yan Zhang 11 Aug 2009 14:01:52
active contoursurface Yan Zhang 11 Aug 2009 14:01:52
snake Yan Zhang 11 Aug 2009 14:01:52
image processing Yan Zhang 11 Aug 2009 14:01:52
pde Yan Zhang 11 Aug 2009 14:01:52
curvature flow Yan Zhang 14 Aug 2009 02:43:14
chanvese model Yan Zhang 14 Aug 2009 02:43:14
hybrid snake model Yan Zhang 14 Aug 2009 02:43:14
implicit method Yan Zhang 14 Aug 2009 02:43:14
geodesica active contour Yan Zhang 14 Aug 2009 02:43:14
2d and 3d fast marching Yan Zhang 19 Aug 2009 04:21:52
active contoursurface Kim 05 Oct 2009 05:21:00
aos Kim 05 Oct 2009 05:21:07
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com