Main Page | Modules | Class List | File List | Class Members | File Members

# Interpolation

## Enumerations
enum | CxImage::InterpolationMethod { CxImage::IM_NEAREST_NEIGHBOUR = 1, CxImage::IM_BILINEAR = 2, CxImage::IM_BSPLINE = 3, CxImage::IM_BICUBIC = 4, CxImage::IM_BICUBIC2 = 5, CxImage::IM_LANCZOS = 6, CxImage::IM_BOX = 7, CxImage::IM_HERMITE = 8, CxImage::IM_HAMMING = 9, CxImage::IM_SINC = 10, CxImage::IM_BLACKMAN = 11, CxImage::IM_BESSEL = 12, CxImage::IM_GAUSSIAN = 13, CxImage::IM_QUADRATIC = 14, CxImage::IM_MITCHELL = 15, CxImage::IM_CATROM = 16 }
enum | CxImage::OverflowMethod { CxImage::OM_COLOR = 1, CxImage::OM_BACKGROUND = 2, CxImage::OM_TRANSPARENT = 3, CxImage::OM_WRAP = 4, CxImage::OM_REPEAT = 5, CxImage::OM_MIRROR = 6 }
## Functions
RGBQUAD | CxImage::GetAreaColorInterpolated (float const xc, float const yc, float const w, float const h, InterpolationMethod const inMethod, OverflowMethod const ofMethod=OM_BACKGROUND, RGBQUAD *const rplColor=0)
RGBQUAD | CxImage::GetPixelColorInterpolated (float x, float y, InterpolationMethod const inMethod=IM_BILINEAR, OverflowMethod const ofMethod=OM_BACKGROUND, RGBQUAD *const rplColor=0)
RGBQUAD | CxImage::GetPixelColorWithOverflow (long x, long y, OverflowMethod const ofMethod=OM_BACKGROUND, RGBQUAD *const rplColor=0)
void | CxImage::OverflowCoordinates (long &x, long &y, OverflowMethod const ofMethod)
void | CxImage::OverflowCoordinates (float &x, float &y, OverflowMethod const ofMethod)

## Enumeration Type Documentation

enum CxImage::InterpolationMethod`[inherited]`

  | Enumeration values:
  IM_NEAREST_NEIGHBOUR |
  IM_BILINEAR |
  IM_BSPLINE |
  IM_BICUBIC |
  IM_BICUBIC2 |
  IM_LANCZOS |
  IM_BOX |
  IM_HERMITE |
  IM_HAMMING |
  IM_SINC |
  IM_BLACKMAN |
  IM_BESSEL |
  IM_GAUSSIAN |
  IM_QUADRATIC |
  IM_MITCHELL |
  IM_CATROM |

enum CxImage::OverflowMethod`[inherited]`

  | Enumeration values:
  OM_COLOR |
  OM_BACKGROUND |
  OM_TRANSPARENT |
  OM_WRAP |
  OM_REPEAT |
  OM_MIRROR |

## Function Documentation

RGBQUAD CxImage::GetAreaColorInterpolated | ( | float const | xc,
|  | float const | yc,
|  | float const | w,
|  | float const | h,
|  | InterpolationMethod const | inMethod,
|  | OverflowMethod const | ofMethod = `OM_BACKGROUND`,
|  | RGBQUAD *const | rplColor = `0`
| ) | `[inherited]`

  | This method is similar to GetPixelColorInterpolated, but this method also properly handles subsampling. If you need to sample original image with interval of more than 1 pixel (as when shrinking an image), you should use this method instead of GetPixelColorInterpolated or aliasing will occur. When area width and height are both less than pixel, this method gets pixel color by interpolating color of frame center with selected (inMethod) interpolation by calling GetPixelColorInterpolated. If width and height are more than 1, method calculates color by averaging color of pixels within area. Interpolation method is not used in this case. Pixel color is interpolated by averaging instead. If only one of both is more than 1, method uses combination of interpolation and averaging. Chosen interpolation method is used, but since it is averaged later on, there is little difference between IM_BILINEAR (perhaps best for this case) and better methods. IM_NEAREST_NEIGHBOUR again leads to aliasing artifacts. This method is a bit slower than GetPixelColorInterpolated and when aliasing is not a problem, you should simply use the later. Parameters:
  | xc,yc | - center of (rectangular) area
  | w,h | - width and height of area
  | inMethod | - interpolation method that is used, when interpolation is used (see above)
  | ofMethod | - overflow method used when retrieving individual pixel colors
  | rplColor | - replacement colour to use, in OM_COLOR
Author: ***bd*** 2.2004

RGBQUAD CxImage::GetPixelColorInterpolated | ( | float | x,
|  | float | y,
|  | InterpolationMethod const | inMethod = `IM_BILINEAR`,
|  | OverflowMethod const | ofMethod = `OM_BACKGROUND`,
|  | RGBQUAD *const | rplColor = `0`
| ) | `[inherited]`

  | This method reconstructs image according to chosen interpolation method and then returns pixel (x,y). (x,y) can lie between actual image pixels. If (x,y) lies outside of image, method returns value according to overflow method. This method is very useful for geometrical image transformations, where destination pixel can often assume color value lying between source pixels. Parameters:
  | (x,y) | - coordinates of pixel to return GPCI method recreates "analogue" image back from digital data, so x and y are float values and color value of point (1.1,1) will generally not be same as (1,1). Center of first pixel is at (0,0) and center of pixel right to it is (1,0). (0.5,0) is half way between these two pixels.
  | inMethod | - interpolation (reconstruction) method (kernel) to use: IM_NEAREST_NEIGHBOUR - returns colour of nearest lying pixel (causes stairy look of processed images) IM_BILINEAR - interpolates colour from four neighbouring pixels (softens image a bit) IM_BICUBIC - interpolates from 16 neighbouring pixels (can produce "halo" artifacts) IM_BICUBIC2 - interpolates from 16 neighbouring pixels (perhaps a bit less halo artifacts than IM_BICUBIC) IM_BSPLINE - interpolates from 16 neighbouring pixels (softens image, washes colours) (As far as I know, image should be prefiltered for this method to give good results... some other time :) ) This method uses bicubic interpolation kernel from CXImage 5.99a and older versions. IM_LANCZOS - interpolates from 12*12 pixels (slow, ringing artifacts)
  | ofMethod | - overflow method (see comments at GetPixelColorWithOverflow)
  | rplColor | - pointer to color used for out of borders pixels in OM_COLOR mode (and other modes if colour can't calculated in a specified way)
Returns: interpolated color value (including interpolated alpha value, if image has alpha layer) Author: ***bd*** 2.2004

RGBQUAD CxImage::GetPixelColorWithOverflow | ( | long | x,
|  | long | y,
|  | OverflowMethod const | ofMethod = `OM_BACKGROUND`,
|  | RGBQUAD *const | rplColor = `0`
| ) | `[inherited]`

  | Method return pixel color. Different methods are implemented for out of bounds pixels. If an image has alpha channel, alpha value is returned in .RGBReserved. Parameters:
  | x,y | : pixel coordinates
  | ofMethod | : out-of-bounds method: OF_WRAP - wrap over to pixels on other side of the image OF_REPEAT - repeat last pixel on the edge OF_COLOR - return input value of color OF_BACKGROUND - return background color (if not set, return input color) OF_TRANSPARENT - return transparent pixel
  | rplColor | : input color (returned for out-of-bound coordinates in OF_COLOR mode and if other mode is not applicable)
Returns: color : color of pixel Author: ***bd*** 2.2004

void CxImage::OverflowCoordinates | ( | long & | x,
|  | long & | y,
|  | OverflowMethod const | ofMethod
| ) | `[inherited]`

  | Recalculates coordinates according to specified overflow method. If pixel (x,y) lies within image, nothing changes. Parameters:
  | x,y | - coordinates of pixel
  | ofMethod | - overflow method
Returns: x, y - new coordinates (pixel (x,y) now lies inside image) Author: ***bd*** 2.2004

void CxImage::OverflowCoordinates | ( | float & | x,
|  | float & | y,
|  | OverflowMethod const | ofMethod
| ) | `[inherited]`

| See OverflowCoordinates for integer version Author: ***bd*** 2.2004