Remap

Performs the look-up coordinate mapping of pixels of the source image.

Syntax

Case 1: Operation on pixel-order data

IppStatus ippiRemap_<mod>(const Ipp<datatype>* pSrc, IppiSize srcSize, int srcStep, IppiRect srcRoi, const Ipp32f* pxMap, int xMapStep, const Ipp32f* pyMap, int yMapStep, Ipp<datatype>* pDst, int dstStep, IppiSize dstRoiSize, int interpolation);

Supported values for mod:

8u_C1R

16u_C1R

16s_C1R

32f_C1R

64f_C1R

8u_C3R

16u_C3R

16s_C3R

32f_C3R

64f_C3R

8u_C4R

16u_C4R

16s_C4R

32f_C4R

64f_C4R

8u_AC4R

16u_AC4R

16s_AC4R

32f_AC4R

64f_AC4R

Case 2: Operation on planar-order data

IppStatus ippiRemap_<mod>(const Ipp<datatype>* const pSrc[3], IppiSize srcSize, int srcStep, IppiRect srcRoi, const Ipp32f* pxMap, int xMapStep, const Ipp32f* pyMap, int yMapStep, Ipp<datatype>* const pDst[3], int dstStep, IppiSize dstRoiSize, int interpolation);

Supported values for mod:

8u_P3R

16u_P3R

16s_P3R

32f_P3R

64f_P3R

IppStatus ippiRemap_<mod>(const Ipp<datatype>* const pSrc[4], IppiSize srcSize, int srcStep, IppiRect srcRoi, const Ipp32f* pxMap, int xMapStep, const Ipp32f* pyMap, int yMapStep, Ipp<datatype>* const pDst[4], int dstStep, IppiSize dstRoiSize, int interpolation);

Supported values for mod:

8u_P4R

16u_P4R

16s_P4R

32f_P4R

64f_P4R

Parameters

pSrc

Pointer to the source image origin. An array of separate pointers to each plane in case of data in planar format.

srcSize

Size in pixels of the source image.

srcStep

Distance in bytes between starts of consecutive lines in the source image buffer.

srcRoi

Region of interest in the source image (of the IppiRect type).

pxMap, pyMap

Pointers to the starts of 2D buffers, containing tables of the x- and y-coordinates.

xMapStep, yMapStep

Steps in bytes through the buffers containing tables of the x- and y-coordinates.

pDst

Pointer to the destination image ROI. An array of separate pointers to ROI in each plane for planar image.

dstStep

Distance in bytes between starts of consecutive lines in the destination image buffer.

dstRoiSize

Size of the destination ROI in pixels.

interpolation

Specifies the interpolation mode. Possible values are:

IPPI_INTER_NN - nearest neighbor interpolation

IPPI_INTER_LINEAR - linear interpolation

IPPI_INTER_CUBIC - cubic interpolation

IPPI_INTER_LANCZOS - interpolation with Lanczos window

IPPI_INTER_CUBIC2P_CATMULLROM - Catmull-Rom spline

the following flag is used additionally to the above modes:

IPPI_SMOOTH_EDGE - edge smoothing

Description

The function ippiRemap is declared in the ippi.h file. It operates with ROI (see ROI Processing in Geometric Transforms).

This function transforms the source image by remapping its pixels. Pixel remapping is performed using pxMap and pyMap buffers to look-up the coordinates of the source image pixel that is written to the target destination image pixel. The application has to supply these look-up tables. The remapping of the source pixels to the destination pixels is made according to the following formula:

dst_pixel[i, j]= src_pixel[pxMap[i, j], pyMap[i, j]]

where i,j are the x- and y-coordinates of the target destination image pixel dst_pixel;

pxMap[i, j] contains the x- coordinates of the source image pixels src_pixel that are written to dst_pixel;

pyMap[i, j] contains the y- coordinates of the source image pixels src_pixel that are written to dst_pixel.

If the referenced coordinates correspond to a pixel outside of the source ROI, and the flag IPPI_SMOOTH_EDGE is not set, then no mapping of the source pixel is performed.

Figure “Remapping the Sample Image” gives an example of applying the function ippiRemap to a sample image that is a square grid of alternating blue, red, and green lines.

Remapping the Sample Image

The transformed part of the image is resampled using the interpolation method specified by the interpolation parameter, and is written to the destination image ROI. The function can be used with or without edge smoothing. The pseudo code below shows how it works.

The function works without edge smoothing - the flag IPPI_SMOOTH_EDGE is not set:

if ( xMap < srcRoi . x || xMap > srcRoi . x + srcRoi . width -1 || yMap < srcRoi . y || yMap > srcRoi . y + srcRoi . height -1)

  not fill dst   /* do not remap */

else

  fill dst with Interpolate(Src, xMap, yMap)   /* remap */

The function works with edge smoothing - the flag IPPI_SMOOTH_EDGE is set:

if (xMap < srcRoi.x - 1 || xMap > srcRoi.x+srcRoi.width || yMap < srcRoi.y - 1 || yMap > srcRoi.y+srcRoi.height)

  not fill dst   /* do not remap */

else if (xMap < srcRoi.x || xMap > srcRoi.x+srcRoi.width-1 || yMap < srcRoi.y || yMap > srcRoi.y+srcRoi.height-1)

   fill dst with Interpolate(Src, fillvalue, xMap, yMap)    /* smoothing */

else

  fill dst with Interpolate(Src, xMap, yMap)   /* remap */

Example “Using the function ippiRemap” shows how to use the function ippiRemap_8u_C1R.

Return Values

ippStsNoErr

Indicates no error. Any other value indicates an error or a warning.

ippStsNullPtrErr

Indicates an error condition if one of the specified pointers is NULL.

ippStsSizeErr

Indicates an error condition if srcSize or dstRoiSize has a field with zero or negative value.

ippStsStepErr

Indicates an error condition if one of the srcStep, dstStep, xMapStep, or yMapStep has a zero or negative value.

ippStsInterpolationErr

Indicates an error condition if interpolation has an illegal value.

ippStsWrongIntersectROIErr

Indicates an error condition if srcRoi has no intersection with the source image.

Using the function ippiRemap

IppiSize size = { 4, 4 };
IppiRect srcRect = { 0, 0, 4, 4 };
Ipp8u src[4*4] = {0, 1, 2, 3, 
      4, 5, 6, 7,
      8, 9, 0, 1,
      2, 3, 4, 5};
Ipp8u dst[4*4];
Ipp32f pxMap[16] = {0, 1, 2, 3,
  0, 1, 2, 0,
  0, 1, 0, 0,
  0, 1, 2, 3};
 
Ipp32f pyMap[16] = {0, 0, 0, 0,
  1, 1, 1, 0,
  2, 2, 0, 0,
  3, 3, 3, 3};   // some order of pixels coordinates to write 
		
ippiRemap_8u_C1R ( src, size, 4, srcRect, pxMap, 16, pyMap, 16, dst, 4,
                   size, IPPI_INTER_NN);
 
Result:
0 1 2 3
4 5 6 7
8 9 0 1     src
2 3 4 5
 
0 1 2 3
4 5 6 0
8 9 0 0    dst
2 3 4 5
 

Submit feedback on this help topic

Copyright © 2000 - 2011, Intel Corporation. All rights reserved.