Specifications

Geometric Transforms
11-29
11
Discussion
The function iplRemap() maps the image
srcImage
to
dstImage
using a
coordinate table supplied by the application in the images
xMap
and
yMap
.
To each pixel in the destination image
dstImage
, the function assigns the
value taken from the point (x,y) in the source image; the coordinates x and
y are retrieved from the locations in
xMap
and
yMap
corresponding to the
destination pixel.
Your application has to compute the floating-point coordinates and store
them in
xMap
and
yMap
prior to calling iplRemap(); see Example 11-2.
Data order and bit depth of
srcImage
and
dstImage
must be the same.
The function supports source and destination images with 1-bit, 8-bit
unsigned, and 16-bit unsigned pixel channels. ROIs and tiling of
srcImage
and
dstImage
are supported. Mask is not directly supported. For masking
some of the image pixels, you can just specify the corresponding x and y
values that are outside the source image’s ROI.
Example 11-4 Re-mapping an Image
int example_remap( void ) {
const int width = 8, height = 8;
int x, y; float norm;
/// source and destination images: 8u
IplImage *src = iplCreateImageJaehne(IPL_DEPTH_8U,
width,height);
IplImage *dst = iplCreateImageHeader (
1, 0, IPL_DEPTH_8U, "GRAY", "GRAY",
IPL_DATA_ORDER_PIXEL, IPL_ORIGIN_TL,
IPL_ALIGN_DWORD, width, height, NULL,
NULL, NULL, NULL );
/// create images for x and y coordinates
IplImage *xmap = iplCreateImageJaehne(IPL_DEPTH_32F,
width, height);
IplImage *ymap = iplCloneImage( xmap );
continued