Image processing library in C++
First step

This first step explains how to write your first program:

The code source of the main.cpp delivered in the Population project is :

#include"Population.h"//Single header
using namespace pop;//Population namespace
int main()
Mat2UI8 img;//2d grey-level image object
img.load(POP_PROJECT_SOURCE_DIR+std::string("/image/iex.png"));//replace this path by those on your computer
img = PDE::nonLinearAnisotropicDiffusion(img);//filtering
int value;
Mat2UI8 threshold = Processing::thresholdOtsuMethod(img,value);//threshold segmentation
Mat2RGBUI8 color = Visualization::labelForeground(threshold,img);//Visual validation
return 0;

producing this image.


Line by line,


-> include the single header file of the Population library.

using namespace pop;

-> population namespace to facilate the declarations in avoiding pop::

Mat2UI8 img;

-> instantiate an object as 2d image with grey-level values


-> load the image (iex.png file is contained in the population folder, Population manage pgm, png, jpg, bmp formats)

img = PDE::nonLinearAnisotropicDiffusion(img);//filtering

-> filter the image to remove the noise. The algorithms are organized in modules as “procedural” classes containing a collection of static function members. To access the algorithms, you can write the scope resolution operator.

double value;
Mat2UI8 threshold = Processing::thresholdOtsuMethod(img,value);//threshold segmentation

-> segment the image with the Otsu's threshold


-> save the image in the input path

Mat2RGBUI8 color = Visualization::labelForeground(threshold,img);//Visual validation

-> create a color image with the segmentation in foreground of the initial image


-> display this image in a windows.

Now, you are ready to code your own program by replacing these source lines of code by your !

Pyton code:

1 import sys
2 import os
3 PathPop= ""
4 if os.path.isfile(PathPop+"population.py")==0:
5  print "set the variable PathPop to the path where you compile population, for instance D:\Users/vtariel/Desktop/ANV/Population-build/. This folder must contain population.py"
6  sys.exit(-1)
7 sys.path.append(PathPop)
8 from population import *
10 img =Mat2UI8()#2d grey-level image object
11 img.load(PathPop+"image/iex.png")#replace this path by those on your computer
12 img.display("initial",False)
13 pde = PDE()
14 img = pde.nonLinearAnisotropicDiffusion(img)
15 proc = Processing()
16 threshold = proc.thresholdOtsuMethod(img)#threshold segmentation with OtsuMethod
17 threshold.save("iexseg.png")
18 visu = Visualization()
19 color = visu.labelForeground(threshold,img)#Visual validation
20 color.display()