17 #if defined(TVREG_NONGAUSSIAN) || (defined(TVREG_INPAINT) && defined(TVREG_DECONV))
27 #define ALGSTRING_SIZE 128
41 #define _TVREG_CONCAT(A,B) A ## B
44 #define FFT(S) _TVREG_CONCAT(fftwf_,S)
46 #define FFT(S) _TVREG_CONCAT(fftw_,S)
73 const num *VaryingLambda;
84 int (*PlotFun)(int, int, num,
const num*, int, int, int,
void*);
120 num *ATrans, *BTrans;
123 FFT(plan) TransformA;
124 FFT(plan) TransformB;
125 FFT(plan) InvTransformA;
126 FFT(plan) InvTransformB;
137 TvRestoreSimplePlot, NULL, NULL};
140 usolver *USolveFun, zsolver *ZSolveFun,
const tvregopt *Opt);
146 int TvRestoreSimplePlot(
int State,
int Iter, num Delta,
147 ATTRIBUTE_UNUSED
const num *u,
148 ATTRIBUTE_UNUSED
int Width,
149 ATTRIBUTE_UNUSED
int Height,
150 ATTRIBUTE_UNUSED
int NumChannels,
151 ATTRIBUTE_UNUSED
void *Param)
161 fprintf(stderr,
" Iteration %4d Delta %7.4f\r", Iter, Delta);
164 fprintf(stderr,
"Converged in %d iterations. \n", Iter);
167 fprintf(stderr,
"Maximum number of iterations exceeded.\n");
208 Free(Opt->AlgString);
222 Opt->Lambda = Lambda;
248 const num *VaryingLambda,
int LambdaWidth,
int LambdaHeight)
252 Opt->VaryingLambda = VaryingLambda;
253 Opt->LambdaWidth = LambdaWidth;
254 Opt->LambdaHeight = LambdaHeight;
271 const num *Kernel,
int KernelWidth,
int KernelHeight)
275 Opt->Kernel = Kernel;
276 Opt->KernelWidth = KernelWidth;
277 Opt->KernelHeight = KernelHeight;
302 Opt->Gamma1 = Gamma1;
314 Opt->Gamma2 = Gamma2;
326 Opt->MaxIter = MaxIter;
351 if(!NoiseModel || !strcmp(NoiseModel,
"L2") || !strcmp(NoiseModel,
"l2")
352 || !strcmp(NoiseModel,
"Gaussian") || !strcmp(NoiseModel,
"gaussian"))
353 Opt->NoiseModel = NOISEMODEL_L2;
354 else if(!strcmp(NoiseModel,
"L1") || !strcmp(NoiseModel,
"l1")
355 || !strcmp(NoiseModel,
"Laplace") || !strcmp(NoiseModel,
"laplace")
356 || !strcmp(NoiseModel,
"Laplacian") || !strcmp(NoiseModel,
"laplacian"))
357 Opt->NoiseModel = NOISEMODEL_L1;
358 else if(!strcmp(NoiseModel,
"Poisson") || !strcmp(NoiseModel,
"poisson"))
359 Opt->NoiseModel = NOISEMODEL_POISSON;
405 int (*PlotFun)(
int,
int, num,
const num*,
int,
int,
int,
void*),
410 Opt->PlotFun = PlotFun;
411 Opt->PlotParam = PlotParam;
427 if(!Opt->VaryingLambda)
428 printf(
"%g\n", Opt->Lambda);
430 printf(
"[%d x %d]\n",
431 Opt->LambdaWidth, Opt->LambdaHeight);
436 printf(
"(identity)\n");
438 printf(
"[%d x %d]\n", Opt->KernelWidth, Opt->KernelHeight);
440 printf(
"tol : %g\n", (
double)Opt->Tol);
441 printf(
"max iter : %d\n", Opt->MaxIter);
442 printf(
"gamma1 : %g\n", (
double)Opt->Gamma1);
443 printf(
"gamma2 : %g\n", (
double)Opt->Gamma2);
446 switch(Opt->NoiseModel)
454 case NOISEMODEL_POISSON:
458 printf(
"(invalid)\n");
462 printf(
"plotting : ");
464 if(Opt->PlotFun == TvRestoreSimplePlot)
466 else if(!Opt->PlotFun)
486 static const char *DefaultAlgorithm =
487 (
char *)
"split Bregman (d = grad u) Gauss-Seidel u-solver";
488 static const char *Invalid = (
char *)
"(invalid)";
491 int UseZ, DeconvFlag, DctFlag;
494 return DefaultAlgorithm;
497 &DctFlag, &USolveFun, &ZSolveFun, Opt))
500 sprintf(Opt->AlgString,
"split Bregman (%s) %s u-solver",
502 "d = grad u, z = Ku" :
509 return Opt->AlgString;