Intel® Integrated Performance Primitives (Intel® IPP) Developer Guide and Reference

ID 790148
Date 3/22/2024
Public
Document Table of Contents

GetRotateTransform

Computes the affine coefficients for the rotation transform.

Syntax

IppStatus ippiGetRotateTransform(double angle, double xShift, double yShift, double coeffs[2][3]);

Include Files

ippi.h

Flavors with the _L suffix: ippi_l.h

Domain Dependencies

Headers: ippcore.h, ippvm.h, ipps.h

Libraries: ippcore.lib, ippvm.lib, ipps.lib

Parameters

angle

Angle of rotation, in degrees. The source image is rotated counterclockwise around the origin (0, 0).

xShift, yShift

Shift along horizontal (x) or vertical (y) axis that is performed after rotation.

coeffs

Computed affine transform coefficients for the given rotation parameters.

Description

This function computes the coefficients for the affine transform that rotates an image by the specified angle around the origin (0, 0) and shifts the image after rotation. The result is stored in the coeffs parameter.

Return Values

ippStsNoErr

Indicates no error. Any other value indicates an error.

ippStsSizeErr

Indicates an error when one of the coeffs values is NULL.

ippStsOutOfRangeErr

Indicates an error when angle is not-a-number (NaN) or infinity.

Example

/*******************************************************************************
* Copyright 2015 Intel Corporation.
*
*
* This software and the related documents are Intel copyrighted materials, and your use of them is governed by
* the express license under which they were provided to you ('License'). Unless the License provides otherwise,
* you may not use, modify, copy, publish, distribute, disclose or transmit this software or the related
* documents without Intel's prior written permission.
* This software and the related documents are provided as is, with no express or implied warranties, other than
* those that are expressly stated in the License.
*******************************************************************************/

// A simple example of computing the affine coefficients for the transform
// that rotates an image using Intel(R) Integrated Performance Primitives (Intel(R) IPP) functions:
//     ippiGetRotateTransform
//     ippiWarpAffineLinearInit
//     ippiWarpGetBufferSize
//     ippiWarpAffineLinear_8u_C3R


#include <stdio.h>
#include "ipp.h"

#define WIDTH   64  /* source image width */
#define HEIGHT  64  /* source image height */
#define NUM_CHN  3

/* Next two defines are created to simplify code reading and understanding */
#define EXIT_MAIN exitLine:                                  /* Label for Exit */
#define check_sts(st) if((st) != ippStsNoErr) goto exitLine; /* Go to Exit if Intel(R) IPP function returned status different from ippStsNoErr */

/* Results of ippMalloc() are not validated because Intel(R) IPP functions perform bad arguments check and will return an appropriate status  */

int main(void)
{
    IppStatus status = ippStsNoErr;
    IppiWarpSpec* pSpec = NULL; /* Pointer to the specification structure */
    IppiSize srcSize = { WIDTH, HEIGHT }, dstSize = { WIDTH, HEIGHT }; /* Size of source/destination images */
    int srcStep, dstStep; /* Steps, in bytes, through the source/destination images */
    Ipp8u* pSrc = NULL, *pDst = NULL;   /* Pointers to source/destination images */
    double angle = 30., xShift = 2., yShift = 1.;
    double coeffs[2][3] = {0};
    IppiPoint dstOffset = { 0, 0 }; /* Offset of the destination image ROI with respect to the destination image origin */
    int specSize = 0, initSize = 0, bufSize = 0; /* Work buffer size */
    Ipp8u* pBuffer = NULL;
    IppiBorderType   borderType = ippBorderConst;
    IppiWarpDirection direction = ippWarpForward; /* Transformation direction */
    Ipp64f pBorderValue[NUM_CHN] = {0};

    pSrc = ippiMalloc_8u_C3(srcSize.width, srcSize.height, &srcStep);
    pDst = ippiMalloc_8u_C3(dstSize.width, dstSize.height, &dstStep);

    check_sts( status = ippiGetRotateTransform(angle, xShift, yShift, (double(*)[3])coeffs) )

    /* Spec and init buffer sizes */
    check_sts( status = ippiWarpAffineGetSize(srcSize, dstSize, ipp8u, coeffs, ippLinear, direction, borderType, &specSize, &initSize) )

    pSpec = (IppiWarpSpec*)ippsMalloc_8u(specSize);

    /* Filter initialization */
    check_sts( status = ippiWarpAffineLinearInit(srcSize, dstSize, ipp8u, coeffs, direction, NUM_CHN, borderType, pBorderValue, 0, pSpec) )

    /* Get work buffer size */
    check_sts( status = ippiWarpGetBufferSize(pSpec, dstSize, &bufSize) )

    pBuffer = ippsMalloc_8u(bufSize);

    /* WarpAffine processing */
    check_sts( status = ippiWarpAffineLinear_8u_C3R(pSrc, srcStep, pDst, dstStep, dstOffset, dstSize, pSpec, pBuffer) )

EXIT_MAIN
    ippiFree(pSrc);
    ippiFree(pDst);
    ippsFree(pBuffer);
    ippsFree(  pSpec);
    printf("Exit status %d (%s)\n", (int)status, ippGetStatusString(status));
    return (int)status;
}