Image Interpolation with Geometric Contour Stencils
|
Contour stencil interpolation. More...
Go to the source code of this file.
Data Structures | |
struct | sinterpentry |
Data for interpolating with a contour stencil. More... | |
struct | sinterpstruct |
Data for interpolating with a contour stencil set. More... | |
Macros | |
#define | NEIGHRADIUS 1 |
The size of the synthesis neighborhood . More... | |
#define | QUAD_RES 8 |
Quadrature resolution to use for integrals. More... | |
#define | TRIG_TABLE_SIZE 256 |
Size of the trignometry tables used in RhoFast. More... | |
#define | EXP_TABLE_SIZE 1024 |
Size of the exponential table used in RhoFast. More... | |
#define | WINDOWRADIUS (1 + NEIGHRADIUS) |
Support radius of the window function . More... | |
#define | NEIGHDIAMETER (1 + 2*NEIGHRADIUS) |
Diameter of the neighborhood. More... | |
#define | NEIGHCENTER (NEIGHRADIUS + NEIGHRADIUS*NEIGHDIAMETER) |
Index of the neighborhood center. More... | |
#define | NUMNEIGH (NEIGHDIAMETER*NEIGHDIAMETER) |
Number of neighbors in the neighborhood, . More... | |
Typedefs | |
typedef struct sinterpstruct | sinterptype |
Data for interpolating with a contour stencil set. More... | |
Functions | |
int | InterpolateStencil (sinterp *SInterp, int S, const double *PsfSamples) |
Compute interpolation information for a stencil. More... | |
sinterp * | NewSInterp (const sset *StencilSet, float RhoSigmaTangent, float RhoSigmaNormal) |
Create a new sinterp object. More... | |
void | FreeSInterp (sinterp *SInterp) |
Free an sinterp object. More... | |
int | ArbitraryScale (float *Output, int OutputWidth, int OutputHeight, const int *Stencil, const sinterp *SInterp, const float *Input, int InputWidth, int InputHeight, float ScaleFactor, int CenteredGrid) |
Scale a color image by a possibly non-integer scale factor. More... | |
float * | ComputeRhoSamples (const sinterp *SInterp, int ScaleFactor, int CenteredGrid) |
Precompute samples of for an integer scale factor. More... | |
void | IntegerScalePass (float *Output, const int *Stencil, const float *RhoSamples, const float *Input, int InputWidth, int InputHeight, int ScaleFactor, int CenteredGrid) |
Scale a color image by an integer factor. More... | |
int | Prefilter (float *Filtered, const int *Stencil, const float *RhoSamples, const float *Input, int InputWidth, int InputHeight, int ScaleFactor, int CenteredGrid, float PsfSigma, int NumPasses) |
Prefilter a color image to improve deconvolution accuracy. More... | |
float | DeconvResidual (float *Residual, const float *Coarse, int CoarseWidth, int CoarseHeight, const float *Interp, int InterpWidth, int InterpHeight, float ScaleFactor, int CenteredGrid, float PsfSigma) |
Compute deconvolution residual for prefiltering. More... | |
Contour stencil interpolation.
This file implements contour stencil interpolation for color images by integer and non-integer scale factors. The main routines are
Copyright (c) 2010-2011, 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 sinterp.c.
#define EXP_TABLE_SIZE 1024 |
#define NEIGHCENTER (NEIGHRADIUS + NEIGHRADIUS*NEIGHDIAMETER) |
#define NEIGHDIAMETER (1 + 2*NEIGHRADIUS) |
#define NEIGHRADIUS 1 |
#define NUMNEIGH (NEIGHDIAMETER*NEIGHDIAMETER) |
#define QUAD_RES 8 |
#define TRIG_TABLE_SIZE 256 |
#define WINDOWRADIUS (1 + NEIGHRADIUS) |
typedef struct sinterpstruct sinterptype |
Data for interpolating with a contour stencil set.
int ArbitraryScale | ( | float * | Output, |
int | OutputWidth, | ||
int | OutputHeight, | ||
const int * | Stencil, | ||
const sinterp * | SInterp, | ||
const float * | Input, | ||
int | InputWidth, | ||
int | InputHeight, | ||
float | ScaleFactor, | ||
int | CenteredGrid | ||
) |
Scale a color image by a possibly non-integer scale factor.
Output | the output image |
OutputWidth,OutputHeight | dimensions of the output image |
Stencil | the best-fitting stencils |
SInterp | stencil interpolation data |
Input | the input image in row-major interleaved order |
InputWidth,InputHeight | dimensions of the input image |
ScaleFactor | scale factor between input and output images |
CenteredGrid | use centered grid if nonzero or top-left otherwise |
This routine implements for a possibly non-integer scale factor the interpolation formula
where the coefficients are computed as
For more accurate deconvolution, Prefilter() should be called first to prefilter the input image.
In the code, the mathematical meanings of the variables are as follows:
For computational efficiency, RhoFast() is used to evaluate instead of Rho(), as needs to be evaluated here many times.
float* ComputeRhoSamples | ( | const sinterp * | SInterp, |
int | ScaleFactor, | ||
int | CenteredGrid | ||
) |
Precompute samples of for an integer scale factor.
SInterp | stencil interpolation data |
ScaleFactor | the integer scale factor |
CenteredGrid | use centered grid if nonzero or top-left otherwise |
This routine evaluates samples of
at locations on a fine grid with step size 1/ScaleFactor, where ScaleFactor is an integer. This precomputation significantly accelerates image scaling by an integer factor.
The samples are computed for every stencil for every neighbor over a square window of size SupportWidth by SupportWidth, where SupportWidth = 2*WINDOWRADIUS*ScaleFactor or this value minus 1, depending on the choice of grid and the oddness of ScaleFactor.
float DeconvResidual | ( | float * | Residual, |
const float * | Coarse, | ||
int | CoarseWidth, | ||
int | CoarseHeight, | ||
const float * | Interp, | ||
int | InterpWidth, | ||
int | InterpHeight, | ||
float | ScaleFactor, | ||
int | CenteredGrid, | ||
float | PsfSigma | ||
) |
Compute deconvolution residual for prefiltering.
Residual | the residual image |
Coarse | the coarse image |
CoarseWidth,CoarseHeight | dimensions of the coarse image |
Interp | the interpolated image |
InterpWidth,InterpHeight | dimensions of the interpolated image |
ScaleFactor | scale factor between coarse and interpolated images |
CenteredGrid | use centered grid if nonzero or top-left otherwise |
PsfSigma | Gaussian PSF standard deviation in units of input pixels |
This routine computes the deconvolution residual
where v is the coarse image and u is the interpolation. This residual is used in the iterative refinement procedure implemented in Prefilter().
void FreeSInterp | ( | sinterp * | SInterp | ) |
void IntegerScalePass | ( | float * | Output, |
const int * | Stencil, | ||
const float * | RhoSamples, | ||
const float * | Input, | ||
int | InputWidth, | ||
int | InputHeight, | ||
int | ScaleFactor, | ||
int | CenteredGrid | ||
) |
Scale a color image by an integer factor.
Output | the output image |
Stencil | the best-fitting stencils |
RhoSamples | precomputed samples of |
Input | the input image in row-major interleaved order |
InputWidth,InputHeight | dimensions of the input image |
ScaleFactor | scale factor between input and output images |
CenteredGrid | use centered grid if nonzero or top-left otherwise |
This routine implements for a integer scale factor the interpolation formula
int InterpolateStencil | ( | sinterp * | SInterp, |
int | S, | ||
const double * | PsfSamples | ||
) |
Compute interpolation information for a stencil.
SInterp | stencil set interpolation data |
S | index of the stencil to interpolate |
PsfSamples | precomputed samples of the PSF |
The orientation and anisotropy of the synthesis functions are computed,
The interpolation matrix
is computed and inverted with InvertMatrix().
Create a new sinterp object.
StencilSet | stencil set to perform interpolation with |
RhoSigmaTangent,RhoSigmaNormal | parameters for Rho |
Given a stencil set , this routine performs the necessary precomputations for interpolation and stores it in an sinterp data structure. Each stencil is processed with InterpolateStencil() to create an sinterpentry.
int Prefilter | ( | float * | Filtered, |
const int * | Stencil, | ||
const float * | RhoSamples, | ||
const float * | Input, | ||
int | InputWidth, | ||
int | InputHeight, | ||
int | ScaleFactor, | ||
int | CenteredGrid, | ||
float | PsfSigma, | ||
int | NumPasses | ||
) |
Prefilter a color image to improve deconvolution accuracy.
Filtered | the prefiltered image |
Stencil | the best-fitting stencils |
RhoSamples | precomputed samples of |
Input | the input image in row-major interleaved order |
InputWidth,InputHeight | dimensions of the input image |
ScaleFactor | scale factor between input and output images |
CenteredGrid | use centered grid if nonzero or top-left otherwise |
PsfSigma | Gaussian PSF standard deviation in units of input pixels |
NumPasses | number of passes of iterative refinement to perform |
This routine performs the iterative refinement prefiltering
Interpolation with a prefiltered image improves the resulting deconvolution accuracy. Interpolation is performed using the prefiltered image as input with either IntegerScalePass() for an integer scale factor or by ArbitraryScale() for a non-integer scale factor.
Prefiltering is implemented with IntegerScalePass() to perform the interpolations and DeconvResidual() to compute the deconvolution residuals .