Quantcast
Channel: Intel® Software - Intel® Integrated Performance Primitives
Viewing all articles
Browse latest Browse all 1489

Possible bug of Intel IPP 9.0 for Resize image.

$
0
0

Hi staff,

I have worked for a time with the new resize functions in IPP 9.0. and I'm getting some problems which need a help:

I have a input picture size 512x512 and I want to resize it. For simplest, I start with output size 512x512. I used this code which supplied by Valentine in this post :

https://software.intel.com/en-us/forums/intel-integrated-performance-pri...

IppStatus resizeShiftCubic_32f_C1R(Ipp32f* pSrc, IppiSize srcSize, Ipp32s srcStep, Ipp32f* pDst, IppiSize dstSize, Ipp32s dstStep, IppiPoint dstShift)
{
	IppiResizeSpec_32f* pSpec = 0;
	int specSize = 0, initSize = 0, bufSize = 0; Ipp8u* pBuffer = 0;
	Ipp32u numChannels = 1; IppiPoint dstOffset = { 0, 0 }; IppStatus status = ippStsNoErr;
	IppiBorderType border = ippBorderRepl;
	Ipp8u* pInit = NULL;
	IppiRect dstRoi = { dstShift.x, dstShift.y, dstSize.width, dstSize.height };
	IppiSize dstRoiSize = { 0 };
	Ipp32f* pDstRoi = (Ipp32f*)((Ipp8u*)pDst + dstRoi.y * dstStep) + dstRoi.x * numChannels;

	if (dstShift.x < 0)
	{
		dstOffset.x = -dstShift.x;
		dstRoi.width -= dstShift.x;
		dstShift.x = 0;
		pDstRoi = pDstRoi + dstOffset.x * numChannels;
	}

	if (dstShift.y < 0)
	{
		dstOffset.y = -dstShift.y;
		dstRoi.height -= dstShift.y;
		dstShift.y = 0;
		pDstRoi = (Ipp32f*)((Ipp8u*)pDstRoi + dstOffset.y * dstStep);
	}

	if (dstRoi.x + dstRoi.width > dstSize.width)
	{
		dstRoi.width = dstSize.width - dstRoi.x;
	}

	if (dstRoi.y + dstRoi.height > dstSize.height)
	{
		dstRoi.height = dstSize.height - dstRoi.y;
	}

	dstRoiSize.width = dstRoi.width;
	dstRoiSize.height = dstRoi.height;

	/* Spec and init buffer sizes */
	status = ippiResizeGetSize_32f(srcSize, dstSize, ippCubic, 0, &specSize, &initSize);

	/* Memory allocation */
	pSpec = (IppiResizeSpec_32f*)ippsMalloc_8u(specSize);

	pInit = ippsMalloc_8u(initSize);

	/* Filter initialization */
	if (status >= ippStsNoErr) status = ippiResizeCubicInit_32f(srcSize, dstSize, 0.f, 0.0f, pSpec, pInit);

	ippsFree(pInit);

	/* work buffer size */
	if (status >= ippStsNoErr) status = ippiResizeGetBufferSize_32f(pSpec, dstSize, numChannels, &bufSize);

	pBuffer = ippsMalloc_8u(bufSize);

	/* Resize processing */
	if (status >= ippStsNoErr) status = ippiResizeCubic_32f_C1R(pSrc, srcStep, pDstRoi, dstStep, dstOffset, dstRoiSize, border, 0, pSpec, pBuffer);
	//if (status >= ippStsNoErr) status = ippiResizeCubic_32f_C1R(pSrc, srcStep, pDst, dstStep, { 30, 30 }, { 300,500 }, border, 0, pSpec, pBuffer);


	ippsFree(pSpec);
	ippsFree(pBuffer);

	return status;

}

 Above code work OK with when dstOffset = {0,0}. dstRoiSize = {512, 512}. It give output image is same as input image.

I changed dstOffset = {0,0}, dstRoiSize = {300,300}. It work ok and give output image have region 300x300 from input image , remain region is blank.

Now i want to change dstOffset = {30,30} and dstRoiSize = {300,300}. Then program is crashed. This is so strange because i think it should give me a image of region {x=30,y=30,w=300,h=300} from input image.

I think this is bug from the library. Or may i misunderstood about dstOffset. Please give me some comment about this.

Regards,

Tam.


Viewing all articles
Browse latest Browse all 1489

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>