Central moment IPL-IPP conversion

Central moment IPL-IPP conversion

Hello and good day.

When converting from the old IPL to the IPP library (v8.1) I get strange results for the IPL function for central moment.

Example code:

	int width = 103; // minimum size for the discrepancy
	int height =2;
	// create unsigned char image (w,h)=(103,2)
	IplImage* iplIm = iplCreateImageHeader(1, 0, IPL_DEPTH_8U, "GRAY", "GRAY",
											IPL_ALIGN_QWORD, width, height,
											NULL, NULL, NULL, NULL);
	// set all pixels to 1.
	iplAllocateImage(iplIm, 1, 1);
	//create ipp state for moments
	IppHintAlgorithm hint = ippAlgHintAccurate;//ippAlgHintAccurate;//ippAlgHintFast;// ippAlgHintNone
	// allocate memory for state
	IppiMomentState_64f* pState;	
	IppStatus sts = ippiMomentInitAlloc_64f( &pState, hint); 
	// calculate moments
	IppiSize size = {width, height};
	sts = ippiMoments64f_8u_C1R((Ipp8u*)iplIm->imageData, iplIm->widthStep, size, pState);

	// get central moment for IPL and IPP
	int mOrd = 3;
	int nOrd = 0;
	double res_ipp;
	sts = ippiGetCentralMoment_64f( pState, mOrd, nOrd, 0, &res_ipp);
	double res_ipl =  iplCentralMoment(iplIm, mOrd, nOrd);
	assert(res_ipl == res_ipp);


Third moment should be zero for an image consisting only of ones.

IPP: -7.4505805969238281e-009, Good enough

IPL: -2.0000000074505806, ???

System details:

I7-2600, Win7 32bit, IPP8.1SP1.

Loaded IPP dlls:


2 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

at the first glance this is the problem in IPL which is no longer supported. Please use IPP instead. :)

Leave a Comment

Please sign in to add a comment. Not a member? Join today