/*******************************************************************************
* Copyright 2015-2018 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 calculating eigen values and eigen vectors
// using Intel(R) Integrated Primitives (Intel(R) IPP) functions:
// ippiEigenValsVecsGetBufferSize_8u32f_C1R
// ippiEigenValsVecs_8u32f_C1R
#include <stdio.h>
#include "ipp.h"
/* 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;
Ipp8u pSrc[4 * 3] = /* Pointers to source images */
{ 2, 17, 2, 21,
9, 4, 11, 5,
2, 32, 7, 2 };
Ipp32f pEigenVV[24 * 3]; /* Image of eigen values and eigen vectors */
IppiSize roiSize = { 4, 3 };/* Size of source ROI in pixels */
int apertureSize = 3; /* Linear size of derivative filter aperture */
int avgWindow = 3; /* Linear size of averaging window */
int pBufferSize = 0; /* Pointer to work buffer */
Ipp8u* pBuffer = NULL;
/* Calculate size of temporary buffer */
check_sts( status = ippiEigenValsVecsGetBufferSize_8u32f_C1R(roiSize, apertureSize, avgWindow, &pBufferSize) )
pBuffer = ippsMalloc_8u(pBufferSize);
/* Calculate both eigen values and eigen vectors of 2x2 autocorrelation */
/* Gradient matrix for every pixel. */
check_sts( status = ippiEigenValsVecs_8u32f_C1R(pSrc, 4, pEigenVV, 24 * sizeof(Ipp32f), roiSize, ippKernelSobel, apertureSize, avgWindow, pBuffer) )
EXIT_MAIN
ippsFree(pBuffer);
printf("Exit status %d (%s)\n", (int)status, ippGetStatusString(status));
return (int)status;
}