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_DATA_ORDER_PIXEL, IPL_ORIGIN_TL,
											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);

Results:

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:

ippccg9-8.1.dll
ippsg9-8.1.dll
ippcvg9-8.1.dll
ippig9-8.1.dll
 

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. :)

Login to leave a comment.