Smooth an image with Total Variation (TV) regularization (standard ROF model, anisotropic, second order)
Usage: example_total_variation
reads a given parameter file (see tv.par, aniso_tv.par, secondo_oder_tv.par in the examples subfolder) and performs a smoothing with TV regularization with the parameters given in this file.
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <vigra/multi_array.hxx>
#include <vigra/stdimagefunctions.hxx>
#include <vigra/tv_filter.hxx>
#ifdef _MSC_VER
#define strcasecmp _stricmp
#endif
std::cout<<"Could not read from file.\n";
}
std::cout<<
"Found parameter "<<
dummy<<
" instead of "<<name<<
"\n";
}
else
std::cout<<
"Parameter "<<name<<
" = "<<
out<<std::endl;
}
float f=0;
std::cout<<"Could not read from file.\n";
}
std::cout<<
"Found parameter "<<
dummy<<
" instead of "<<name<<
"\n";
}
else{
std::cout<<"Parameter "<<name<<" = "<<f<<std::endl;
}
return f;
}
{
using namespace multi_math;
{
std::cout <<
"Usage: " <<
argv[0] <<
" parameterfile" << std::endl;
std::cout <<
"(supported formats for images: " <<
impexListFormats() <<
")" << std::endl;
return 1;
}
try
{
std::cout<<
"Cannot open file "<<
argv[1]<<std::endl;
return 1;
}
switch(mode){
case 1:
case 2:
break;
case 3:
break;
case 4:
break;
default:
std::cout<<"Unknown mode "<<mode<<std::endl;
}
{
for (int y=0;y<data.shape(1);y++){
for (int x=0;x<data.shape(0);x++){
}
}
importImage(
info, destImage(data));
data=data*(1/255.);
switch(mode){
case 1:
std::cout<<"Standard TV filter"<<std::endl;
break;
case 2:
std::cout<<"Weighted TV filter"<<std::endl;
break;
case 3:{
std::cout<<"Anisotropic TV filter"<<std::endl;
std::cout<<
"outer step "<<
i<<
"\n";
std::cout<<"Writing temp file\n";
else{
}
}
}
break;
}
case 4:{
std::cout<<"Second order TV filter"<<std::endl;
for (int y=0;y<data.shape(1);y++){
for (int x=0;x<data.shape(0);x++){
}
}
std::cout<<
"outer step "<<
i<<
"\n";
std::cout<<"Writing temp file\n";
else{
}
}
}
}
}
else{
}
}
else
{
std::cout<<"Color images are currently not supported !\n";
}
}
catch (std::exception & e)
{
std::cout << e.what() << std::endl;
return 1;
}
return 0;
}
Argument object for the function exportImage().
Definition imageinfo.hxx:134
Argument object for the function importImage().
Definition imageinfo.hxx:391
Class for a single RGB value.
Definition rgbvalue.hxx:128
image import and export functions
void totalVariationFilter(...)
Performs standard Total Variation Regularization.
double gamma(double x)
The gamma function.
Definition mathutil.hxx:1587
std::string impexListFormats()
List the image formats VIGRA can read and write.
void anisotropicTotalVariationFilter(...)
Performs Anisotropic Total Variation Regularization.
void secondOrderTotalVariationFilter(...)
Performs Anisotropic Total Variation Regularization.
void getAnisotropy(...)
Sets up directional data for anisotropic regularization.