|
Image Interpolation with Geometric Contour Stencils
|
Contour stencil set construction. More...

Go to the source code of this file.
Data Structures | |
| struct | stencilentry |
A single contour stencil . More... | |
| struct | stencilsetcell |
A cell in a contour stencil, . More... | |
| struct | stencilqvec |
| Quantized vector. More... | |
| struct | ssetstruct |
A contour stencil set . More... | |
Macros | |
| #define | NUMANGLES 64 |
| The angular resolution for stencil quantization. More... | |
| #define | QUAD_RES 8 |
| Number of quadrature panels to use for integrals. More... | |
| #define | INITIAL_CAPACITY 16 |
| Initial capacity of a stencil set. More... | |
| #define | STABILITY_THRESH 1e-4 |
| Stability threshold. More... | |
Typedefs | |
| typedef struct ssetstruct | ssettype |
A contour stencil set . More... | |
Functions | |
| void | FreeStencilSet (sset *Set) |
| Free a stencil set. More... | |
| sset * | NewStencilSet (double StencilRadius, double(*Psf)(double, double, const void *), const void *PsfParam, double PsfRadius) |
| Create a new stencil set. More... | |
| int | GetNumStencils (const sset *Set) |
| Get the number of stencils in a stencil set. More... | |
| const void * | GetPsfParam (const sset *Set) |
| Get the PSF parameter pointer. More... | |
| double | GetPsfRadius (const sset *Set) |
| Get the support radius of the PSF. More... | |
| double | EvalPhi (const sset *Set, int S, double x, double y) |
Evaluate the associated with a stencil. More... | |
| int | AddStencil (sset *Set, double(*Phi)(double, double, const void *), const void *PhiParam, double Rotation, int(*DrawFun)(pen *Pen, const void *Param), const void *DrawParam, const float *DrawColor) |
| Add a stencil to a stencil set. More... | |
| int | StencilConfusion (double *ConfusionMatrix, sset *Set) |
| Compute the confusion matrix of a stencil set. More... | |
| int | PrintStencilConfusion (sset *Set) |
| Print stencil confusion information about a stencil set. More... | |
| void | FitStencils (int *Stencil, const sset *Set, const float *Image, int ImageWidth, int ImageHeight) |
| Determine the best-fitting stencil at each point in an image. More... | |
| int | DrawContours (const char *FileName, int OutputWidth, int OutputHeight, double ScaleFactor, const int *Stencil, const sset *Set, const float *Input, int InputWidth, int InputHeight) |
| Visualize the estimated contours. More... | |
| int | DrawContoursEps (const char *EpsFile, const int *Stencil, const sset *Set, const float *Input, int InputWidth, int InputHeight) |
| Visualize the estimated contours as an EPS image. More... | |
| int | DrawContoursSvg (const char *SvgFile, const char *BgFile, const int *Stencil, const sset *Set, const float *Input, int InputWidth, int InputHeight) |
| Visualize the estimated contours as an SVG image. More... | |
Variables | |
| double(*)(double, double, const void *) | GetPsf (const sset *Set) |
| Get the PSF. More... | |
Contour stencil set construction.
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 sset.c.
| #define INITIAL_CAPACITY 16 |
| #define NUMANGLES 64 |
| #define QUAD_RES 8 |
| typedef struct ssetstruct ssettype |
A contour stencil set
.
A stencil set is a collection of contour stencils. This is represented as an array ssetstruct::Stencil of type stencilentry. For computational efficiency, an array of quantized stencil vectors stencilqvec is also stored in ssetstruct::StencilTable. The locations of the cells are stored in stencilsetcell::Cell. The point spread function (PSF) to model the sampling of the input image is specified by ssetstruct::Psf.
ssetstruct is the definition of sset, which is encapsulated by forward declaration in sset.h.
Stencil sets are managed with the following functions:
| int AddStencil | ( | sset * | Set, |
| double(*)(double, double, const void *) | Phi, | ||
| const void * | PhiParam, | ||
| double | Rotation, | ||
| int(*)(pen *Pen, const void *Param) | DrawFun, | ||
| const void * | DrawParam, | ||
| const float * | DrawColor | ||
| ) |
Add a stencil to a stencil set.
| Set | the stencil set |
| Phi | the distance function from which to derive the stencil |
| PhiParam | parameters for the distance function |
| Rotation | rotation of the stencil |
| DrawFun | function that draws the stencil |
| DrawParam | parameter for DrawFun |
| DrawColor | RGB color for drawing the stencil |
| int DrawContours | ( | const char * | FileName, |
| int | OutputWidth, | ||
| int | OutputHeight, | ||
| double | ScaleFactor, | ||
| const int * | Stencil, | ||
| const sset * | Set, | ||
| const float * | Input, | ||
| int | InputWidth, | ||
| int | InputHeight | ||
| ) |
Visualize the estimated contours.
| Output | output image |
| OutputWidth,OutputHeight | dimensions of the output image |
| ScaleFactor | scale factor between input and output images |
| Stencil | best-fitting stencils |
| Set | the stencil set |
| Input | input image |
| InputWidth,InputHeight | dimensions of the input image |
Renders a visualization of the estimated contours to the output image. A nearest neighbor interpolation of the input image is created where the colors are darkened and converted to grayscale. For each pixel, the best-fitting stencil is drawn by calling the stencil's stencilentry::DrawFun.
| int DrawContoursEps | ( | const char * | EpsFile, |
| const int * | Stencil, | ||
| const sset * | Set, | ||
| const float * | Input, | ||
| int | InputWidth, | ||
| int | InputHeight | ||
| ) |
Visualize the estimated contours as an EPS image.
| EpsFile | output EPS file name |
| Stencil | best-fitting stencils |
| Set | the stencil set |
| Input | input image |
| InputWidth,InputHeight | dimensions of the input image |
Renders a visualization of the estimated contours as an EPS image. For each pixel, the best-fitting stencil is drawn by calling the stencil's stencilentry::DrawFun.
| int DrawContoursSvg | ( | const char * | SvgFile, |
| const char * | BgFile, | ||
| const int * | Stencil, | ||
| const sset * | Set, | ||
| const float * | Input, | ||
| int | InputWidth, | ||
| int | InputHeight | ||
| ) |
Visualize the estimated contours as an SVG image.
| SvgFile | output SVG file name |
| BgFile | output background image file name (PNG or JPEG) |
| Stencil | best-fitting stencils |
| Set | the stencil set |
| Input | input image |
| InputWidth,InputHeight | dimensions of the input image |
Renders a visualization of the estimated contours as an SVG image. For each pixel, the best-fitting stencil is drawn by calling the stencil's stencilentry::DrawFun.
| double EvalPhi | ( | const sset * | Set, |
| int | S, | ||
| double | x, | ||
| double | y | ||
| ) |
Evaluate the
associated with a stencil.
| Set | the stencil set |
| S | index of the stencil |
| x,y | location to evaluate |
Evaluate the distance function
associated with stencil S at (x,y). The stencil rotation from stencilentry::PhiTrans is applied.
| void FitStencils | ( | int * | Stencil, |
| const sset * | Set, | ||
| const float * | Image, | ||
| int | ImageWidth, | ||
| int | ImageHeight | ||
| ) |
Determine the best-fitting stencil at each point in an image.
| Stencil | the selected best-fitting stencils |
| Set | stencil set to use |
| Image | the input image |
| ImageWidth,ImageHeight | image dimensions |
This is the main routine for determining the best-fitting stencils on an image. The result is stored in Stencil, which should be an array of size ImageWidth by ImageHeight. For each pixel, the index of the best-fitting stencil is stored in Stencil.
For computational efficiency, the stencil fitting uses the quantized stencil vectors ssetstruct::StencilTable to approximate the cell total variations
First, the cell total variation are computed for each pixel at each angle 0, ..., NUMANGLES-1. Then then stencils are computed by summing the cell total variations. Finally, the stencil with the smallest total variation is identified as the best-fitting stencil,
If the difference between the smallest and second smallest total variations is below a threshold, the circle stencil is selected.
| void FreeStencilSet | ( | sset * | Set | ) |
| int GetNumStencils | ( | const sset * | Set | ) |
| const void* GetPsfParam | ( | const sset * | Set | ) |
| double GetPsfRadius | ( | const sset * | Set | ) |
| sset* NewStencilSet | ( | double | StencilRadius, |
| double(*)(double, double, const void *) | Psf, | ||
| const void * | PsfParam, | ||
| double | PsfRadius | ||
| ) |
| int PrintStencilConfusion | ( | sset * | Set | ) |
Print stencil confusion information about a stencil set.
| Set | the stencil set |
Prints information from the stencil confusion matrix computed by StencilConfusion().
| int StencilConfusion | ( | double * | ConfusionMatrix, |
| sset * | Set | ||
| ) |
Compute the confusion matrix of a stencil set.
| ConfusionMatrix | pointer to an array to hold the result |
| Set | the stencil set |
For each distance function
used in the stencil set, all stencil TVs are computed. The results are stored in column-major order in ConfusionMatrix as
The stencil associated with a distance function should have the lowest TV value, that is, the diagonal entries should be the smallest in each column. Small off-diagonal entries indicate stencils that are likely to be confused.
1.8.3.1