Main Page | Modules | Alphabetical List | Class List | Directories | Class Members

Images functionalities that need resampling


Defines

#define CPL_OPERATION   CPL_IMAGE_WARP_POLYNOMIAL
 Warp an image according to a 2d polynomial transformation.
#define CPL_OPERATION   CPL_IMAGE_RESAMPLE_SUBSAMPLE
 Warp an image according to a 2d polynomial transformation.

Functions

cpl_image * cpl_image_extract_subsample (const cpl_image *image, int llx, int lly, int urx, int ury, int xstep, int ystep)
 Sub-sample an image.
double cpl_image_get_interpolated (const cpl_image *source, double xpos, double ypos, const cpl_vector *xprofile, double xradius, const cpl_vector *yprofile, double yradius, double *pconfid)
 Interpolate a pixel.

Detailed Description

This module provides functions to warp, shift or rotate images.

Synopsis:
   #include "cpl_image_resample.h"

Define Documentation

#define CPL_OPERATION   CPL_IMAGE_RESAMPLE_SUBSAMPLE
 

Warp an image according to a 2d polynomial transformation.

Parameters:
out Pre-allocated image to hold the result
in Image to warp.
poly_u 2D Polynomial transform in U.
poly_v 2D Polynomial transform in V.
xprofile Interpolation weight as a function of the distance in X
xradius Positive inclusion radius in the X-dimension
yprofile Interpolation weight as a function of the distance in Y
yradius Positive inclusion radius in the Y-dimension
Returns:
CPL_ERROR_NONE or the relevant _cpl_error_code_ on error
See also:
cpl_image_get_interpolated()
Warp an image according to a polynomial transform. Provide two 2d cpl_polynomial poly_u and poly_v such as:

  x = cpl_polynomial_eval(pu, (u, v))
  y = cpl_polynomial_eval(pv, (u, v))
  

Attention! The polynomials define a reverse transform. (u,v) are coordinates in the warped image and (x,y) are coordinates in the original image. The transform you provide is used to compute from the warped image, which pixels contributed in the original image.

FIXME: Flux-calibration is missing. FIXME: Not thoroughly tested.

Beware that extreme transformations may lead to blank images.

The input image type can be CPL_TYPE_INT, CPL_TYPE_FLOAT and CPL_TYPE_DOUBLE.

The two images may have different dimensions and types.

Possible _cpl_error_code_ set in this function:

  • CPL_ERROR_NULL_INPUT if (one of) the input pointer(s) is NULL
  • CPL_ERROR_ILLEGAL_INPUT if the polynomial dimensions are not 2
  • CPL_ERROR_TYPE_MISMATCH if the passed image type is not supported

#define CPL_OPERATION   CPL_IMAGE_WARP_POLYNOMIAL
 

Warp an image according to a 2d polynomial transformation.

Parameters:
out Pre-allocated image to hold the result
in Image to warp.
poly_u 2D Polynomial transform in U.
poly_v 2D Polynomial transform in V.
xprofile Interpolation weight as a function of the distance in X
xradius Positive inclusion radius in the X-dimension
yprofile Interpolation weight as a function of the distance in Y
yradius Positive inclusion radius in the Y-dimension
Returns:
CPL_ERROR_NONE or the relevant _cpl_error_code_ on error
See also:
cpl_image_get_interpolated()
Warp an image according to a polynomial transform. Provide two 2d cpl_polynomial poly_u and poly_v such as:

  x = cpl_polynomial_eval(pu, (u, v))
  y = cpl_polynomial_eval(pv, (u, v))
  

Attention! The polynomials define a reverse transform. (u,v) are coordinates in the warped image and (x,y) are coordinates in the original image. The transform you provide is used to compute from the warped image, which pixels contributed in the original image.

FIXME: Flux-calibration is missing. FIXME: Not thoroughly tested.

Beware that extreme transformations may lead to blank images.

The input image type can be CPL_TYPE_INT, CPL_TYPE_FLOAT and CPL_TYPE_DOUBLE.

The two images may have different dimensions and types.

Possible _cpl_error_code_ set in this function:

  • CPL_ERROR_NULL_INPUT if (one of) the input pointer(s) is NULL
  • CPL_ERROR_ILLEGAL_INPUT if the polynomial dimensions are not 2
  • CPL_ERROR_TYPE_MISMATCH if the passed image type is not supported


Function Documentation

cpl_image* cpl_image_extract_subsample const cpl_image *  image,
int  llx,
int  lly,
int  urx,
int  ury,
int  xstep,
int  ystep
 

Sub-sample an image.

Parameters:
image The image to subsample
llx lower left x coord of 1st pixel to use
lly lower left y coord of 1st pixel to use
urx upper right x coord of last pixel to use
ury upper right y coord of last pixel to use
xstep Take every xstep pixel in x
ystep Take every ystep pixel in y
Returns:
The newly allocated sub-sampled image or NULL in error case
See also:
cpl_image_extract
xstep and ystep shall be positive.

Currently xstep must equal ystep. Currently both llx and lly must equal 1. Currently both urx and ury must equal the X- and Y-size of the image.

step represents the sampling step in x and y: a step of 2 will create an image with a qaurter of the pixels of the input image.

Currently, both the X- and Y-size of the image must be divisible by the step.

image type can be CPL_TYPE_INT, CPL_TYPE_FLOAT and CPL_TYPE_DOUBLE.

The returned image must be deallocated using cpl_image_delete().

Possible _cpl_error_code_ set in this function:

  • CPL_ERROR_NULL_INPUT if (one of) the input pointer(s) is NULL
  • CPL_ERROR_ILLEGAL_INPUT if llx, lly, urx, ury, xstep, ystep are not as requested
  • CPL_ERROR_TYPE_MISMATCH if the passed image type is not supported

double cpl_image_get_interpolated const cpl_image *  source,
double  xpos,
double  ypos,
const cpl_vector *  xprofile,
double  xradius,
const cpl_vector *  yprofile,
double  yradius,
double *  pconfid
 

Interpolate a pixel.

Parameters:
source Interpolation source
xpos Pixel x floating-point position (FITS convention)
ypos Pixel y floating-point position (FITS convention)
xprofile Interpolation weight as a function of the distance in X
xradius Positive inclusion radius in the X-dimension
yprofile Interpolation weight as a function of the distance in Y
yradius Positive inclusion radius in the Y-dimension
pconfid Confidence level of the interpolated value (range 0 to 1)
Returns:
The interpolated pixel value, or undefined on error
See also:
cpl_image_get()
If the X- and Y-radii are identical the area of inclusion is a circle, otherwise it is an ellipse, with the larger of the two radii as the semimajor axis and the other as the semiminor axis.

The radii are only required to be positive. However, for small radii, especially radii less than 1/sqrt(2), (xpos, ypos) may be located such that no source pixels are included in the interpolation, causing the interpolated pixel value to be undefined.

The X- and Y-profiles can be generated with cpl_vector_fill_kernel_profile(profile, radius). For profiles generated with cpl_vector_fill_kernel_profile() it is important to use the same radius both there and in cpl_image_get_interpolated().

A good profile length is CPL_KERNEL_DEF_SAMPLES, using radius CPL_KERNEL_DEF_WIDTH.

On error *pconfid is negative (unless pconfid is NULL). Otherwise, if *pconfid is zero, the interpolated pixel-value is undefined. Otherwise, if *pconfid is less than 1, the area of inclusion is close to the image border or contains rejected pixels.

The input image type can be CPL_TYPE_INT, CPL_TYPE_FLOAT and CPL_TYPE_DOUBLE.

Here is an example of a simple image unwarping (with error-checking omitted for brevity):

const double xyradius = CPL_KERNEL_DEF_WIDTH;

cpl_vector * xyprofile = cpl_vector_new(CPL_KERNEL_DEF_SAMPLES); cpl_image * unwarped = cpl_image_new(nx, ny, CPL_TYPE_DOUBLE);

cpl_vector_fill_kernel_profile(xyprofile, CPL_KERNEL_DEFAULT, xyradius);

for (iu = 1; iu <= nx; iu++) { for (iv = 1; iv <= ny; iv++) { double confidence; const double x = my_unwarped_x(); const double y = my_unwarped_y();

const double value = cpl_image_get_interpolated(warped, x, y, xyprofile, xyradius, xyprofile, xyradius, &confidence);

if (confidence > 0) cpl_image_set(unwarped, iu, iv, value); else cpl_image_reject(unwarped, iu, iv); } }

cpl_vector_delete(xyprofile);

Possible _cpl_error_code_ set in this function:

  • CPL_ERROR_NULL_INPUT if (one of) the input pointer(s) is NULL
  • CPL_ERROR_ILLEGAL_INPUT if xradius, xprofile, yprofile and yradius are not as requested
  • CPL_ERROR_TYPE_MISMATCH if the passed image type is not supported


Generated on Mon Sep 26 14:38:17 2005 for Common Pipeline Library Reference Manual by  doxygen 1.4.1