ipp filter problems

ipp filter problems

Hi,
I have two problems with the ipp filter functions.
1.
IppiSize dstROI = {718, 404}
IppiSize kernelSize = {3, 3}
IppiPoint anchorIpp = {-1, -1};
status = ippiFilter32f_8u_C1R(u8srcdata, 718, u8dstdata, 718,
dstROI, &kernelMatrix(0, 0), kernelSize, anchorIpp);

return always -14 (step error), altough the step is not less than dstROI.height.

2. If i use
status = ippiFilterLowpass_8u_AC4R(i_src->getPixel(pixelOffset, pixelOffset), yPitch,
dstImg->getPixel(pixelOffset, pixelOffset), yPitch, dstROI, mask);

for example, then the alpha channel of the destination image is always 0.
Cananybody help me?

Regards
Steffen

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

Hi Steffen,

I think the step size needs to be in bytes instead of samples. Not sure about the alpha channel problem.

Peter

Hi Steffen,

Quoting steffenroeberI have two problems with the ipp filter functions...
1.
IppiSize dstROI = {718, 404}
IppiSize kernelSize = {3, 3}
IppiPoint anchorIpp = {-1, -1};
status = ippiFilter32f_8u_C1R(u8srcdata, 718, u8dstdata, 718,
dstROI, &kernelMatrix(0, 0), kernelSize, anchorIpp);

return always -14 (step error), altough the step is not less than dstROI.height.
...

These two values don't look right. This is what a header says forippiFilter32f_8u_C1R:

...
// Parameters:
// pSrc Pointer to the source buffer
// srcStep Step in bytes through the source image buffer
// pDst Pointer to the destination buffer
// dstStep Step in bytes through the destination image buffer
// dstRoiSize Size of the source and destination ROI in pixels
// pKernel Pointer to the kernel values ( 32f kernel )
// kernelSize Size of the rectangular kernel in pixels.
// anchor Anchor cell specifying the rectangular kernel alignment
// with respect to the position of the input pixel
...

and for ippiMalloc set of functions:

...
// Parameter:
// widthPixels width of image in pixels
// heightPixels height of image in pixels
// pStepBytes the pointer to the image step, it is an out parameter calculated
// by the function
...

Best regards,
Sergey

Quoting steffenroeber...
status = ippiFilter32f_8u_C1R(u8srcdata,
718, u8dstdata, 718,
dstROI, &kernelMatrix(0, 0), kernelSize, anchorIpp);

return always -14 (step error), altough the step is not less than dstROI.height
...
It is recommended to use a value forthe'Step In Bytes' parameters returned from IPP memory allocation functions,
like ippiMalloc_xxx orippsMalloc_xxx.

Best regards,
Sergey

But for 8 bit images the ypitch is the same like the width of the roi, isn't it?

No necessarily. If you used the IPP malloc routine it may allocate more per line to try and get the start of each line to align with a certain byte alignment to allow the use of vector instructions. If you're managing the memory your self, then most likely yes. Note that the filter function you're using is on 32-bit floating point data, so the step size will be at least 4 times the width.

Peter

Quoting pvonkaenel... Note that the filter function you're using is on 32-bit floating point data, so the step size will be at least 4 times the width...
Here is a declaration of the function:

IPPAPI( IppStatus, ippiFilter32f_8u_C1R, ( const Ipp8u* pSrc, int srcStep,
Ipp8u* pDst, int dstStep, IppiSize dstRoiSize, const Ipp32f* pKernel,
IppiSize kernelSize, IppiPoint anchor ))

As you can see it uses a floating point type only for the kernel.

I don't understand. The docu says:
ippStsStepErr:
Indicates
an error condition if one the step value is less than roiSize.width*sizeof(pSrc)*numberOfChannels.

My roiSize.width=718, sizeof(pSrc) = 1, numberOfChannels =1
-> 718
and my step value is also 718. Do, what does this has to du with the ippimalloc?

Maybe the questions: Is the step val related to the original image or to the dstRoiSize?

Quoting steffenroeberI don't understand. The docu says:
ippStsStepErr:
Indicates an error condition if one the step value is less than roiSize.width*sizeof(pSrc)*numberOfChannels.

My roiSize.width=718, sizeof(pSrc) = 1, numberOfChannels =1
-> 718
and my step value is also 718. Do, what does this has to du with the ippimalloc?...

[SergeyK] It returns a 'Step Bytes' value. For example:
...
...ippiMalloc_8u_C1( iSrcWidth, iSrcHeight, &iSrcStepBytes );
...

Steffen,

How did you allocate the memory for yoursource and destinationimages? Did you use someippiMalloc_xxx function?

In order to help you here is a very small test-case and please take a look / investigate:

	...

	// Sub-Test 06 - Tests for 'ippiMalloc_8u_C1' and 'CrtMalloc' functions

	{

		CrtPrintf( RTU("Sub-Test 06n") );				// ippiMalloc_8u_C1: Max Image size = 34207 x 34207

														// CrtMalloc       : Max Image size = 34208 x 34208

		Ipp8u *pSrcImage = RTnull;

		Ipp8u *pDstImage = RTnull;
		while( RTtrue )

		{

			RTint iSrcWidth;

			RTint iSrcHeight;

			iSrcWidth = 34207;							// For ippiMalloc_8u_C1 function	( ~1.08975GB )

			iSrcHeight = 34207;

		//	iSrcWidth = 34208;							// For CrtMalloc function			( ~1.08982GB )

		//	iSrcHeight = 34208;
			CrtPrintf( RTU("Source      Image size: %5ld x %5ldn"), iSrcWidth, iSrcHeight );
			RTint iSrcStepBytes = -1;
			iSrcStepBytes = iSrcWidth;
			pSrcImage = ( Ipp8u * )::ippiMalloc_8u_C1( iSrcWidth, iSrcHeight, &iSrcStepBytes );

		//	pSrcImage = ( Ipp8u * )::CrtMalloc( iSrcWidth * iSrcHeight * sizeof( RTuchar ) );

			if( pSrcImage == RTnull )

			{

				CrtPrintf( RTU("Memory for Source Image is NOT allocatedn") );

				break;

			}

			CrtPrintf( RTU("Memory for Source Image is allocatedn") );
			IppiSize srcSize = { 0 };

			srcSize.width = ( RTint )( iSrcWidth * iSrcHeight );

			srcSize.height = 1;
		//	st = ::ippiSet_8u_C1R( 1, pSrcImage, 1, srcSize );

		//	if( st != ippStsNoErr )

		//	{

		//		CrtPrintf( RTU("[ ippiSet_8u_C1R ] Failedn") );

		//		break;

		//	}

		//	CrtPrintf( RTU("[ ippiSet_8u_C1R ] Completedn") );
			break;

		}
		SysSleep( 2000 );
		if( pSrcImage != RTnull )

		{

			::ippiFree( pSrcImage );					// For ippiMalloc_8u_C1 function

	//		CrtFree( pSrcImage );						// For CrtMalloc function

			pSrcImage = RTnull;

			CrtPrintf( RTU("Memory for Source Image deallocatedn") );

		}

	}

	...
Best regards,
Sergey

Hi,
I used my own memorly allocation. And I fixed the issue meanwhile. It seems that I have to use the step value of the whole image instead of the ROI. At least this does not create this error code.

Quoting steffenroeber...I used my own memorly allocation...

[SergeyK] This is OK and I also use 'malloc' instead of 'ippiMalloc_xxx' in some cases. But, I always verify a 'Step Byte' value with
a right'ippiMalloc_xxx' function and then use it.

And I fixed the issue meanwhile. It seems that I have to use the step value of the whole image instead of the ROI. At least this does not create this error code.

Leave a Comment

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