Intel® Integrated Performance Primitives
Deliberate problems developing high-performance vision, signal, security, and storage applications.

Porting Ipp6 to Ipp8

Pavel_Kogan
Beginner
1,130 Views

Hi all, 

I am new to Ipp and have tiny experience with ImageProcessing. I need to port old code which is using Ipp6 to our new project. I need some help with ippiResize_8u_C1R function (IPPI_INTER_CUBIC interpolation). What is the most correct way to port it, if I want to get exactly same pixels value after resize. In new Ipp Resize api I see completely new terminology like "spec", "external buffer" and also in function ippiResizeCubicInit_8u I need to define A, B, C and I don't have a clue what their value was in original old function.

Thanks,  Pavel

0 Kudos
14 Replies
Jeffrey_M_Intel1
Employee
1,130 Views

These articles are getting a bit rusty, but they may help:

http://software.intel.com/en-us/articles/resize-changes-in-intel-ipp-71
http://software.intel.com/en-us/articles/threading-intel-integrated-performance-primitives-image-resize-with-intel-threading

As a basic summary IPP has moved to separate functions for the different interpolation algorithms instead of keeping them all in 1 big resize function as back in IPP 6.  Hopefully these articles will help you with things like initialization.  Since algorithms have changed somewhat you may not be able to get exactly the same pixel values but the overall result should be similar. 

0 Kudos
Jeffrey_M_Intel1
Employee
1,130 Views

For the B and C parameters, this could be a start: 

http://software.intel.com/sites/products/documentation/doclib/ipp_sa/71/ipp_manual/IPPI/ippi_appendices/ippi_appB_Cubic2PInterpolation.htm

There is a short list of options -- you may need to do some experimentation to find the best match.

0 Kudos
Pavel_Kogan
Beginner
1,130 Views

Hi Jeffrey,

Thanks you for your help. Do you know if there is some place I can find a source code of  ResizeSqrPixel function?

Thanks, Pavel

0 Kudos
Jeffrey_M_Intel1
Employee
1,130 Views

Do you mean an example program showing ResizeSqrPixel?  There is a start here: http://software.intel.com/en-us/articles/resize-changes-in-intel-ipp-71

BTW, ResizeSqrPixel is deprecated.  There have been no decisions about removals yet so no reason to worry for existing implementations, but please think twice before using it in new code.  Any reason you want ResizeSqrPixel instead of the newer implementation?

0 Kudos
Pavel_Kogan
Beginner
1,130 Views

Hi Jeffrey,

I meant the implementation of ResizeSqrPixel. I don't want to use ResizeSqrPixel as it is deprecated, however as I am not so familiar with image processing (and this part of code is not mine). I hoped the upgrade would be easier than experimenting with paramateres trying to obtain most similar result in the output. 

Regards, Pavel

0 Kudos
Valentin_K_Intel
Employee
1,130 Views

Hi Pavel,

To replace old ippiResize_8u_C1R function call

ippiResize_8u_C1R( pSrc, srcSize, srcStep, srcRoi, pDst, dstStep, dstRoi, xFactor, yFactor, IPPI_INTER_CUBIC );

It can be used the code below where valueB and valueC should be chosen as it is required for task solving:

...
Ipp32u specSize = 0, initSize = 0, bufSize = 0; Ipp8u* pBuffer  = 0;
Ipp8u* pInitBuf = 0; Ipp32u numChannels = 1; IppiPoint dstOffset = {0, 0}; IppStatus status = ippStsNoErr;
IppiBorderType border = ippBorderRepl;

/* cubic interpolation coefficients */
hpp32f valueB = 0.f, valueC = 0.5f; /* Catmull-Rom spline */

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

if (status != ippStsNoErr) return status;

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

if (pInitBuf == NULL || pSpec == NULL)
{
    ippsFree(pInitBuf);
    ippsFree(pSpec);
    return ippStsNoMemErr;
}

/* Filter initialization */
status = ippiResizeCubicInit_8u(srcSize, dstSize, valueB, valueC, pSpec, pInitBuf);
ippsFree(pInitBuf);

if (status != ippStsNoErr)
{
    ippsFree(pSpec);
    return status;
}

/* work buffer size */
status = ippiResizeGetBufferSize_8u(pSpec, dstSize, numChannels, &bufSize);
if (status != ippStsNoErr)
{
    ippsFree(pSpec);
    return status;
}

pBuffer = ippsMalloc_8u(bufSize);
if (pBuffer == NULL)
{
    ippsFree(pSpec);
    return ippStsNoMemErr;
}

/* Resize processing */
status = ippiResizeCubic_8u_C1R(pSrc, srcStep, pDst, dstStep, dstOffset, dstSize, border, 0, pSpec, pBuffer);

ippsFree(pSpec);
ippsFree(pBuffer);
...

Best regards,
Valentin

0 Kudos
Igor_A_Intel
Employee
1,130 Views

Hi Pavel,

the only difference between "old" (deprecated Resize) and "new" (ResizeSqrPixel & Resize<Interpolation>) approaches is that the first one resizes a number of "distances" between image pixels while the new one considers pixels as "squares" and resizes a number of such "squares". Imagine you have 4x4 image and want to decrease its size 2x - in the first case for image width = 4 you have 3 distances and applying scale=0.5 you'll have 1.5 pixels output while for the new approach you'll have 2 pixels. Taking this in mind you always can recalculate resize coefficients between the old and the new one - in this case you'll have very similar results.

regards, Igor 

0 Kudos
Pavel_Kogan
Beginner
1,130 Views

Hi Valentin,

And where I should use srcRoi parameter.

Thanks, Pavel

0 Kudos
Valentin_K_Intel
Employee
1,130 Views

Pavel,

For new IPP resize functions the parameter srcRoi is absent. The couple of parameters dstOffset and dstSize in the processing function defines the destination ROI, the source image ROI is defined based on the destination ROI internally. It is noted that the initialization function accepts image sizes not ROI.

Regards, Valentin

0 Kudos
David_H_11
Beginner
1,130 Views

Hello,

there seems to be a difference between 

ippiResizeCubic_8u_C1R

and

ippiResize_8u_C1R

using IPPI_INTER_CUBIC

as the latter does an interpolation, and first one uses a fixed filter. To get nicer images, I would like to use IPPI_INTER_CUBIC

how can I do this without using deprecated functions?

Thanks

David

 

0 Kudos
Valentin_K_Intel
Employee
1,130 Views

Hi David,

The both functions use a fixed filter for interpolation. The ippiResizeCubic does interpolation with using Two-Parameter Cubic Filters: https://software.intel.com/sites/products/documentation/doclib/ipp_sa/71/ipp_manual/IPPI/ippi_appendices/ippi_appB_Cubic2PInterpolation.htm

You can experiment with B and C parameters to get a result that fits for your task.

Regards, Valentin
 

0 Kudos
Liu__Ning
Beginner
1,130 Views

Valentin K. (Intel) wrote:

Hi David,

The both functions use a fixed filter for interpolation. The ippiResizeCubic does interpolation with using Two-Parameter Cubic Filters: https://software.intel.com/sites/products/documentation/doclib/ipp_sa/71/ipp_manual/IPPI/ippi_appendices/ippi_appB_Cubic2PInterpolation.htm

You can experiment with B and C parameters to get a result that fits for your task.

Regards, Valentin
 

Hello Valentin,

currently I'm comparing the performance of resize with cubic between the IPP 2019 with IPP 5.2, my CPU is intel i7 8700k, 32 bit.

The resize test is that the size of the destination image is (240, 217), one part of the source image will be zoomed to the destination's size.
When one image (60 * 54) is zoomed 4 times, the resize cubic function of IPP 5.2 runs faster than IPP 2019.
When one image (30 * 27) is zoomed 8 times, the resize cubic function of IPP 5.2 runs still faster than IPP 2019. And in this time IPP 2019 is also slower than zoomed 4 times.

My question is that,

Why is IPP 2019 slower than IPP 5.2? Why is using IPP 2019 zoom 8 times slower than zoom 4 times. When zooming 8 times, the processed image size is only a quarter of the zooming 4 times? Has your team also test the performance difference?

Thank you in advance.
Ning

 

0 Kudos
Pavel_B_Intel1
Employee
1,130 Views

Hello Ning,

thank you, we will investigate the case. It takes some time from the IPP team. Feel free to contact with me.

Pavel

0 Kudos
Pavel_B_Intel1
Employee
1,130 Views

I see the discussion was moved to the Resize with Cubic in IPP 2019 slower than IPP 5.2 topic. Let go to the topic.

Pavel

0 Kudos
Reply