Developer Reference for Intel® Integrated Performance Primitives
Retrieves image Hu moment invariants computed by ippiMoments function.
IppStatus ippiGetHuMoments_64f(const IppiMomentState_64f* pState, int nChannel, IppiHuMoment_64f pHm);
ippi.h
Headers: ippcore.h, ippvm.h, ipps.h
Libraries: ippcore.lib, ippvm.lib, ipps.lib
pState |
Pointer to the structure that stores image moments. |
nChannel |
The channel for which the moment is returned. |
pHm |
Pointer to the array containing the Hu moment invariants. |
This function returns the pointer pHm to the array of seven Hu moment invariants previously computed by the ippiMoments function.
ippStsNoErr |
Indicates no error. Any other value indicates an error or a warning. |
ippStsNullPtrErr |
Indicates an error condition if pState or pHm pointer is NULL. |
ippStsContextMatchErr |
Indicates an error condition if a pointer to an invalid structure is passed. |
ippStsMoment00ZeroErr |
Indicates an error condition if M(0,0) value is close to zero. |
/*******************************************************************************
* 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 Hu moment values for images.
// implemented with Intel® Integrated Primitives (Intel® IPP) functions:
// ippiSet_8u_C1R
// ippiMomentGetStateSize_64f
// ippiMomentInit_64f
// ippiMoments64f_8u_C1R
// ippiGetHuMoments_64f
#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® IPP function returned status different from ippStsNoErr */
/* Results of ippMalloc() are not validated because Intel® IPP functions perform bad arguments check and will return an appropriate status */
int main(void)
{
IppStatus status = ippStsNoErr;
Ipp8u pSrc[64]; /* Pointer to source image */
IppiSize roiA={8,8}, roiH={8,1}, roiV={1,8}; /* Used image ROI sizes */
int sizeState = 0; /* State size */
IppiHuMoment_64f hmH = {0}, hmV= {0}; /* Horizontal and vertical moments */
IppiMomentState_64f *pState = NULL; /* Pointers to state structure */
check_sts( status = ippiMomentGetStateSize_64f(ippAlgHintNone, &sizeState) )
/* memory allocation */
pState = (IppiMomentState_64f*) ippMalloc( sizeState );
check_sts( status = ippiMomentInit_64f(pState, ippAlgHintNone) )
/* set horizontal edge */
check_sts( status = ippiSet_8u_C1R( 0, pSrc, 8, roiA ) )
check_sts( status = ippiSet_8u_C1R( 3, pSrc, 8, roiH ) )
/* compute spatial moment values */
check_sts( status = ippiMoments64f_8u_C1R( pSrc, 8, roiA, pState ) )
/* compute seven Hu moment invariants */
check_sts( status = ippiGetHuMoments_64f( pState, 0, hmH ) )
/* set vertical edge */
check_sts( status = ippiSet_8u_C1R( 0, pSrc, 8, roiA ) )
check_sts( status = ippiSet_8u_C1R( 3, pSrc, 8, roiV ) )
/* compute spatial moment values */
check_sts( status = ippiMoments64f_8u_C1R( pSrc, 8, roiA, pState ) )
/* compute seven Hu moment invariants */
check_sts( status = ippiGetHuMoments_64f( pState, 0, hmV ) )
EXIT_MAIN
ippFree( pState );
printf("Exit status %d (%s)\n", (int)status, ippGetStatusString(status));
return (int)status;
}