Porting Ipp6 to Ipp8

Porting Ipp6 to Ipp8

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

12 post / 0 nuovi
Ultimo contenuto
Per informazioni complete sulle ottimizzazioni del compilatore, consultare l'Avviso sull'ottimizzazione

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-perf...

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. 

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.

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

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?

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

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

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 

Hi Valentin,

And where I should use srcRoi parameter.

Thanks, Pavel

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

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

 

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
 

Accedere per lasciare un commento.