This code was developped by Aurelien Lucchi during his doctoral studies in the computer vision laboratory run by Prof. Pascal Fua at EPFL.
Contributors:
This tutorial will help you compile the code and run it on your own system. It is intended for people with a Linux system but windows or mac users should also be able to compile the code.
Step-by-step instructions:
-
Copy the source code from the web.
-
Make sure you have cmake installed on your system (cmake is a tool to create makefiles).
-
Compile third-party libraries :
UNIX
- OpenCv (Install package opencv-dev in Ubuntu or download from http://opencv.org). Versions 3 and 2.4 work.
- zlib. If you have problems with zlib, we recommend using the one shipped as a 3rdparty within
opencv
. SetZLIB_INCLUDE_DIR
to3rdparty/zlib
andZLIB_LIBRARY
tobuild/3rdpartz/lib/zlib.lib
- ITK : Download from the ITK web site and set review flag to
ON
(this can be done by using advanced mode with ccmake and settting variableModule_ITKReview
to ON). Tested version 4.7. - SLIC: Go to
lib/slic
. Typeccmake ..
, change the OpenCV_DIR and then typemake
to build the slic library. - Go to
lib/libDAI-0.2.4
and typemake
. Note thatlibDAI
requires the following dependencies for Ubuntu:sudo apt-get install g++ make doxygen graphviz libboost-dev libboost-graph-dev libboost-program-options-dev
WINDOWS
We recommend using
MSBuild
to build. For example"C:\Windows\Microsoft.NET\Framework64\v4.0.30319\MSBuild.exe" opencv.sln /p:Configuration=Release /m
- OpenCV: download archive from web site. Then create a Visual Studio solution with cmake (or cmake-gui). You might have to change the options to vuils a static library. Then compile with
MSBuild.exe opencv.sln
. Versions 3 and 2.4 work. - zlib
If you have problems with zlib, we recommend using the one shipped as a 3rdparty within
opencv
. SetZLIB_INCLUDE_DIR
to3rdparty/zlib
andZLIB_LIBRARY
tobuild/3rdparty/lib/Release/zlib.lib
. In OpenCV 2.4 you may have to copy the generatedzconf.h
frombuild/3rdparty/include
orsources/build/3rdparty/zlib
to3rdparty/zlib
, or include both paths.- SLIC: Go to
lib/slic
and typecmake .; make
- ITK: Download from the ITK web site and set review flag to
ON
(can be done by using advanced mode with ccmake and settting variableModule_ITKReview
toON
). Tested version 4.7. - Go to
lib/libDAI-0.2.4
and typecmake
andMSBuild.exe dai.sln
. Note thatlibDAI
requiresboost
. - Add
dirent.h
tocore/
- [OPTIONAL] Install
7-zip
to compress intermediary results.
-
Main code
Edit the variables in the "THIRD-PARTY LIBRARIES" section in
CMakeLists_common.txt
(you can also use theccmake
(UNIX) orcmake-gui
(WINDOWS) interface). You might want to turn off some of the dependencies. Look at theUSE_???
flags.Go to the
superpixels_public
directory and compile withUNIX
mkdir build ccmake ..
Once configured and generated run
make
WINDOWS
mkdir build cmake-gui ..
Once configured and generated run
MSBuild.exe sliceMe.sln
or open thesliceMe.sln
with Visual Studio. -
Edit the config file
This program relies on a configuration file that contains all the parameters needed for training or applying the algorithm to a new dataset. Below is a description of each parameter.
trainingDir
: Input volume (TIF cube).maskTrainingDir
: Mask volume (TIF cube or series of png images containing black and white voxels only)outputModel
: Output model file (default=model.txt
)testDir
: Test input volume (TIF cube).maskTestDir
: Test mask volume (TIF cube containing black and white voxels only).stepForOutputFiles
: output files and corresponding scores are computed every stepForOutputFiles iterations. Reasonable values are 10 for default training algorithm and 100 for stochastic optimization (-w 9
option described below).featureTypes
: Type of features extracted from the image/cube and used to train a model. The default value isfeatureTypes=33
.nMaxIterations
: Maximum number of iterations. This number should be around 500-1000 iterations depending on how much training data is provided to the algorithm.
An example configuration file named
config.txt
with a set of default parameters is provided in the root directory or on the biomed web. -
Running the code
Look at
howto.pdf
- Multithreading
For ssvm, edit svm_struct_globals.h
and change NTHREADS