GetHuMoments

Retrieves image Hu moment invariants computed by ippiMoments function.

Syntax

IppStatus ippiGetHuMoments_64f(IppiMomentState_64f* pState, int nChannel, IppiHuMoment_64f* pHm);

IppStatus ippiGetHuMoments_64s(IppiMomentState_64s* pState, int nChannel, IppiHuMoment_64s* pHm, int scaleFactor);

Parameters

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.

scaleFactor

Scale factor (see Integer Result Scaling).

Description

The function ippiGetHuMoments is declared in the ippi.h file. This function returns the pointer pHm to the array of seven Hu moment invariants previously computed by the ippiMoments function. Different functions are used to retrieve Hu moments in integer and floating-point formats, respectively. In case of integer data, the result may be scaled by the specified scaleFactor.

The code Example “Computing Hu moments” shows how to compute Hu moment values for images that have horizontal and vertical lines.

Return Values

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.

Computing Hu moments

IppStatus mom8u( void) {
   IppStatus stH, stV;
   Ipp8u x[64];
   IppiSize roiA={8,8}, roiH={8,1}, roiV={1,8};
   IppiHuMoment_64f hmH, hmV;
   IppiMomentState_64f*ctx;

		
   stH = ippiMomentInitAlloc_64f(&ctx, ippAlgHintNone );

		
   ippiSet_8u_C1R( 0, x, 8, roiA );
   ippiSet_8u_C1R( 3, x, 8, roiH );
   stH = ippiMoments64f_8u_C1R( x, 8, roiA, ctx );
   ippiGetHuMoments_64f( ctx, 0, hmH );

		
   ippiSet_8u_C1R( 0, x, 8, roiA );
   ippiSet_8u_C1R( 3, x, 8, roiV );
   stV = ippiMoments64f_8u_C1R( x, 8, roiA, ctx );
   ippiGetHuMoments_64f( ctx, 0, hmV );

		
   ippiMomentFree_64f( ctx );
   return ippStsNoErr==stH ? stV : stH;
}

	

Submit feedback on this help topic

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