Image Interpolation with Geometric Contour Stencils
|
Contour stencil interpolation. More...
#include "sset.h"
Go to the source code of this file.
Typedefs | |
typedef struct sinterpstruct | sinterp |
Functions | |
sinterp * | NewSInterp (const sset *StencilSet, float RhoSigmaTangent, float RhoSigmaNormal) |
Create a new sinterp object. More... | |
void | FreeSInterp (sinterp *SInterp) |
Free an sinterp object. More... | |
float * | ComputeRhoSamples (const sinterp *SInterp, int ScaleFactor, int CenteredGrid) |
Precompute samples of for an integer scale 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... | |
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 | 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... | |
Contour stencil interpolation.
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.h.
typedef struct sinterpstruct sinterp |
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
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 .