Tutorial

Rotating an Image Using Intel IPP Warp Functions

Starting with the 9.0 version, Intel IPP enables you to use the
ippiWarpAffine<Interpolation>
functions to implement rotation of an image using pre-calculated affine coefficients based on rotation parameters (angle,
x
-,
y
-shifts ). To obtain affine coefficients for the specified rotation parameters, you can apply the
ippiGetRotateTransform
function. This function computes the affine coefficients for the transform that rotates an image by the specified angle around (0, 0) and shifts the image by the specified
x-
and
y-
shift values.
You can apply the computed bounding box to change the
x
-,
y
-shifts of the rotated image to fit the transformed image to the destination ROI. To compute the bounding box for the affine transform, use the
ippiGetAffineBound
function.
Before calling the warp affine processing function, you need to:
  • Compute the size of the specification structure for affine warping with the specified interpolation method using the
    ippiWarpAffineGetSize
    function
  • Initialize the specification structure using the
    ippiWarpAffine<Interpolation>Init
    function
  • Compute the size of the temporary work buffer required for warping using
    ippiWarpAffineGetSize
    and pass pointer to the buffer to the processing function
The code example below demonstrates how to perform image rotation using the Intel IPP affine warping functions:
IppStatus warpAffine(Ipp8u* pSrc, IppiSize srcSize, int srcStep, Ipp8u* pDst, IppiSize dstSize, int dstStep, const double coeffs[2][3]) { int specSize = 0, initSize = 0, bufSize = 0; Ipp8u* pBuffer = NULL; const Ipp32u numChannels = 3; IppiPoint dstOffset = {0, 0}; IppiBorderType borderType = ippBorderConst; IppiWarpDirection direction = ippWarpForward; Ipp64f pBorderValue[numChannels]; IppiWarpSpec* pSpec = NULL; IppStatus status = ippStsNoErr; for (int i = 0; i < numChannels; ++i) pBorderValue[i] = 255.0; /* Spec and init buffer sizes */ status = ippiWarpAffineGetSize(srcSize, dstSize, ipp8u, coeffs, ippLinear, direction, borderType, &specSize, &initSize); /* Allocate memory */ pSpec = (IppiWarpSpec*)ippsMalloc_8u(specSize); /* Affine transform data initialization */ if (status >= ippStsNoErr) status = ippiWarpAffineLinearInit(srcSize, dstSize, ipp8u, coeffs, direction, numChannels, borderType, pBorderValue, 0, pSpec); /* Get work buffer size */ if (status >= ippStsNoErr) status = ippiWarpGetBufferSize(pSpec, dstSize, &bufSize); pBuffer = ippsMalloc_8u(bufSize); /* Affine transform processing */ if (status >= ippStsNoErr) status = ippiWarpAffineLinear_8u_C3R(pSrc, srcStep, pDst, dstStep, dstOffset, dstSize, pSpec, pBuffer); /* Free memory */ ippsFree(pSpec); ippsFree(pBuffer); return status; }
For more information about the Intel IPP Warp functions, refer to the
Intel IPP Developer Reference
.

Product and Performance Information

1

Performance varies by use, configuration and other factors. Learn more at www.Intel.com/PerformanceIndex.