Total Variation Inpainting using Split Bregman
Functions
tvreg.c File Reference

TV-regularized image restoration. More...

#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "tvregopt.h"
#include "dsolve_inc.c"

Go to the source code of this file.

Functions

int TvRestore (num *u, const num *f, int Width, int Height, int NumChannels, tvregopt *Opt)
 Total variation based image restoration. More...
 
static int IsSymmetric (const num *Kernel, int KernelWidth, int KernelHeight)
 Test if Kernel is whole-sample symmetric.
 
static int TvRestoreChooseAlgorithm (int *UseZ, int *DeconvFlag, int *DctFlag, usolver *USolveFun, zsolver *ZSolveFun, const tvregopt *Opt)
 Algorithm planning function.
 

Detailed Description

TV-regularized image restoration.

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 tvreg.c.

Function Documentation

int TvRestore ( num *  u,
const num *  f,
int  Width,
int  Height,
int  NumChannels,
tvregopt Opt 
)

Total variation based image restoration.

Parameters
uinitial guess, overwritten with restored image
finput image
Width,Height,NumChannelsdimensions of the input image
Opttvregopt options object
Returns
0 on failure, 1 on success, 2 on maximum iterations exceeded

This routine implements simultaneous denoising, deconvolution, and inpainting with total variation (TV) regularization, using either the Gaussian (L2), Laplace (L1), or Poisson noise model, such that Kernel*u is approximately f outside of the inpainting domain.

The input image f should be a contiguous array of size Width by Height by NumChannels in planar row-major order, f[x + Width*(y + Height*k)] = kth component of pixel (x,y).

The image intensity values of f should be scaled so that the maximum intensity range of the true clean image is from 0 to 1. It is allowed that f have values outside of [0,1] (as spurious noisy pixels can exceed this range), but it should be scaled so that the restored image is in [0,1]. This scaling is especially important for the Poisson noise model.

Typically, NumChannels is either 1 (grayscale image) or 3 (color image), but NumChannels is allowed to be any positive integer. If NumChannels > 1, then vectorial TV (VTV) regularization is used in place of TV.

Image u is both an input and output of the routine. Image u should be set by the caller to an initial guess, for example a good generic initialization is to set u as a copy of f. Image u is overwritten with the restored image.

Other options are specified through the options object Opt. First use tvregopt Opt = TvRegNewOpt() to create a new options object with default options (denoising with the Gaussian noise model). Then use the following functions to make settings.

When done, call TvRegFreeOpt() to free the options object. Setting Opt = NULL uses the default options (denoising with Gaussian noise model).

The split Bregman method is used to solve the minimization, T. Goldstein and S. Osher, "The Split Bregman Algorithm for L1 Regularized Problems", UCLA CAM Report 08-29.

The routine automatically adapts the algorithm according to the inputs. If no deconvolution is needed, Gauss-Seidel is used to solve the u-subproblem. If the kernel is symmetric, a DCT-based solver is applied and, if not, a (slower) Fourier-based solver. For the Gaussian noise model, the routine uses a simpler splitting of the problem with two auxiliary variables. For non-Gaussian noise models, a splitting with three auxiliary variables is applied.

Definition at line 98 of file tvreg.c.