Libnvia
is a C++ template library for numeric variational image analysis. It
provides abstractions for some functions, functionals, operators and
spaces, and optimization subroutines used in image analysis with
variational or PDE methods. Libnvia is still under development.
Here is an example for computing the minimizer of the Rudin-Osher-Fatemi model with Chambolle's algorithm.
#include "nvia.h"
Function ROF_projector(Function& f, double lambda, double tau = 0.24, int steps = 10)
{
CoFunction p(f.dim(), 0., 0.);
for(int i = 0; i < steps; ++i) {
p = (p + (tau/lambda)*Grad(f + lambda*Div(p)))/(1. +
(tau/lambda)*abs(Grad(f + lambda*Div(p))));
}
return f + lambda * Div(p);
}
Another example using the above function to reconstruct an image.
#include <iostream>
#include "nvia.h"
using namespace std;
int main()
{
Function lena, u;
lena = read_pgm("lena.pgm");
add_gaussian_noise(lena, 10.);
write_pgm("lena_noise.pgm", lena);
u = ROF_projector(lena, 16.0, 0.24, 2);
write_pgm("u.pgm", u);
return 0;
}
Installation
There
is no need to compile anything. Download and extract libnvia's source
code in a directory and add it to the include path. To use libnvia
classes and functions, include nvia.h in the source file and compile.
There is no library to link to. Libnvia use GNU Scientific Library in
random number generation. Thus GSL should also be installed before
using libnvia.
download