Multi-scale Series Contextual Model


Multi-scale contextual model is a series of classifiers which applies a set of linear filters to the context image consecutively to generate a scale-space representation of the context and gives the classifier access to samples of the scale space. The samples of the coarser scale are more informative and robust against noise due to the averaging.


This a memory friendly version of our multi-scale contextual model implemented in C++. You can download it here.


OpenCV and Boost are required to compile this code.

    [1] OpenCV 2.4.8

    [2] Boost 1.53.0


Download the zip file. Unzip it and use cmake to build it.



    [2] ccmake .

    [3] set the dependency paths.

    [4] set the CMAKE_BUILD_TYPE to RELEASE.   

    [5] press “c” to configure and “g” to generate.

    [6] make

I have compiled the code on both Linux and Mac successfully.


[1] There is a “params.txt” file which contains the parameters. You can change the parameters in this file. If you want to use the default parameters you don’t need to modify it. For larger objects you probably want to increase the radius.

[2]  You can run the code in three different modes:

[mode a: Full mode] Pass training and testing images at the same time. The model uses the training images to learn the parameters and runs the trained model on the testing images. Here is an example:

./RunSeries train/ trainLabels/ results/ test/

“train” contains training images.

“trainLabels” contains training labels.

“results” would contain the trained models and outputs.

“test” contains testing images.

[mode b: Train mode] Pass training images and training labels. The model learns the parameters and saves them for later usage. Here is an example:

./RunSeries train/ trainLabels/ results/

“train” contains training images.

“trainLabels” contains training labels.

“results” would contain the trained models and outputs.

[mode c: Test mode] Pass testing images and previously trained model. The model will generate the outputs for testing images. Here is an example:

./RunSeries test/ results/

“test” contains testing images.

“results” contains the trained models. Also, the testing outputs will be written in this folder.

I have included sample folders for training images and labels. Note that the code expects labels to be between 0 and 255 ( it is binary so 0 for background and 255 for foreground)


If you use this code please cite the following:

M. Seyedhosseini and T. Tasdizen. Multi-class multi-scale series contextual model for image segmentation. In IEEE Transactions on Image Processing, Vol 22, No 11, pages 4486–4496, 2013. [pdf,bibtex]


  1. -The first version was released (April 10th 2014).


Questions or bug? please email me