This package is a C++ implementation of factor-2 contour stencil interpolation, a fast edge-adaptive image interpolation method. The implementation follows the fast algorithm described in section 3.3 of
P. Getreuer, “Contour stencils for edge-adaptive image interpolation.” Proc. SPIE, vol. 7257, 2009.
Compilation requires the libpng and zlib libraries, freely available at www.libpng.org. The libpng library is used by the CImage class (image.cpp and image.h) for reading and writing PNG files. The interpolation code itself (c2xinterp.cpp) does not depend on any libraries.
A makefile is included for compilation with GCC. Type “make” to compile.
Compilation produces a simple command-line interface program c2xinterp. The program takes two arguments, an input PNG file and an output PNG file.
Syntax: c2xinterp in.png [out.png]
If no output file is specified, the result is written to “out.png.”
The interpolation code itself is in c2xinterp.cpp, and the interpolation function is C2xInterp_RGBA:
void C2xInterp_RGBA(const uint32_t *wpSrc,
int iSrcWidth, int iSrcHeight, int iSrcStride,
uint32_t *wpDest, int iDestStride)
C2xInterp_RGBA interpolates an RGBA color image by factor 2. The arguments are
wpSrc | Pointer to the source image data in RGBA format |
iSrcWidth | Source width in pixels |
iSrcHeight | Source height in pixels |
iSrcStride | Souce stride between successive scanlines |
wpDest | Pointer to where to store the interpolated image |
iDestStride | Destination stride |
In detail, wpSrc points to a buffer of size at least iSrcHeight×iSrcStride, where each element represents one 32-bit RGBA pixel. Similarly, wpDest points to a buffer with size at least 2×iSrcHeight×iDestStride of RGBA pixels.
The stride (or pitch) is the distance in memory between a given pixel and the pixel below in the next scanline, counted in 32-bit words. If there is no excess memory between the end of one scanline and the beginning of the next, the stride is simply the image width,
iStrStride = iSrcWidth,
iDestStride = 2*iSrcWidth.
Using other stride values enables for example interpolating a rectangular subregion of an image.