Total Variation Inpainting using Split Bregman
Data Structures | Macros | Typedefs | Enumerations | Functions | Variables
tvregopt.h File Reference

tvreg options handling and internal definitions More...

#include "tvreg.h"

Go to the source code of this file.

Data Structures

struct  numvec2
 2D vector with num components More...
 
struct  tag_tvregopt
 Options handling for TvRestore. More...
 
struct  tag_tvregsolver
 TvRestore solver state. More...
 

Macros

#define ALGSTRING_SIZE   128
 Size of the string buffer for holding the algorithm description.
 
#define _TVREG_CONCAT(A, B)   A ## B
 Token concatenation macro. More...
 
#define FFT(S)   _TVREG_CONCAT(fftw_,S)
 

Typedefs

typedef num numcomplex [2]
 Complex value type.
 
typedef struct tag_tvregsolver tvregsolver
 TvRestore solver state. More...
 
typedef num(* usolver )(tvregsolver *)
 
typedef void(* zsolver )(tvregsolver *)
 

Enumerations

enum  noisemodel { NOISEMODEL_L2, NOISEMODEL_L1, NOISEMODEL_POISSON }
 Enum of the noise models supported by TvRestore.
 

Functions

static int TvRestoreChooseAlgorithm (int *UseZ, int *DeconvFlag, int *DctFlag, usolver *USolveFun, zsolver *ZSolveFun, const tvregopt *Opt)
 
int TvRestoreSimplePlot (int State, int Iter, num Delta, ATTRIBUTE_UNUSED const num *u, ATTRIBUTE_UNUSED int Width, ATTRIBUTE_UNUSED int Height, ATTRIBUTE_UNUSED int NumChannels, ATTRIBUTE_UNUSED void *Param)
 
tvregoptTvRegNewOpt ()
 Create a new tvregopt options object. More...
 
void TvRegFreeOpt (tvregopt *Opt)
 Free tvregopt options object. More...
 
void TvRegSetLambda (tvregopt *Opt, num Lambda)
 Specify fidelity weight lambda. More...
 
void TvRegSetVaryingLambda (tvregopt *Opt, const num *VaryingLambda, int LambdaWidth, int LambdaHeight)
 Specify spatially varying fidelity weight. More...
 
void TvRegSetKernel (tvregopt *Opt, const num *Kernel, int KernelWidth, int KernelHeight)
 Specify kernel for a deconvolution problem. More...
 
void TvRegSetTol (tvregopt *Opt, num Tol)
 Specify convergence tolerance. More...
 
void TvRegSetGamma1 (tvregopt *Opt, num Gamma1)
 Specify d = grad u penalty weight. More...
 
void TvRegSetGamma2 (tvregopt *Opt, num Gamma2)
 Specify z = Ku constraint weight. More...
 
void TvRegSetMaxIter (tvregopt *Opt, int MaxIter)
 Specify the maximum number of iterations. More...
 
int TvRegSetNoiseModel (tvregopt *Opt, const char *NoiseModel)
 Specify noise model. More...
 
void TvRegSetPlotFun (tvregopt *Opt, int(*PlotFun)(int, int, num, const num *, int, int, int, void *), void *PlotParam)
 Specify plotting function. More...
 
void TvRegPrintOpt (const tvregopt *Opt)
 Debugging function that prints the current options. More...
 
const char * TvRegGetAlgorithm (const tvregopt *Opt)
 Get a string description of the selected restoration algorithm. More...
 

Variables

tvregopt TvRegDefaultOpt
 Default options struct. More...
 

Detailed Description

tvreg options handling and internal definitions

Author
Pascal Getreuer getre.nosp@m.uer@.nosp@m.gmail.nosp@m..com

Copyright (c) 2010-2012, Pascal Getreuer All rights reserved.

This program is free software: you can use, modify and/or redistribute it under the terms of the simplified BSD License. You should have received a copy of this license along this program. If not, see http://www.opensource.org/licenses/bsd-license.html.

Definition in file tvregopt.h.

Macro Definition Documentation

#define _TVREG_CONCAT (   A,
 
)    A ## B

Token concatenation macro.

This extra level of indirection is needed so that macros expand before token pasting. The use of this concatenation is for a name mangling macro FFT(S) for using num with the FFTW library. The macro is defined such that FFT(functionname) expands to fftwf_functionname if num is single, or fftw_functionname if num is double, according to whether NUM_SINGLE is defined.

Definition at line 41 of file tvregopt.h.

Typedef Documentation

typedef struct tag_tvregsolver tvregsolver

TvRestore solver state.

This struct represents the TvRestore solver state. It holds all variables and parameters to be passed between TvRestore() and the solver subroutines.

Function Documentation

void TvRegFreeOpt ( tvregopt Opt)

Free tvregopt options object.

Parameters
Opttvregopt options object

Definition at line 203 of file tvregopt.h.

const char* TvRegGetAlgorithm ( const tvregopt Opt)

Get a string description of the selected restoration algorithm.

Parameters
Opttvregopt options object
Returns
String describing the selected algorithm

This routine calls TvRestoreChooseAlgorithm() and translates the result to a text string. The string is stored in a small buffer within the tvregopt and does not need to be released separately.

Definition at line 484 of file tvregopt.h.

tvregopt* TvRegNewOpt ( )

Create a new tvregopt options object.

Returns
tvregopt pointer, or NULL if out of memory

This routine creates a new tvregopt options object and initializes it to default values. It is the caller's responsibility to call TvRegFreeOpt() to free the tvregopt object when done.

Definition at line 182 of file tvregopt.h.

void TvRegPrintOpt ( const tvregopt Opt)

Debugging function that prints the current options.

Parameters
Opttvregopt options object

Definition at line 420 of file tvregopt.h.

void TvRegSetGamma1 ( tvregopt Opt,
num  Gamma1 
)

Specify d = grad u penalty weight.

Parameters
Opttvregopt options object
Gamma1penalty (positive scalar)

Definition at line 299 of file tvregopt.h.

void TvRegSetGamma2 ( tvregopt Opt,
num  Gamma2 
)

Specify z = Ku constraint weight.

Parameters
Opttvregopt options object
Gamma1penalty (positive scalar)

Definition at line 311 of file tvregopt.h.

void TvRegSetKernel ( tvregopt Opt,
const num *  Kernel,
int  KernelWidth,
int  KernelHeight 
)

Specify kernel for a deconvolution problem.

Parameters
Opttvregopt options object
Kernelpointer to convolution kernel
KernelWidth,KernelHeightdimensions of the kernel

Kernel should be a contiguous array of size KernelWidth by KernelHeight in row-major order, Kernel[x + KernelWidth*y] = K(x,y). If Kernel = NULL, then no deconvolution is performed.

Definition at line 270 of file tvregopt.h.

void TvRegSetLambda ( tvregopt Opt,
num  Lambda 
)

Specify fidelity weight lambda.

Parameters
Opttvregopt options object
Lambdafidelity weight (positive scalar)

Definition at line 219 of file tvregopt.h.

void TvRegSetMaxIter ( tvregopt Opt,
int  MaxIter 
)

Specify the maximum number of iterations.

Parameters
Opttvregopt options object
MaxItermaximum number of iterations

Definition at line 323 of file tvregopt.h.

int TvRegSetNoiseModel ( tvregopt Opt,
const char *  NoiseModel 
)

Specify noise model.

Parameters
Opttvregopt options object
NoiseModelstring

NoiseModel should be a string specifying one of the following:

  • 'Gaussian' or 'L2' (default) Additive white Gaussian noise (AWGN), this is the noise model used in the traditional Rudin-Osher-Fatemi model;
  • 'Laplace' or 'L1' Laplace noise, effective for salt & pepper noise;
  • 'Poisson' Each pixel is an independent Poisson random variable with mean equal to the exact value.

Definition at line 346 of file tvregopt.h.

void TvRegSetPlotFun ( tvregopt Opt,
int(*)(int, int, num, const num *, int, int, int, void *)  PlotFun,
void *  PlotParam 
)

Specify plotting function.

Parameters
Opttvregopt options object
PlotFunplotting function
PlotParamvoid pointer for passing addition parameters

Specifying the plotting function gives control over how TvRestore displays information. Setting PlotFun = NULL disables all normal display (error messages are still displayed).

An example PlotFun is

int ExamplePlotFun(int State, int Iter, num Delta,
const num *u, int Width, int Height, int NumChannels, void *PlotParam)
{
switch(State)
{
case 0:
fprintf(stderr, " RUNNING Iter=%4d, Delta=%7.4f\r", Iter, Delta);
break;
case 1:
fprintf(stderr, " CONVERGED Iter=%4d, Delta=%7.4f\n", Iter, Delta);
break;
case 2:
fprintf(stderr, " Maximum number of iterations exceeded!\n");
break;
}
return 1;
}

The State argument is either 0, 1, or 2, and indicates TvRestore's status. Iter is the number of Bregman iterations completed, Delta is the change in the solution Delta = ||u^cur - u^prev||_2 / ||f||_2. Argument u gives a pointer to the current solution, which can be used to plot an animated display of the solution progress. PlotParam is a void pointer that can be used to pass additional information to PlotFun if needed.

Definition at line 404 of file tvregopt.h.

void TvRegSetTol ( tvregopt Opt,
num  Tol 
)

Specify convergence tolerance.

Parameters
Opttvregopt options object
Tolconvergence tolerance (positive scalar)

Definition at line 287 of file tvregopt.h.

void TvRegSetVaryingLambda ( tvregopt Opt,
const num *  VaryingLambda,
int  LambdaWidth,
int  LambdaHeight 
)

Specify spatially varying fidelity weight.

Parameters
Opttvregopt options object
VaryingLambdapointer to Lambda array
LambdaWidth,LambdaHeightdimensions of the array

VaryingLambda should be a contiguous array of size LambdaWidth by LambdaHeight in row-major order of nonnegative values, VaryingLambda[x + Width*y] = fidelity weight at pixel (x,y). Smaller VaryingLambda at a point implies stronger denoising, and a value of zero specifies that the point should be inpainted.

If VaryingLambda = NULL, the constant Lambda value is used.

For inpainting, set VaryingLambda as VaryingLambda[x + Width*y] = 0 if pixel (x,y) is unknown, VaryingLambda[x + Width*y] = C if pixel (x,y) is known, where C is a positive constant. Unknown pixels are inpainted (interpolated). Known pixels are denoised (and deconvolved, if a kernel is also set). To keep the known pixels (approximately) unchanged, set C to a large value.

Definition at line 247 of file tvregopt.h.

Variable Documentation

tvregopt TvRegDefaultOpt
Initial value:
= {TVREGOPT_DEFAULT_LAMBDA, NULL, 0, 0, NULL, 0, 0,
TvRestoreSimplePlot, NULL, NULL}

Default options struct.

Definition at line 134 of file tvregopt.h.