Population
Image processing library in C++
Classes

Matrix In -> Matrix Out (anisotropic non-linear diffusion equation, permeability, random walk) More...

Classes

class  pop::PDE
 Algorithm based on partial differential equations. More...
 

Detailed Description

Matrix In -> Matrix Out (anisotropic non-linear diffusion equation, permeability, random walk)

In mathematics, a partial differential equation (PDE) is a differential equation that contains unknown multivariable functions and their partial derivatives. In this module, we use dinite-difference methods a for approximating the solutions to these equations using finite difference equations to approximate derivatives. The most classical equation is the diffusion : $:\frac{\partial\phi(\mathbf{r},t)}{\partial t} = D\nabla^2\phi(\mathbf{r},t), $. The approximation is coded as follows:

Mat2UI8 img;
img.load((std::string(POP_PROJECT_SOURCE_DIR)+"/image/Lena.bmp").c_str());
Mat2F32 img_timet(img);//operation on float
Mat2F32 img_timet_plus_one(img);
FunctorPDE::Laplacien<> laplacien;
F32 D=0.25;//diffusion coefficient
MatNDisplay disp;
for(unsigned int index_time=0;index_time<300;index_time++){
std::cout<<index_time<<std::endl;
ForEachDomain2D(x,img_timet) {
img_timet_plus_one(x) = img_timet(x) + D*laplacien(img_timet,x);
}
img_timet = img_timet_plus_one;//timet<-timet_plus_one
disp.display(img_timet);//display the current image
}
diffusion2.gif
heat equation on Lena image

For a more flexible implementation, I define a collection of functors pop::FunctorPDE for the classical differential operators in finite difference scheme.