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

IPP 6.1 ResizeShift() equivalent in IPP 9.0

Komal_S_
Beginner
1,434 Views
Hi, I need to get ResizeShift() method from IPP 6.1 replaced by IPP 9.0 equivalent method. Output for IPP 9.0 using the following code does not match with IPP 6.1. Input Parameters used: srcRoi = {8, 8}; dstRoiSize = {448,448}; dstStep = 512 * sizeof(float); //original size of image is 512x512 srcStep = srcRoi.width * sizeof(float); xFr = yFr = 0.0136986; // xShift = yShift = 0.5; IPP 6.1 call to ResizeShift: ippiResizeShift_32f_C1R(src, srcSize, srcStep, srcRoi, dstStart, dstStep, dstRoiSize, xFr, yFr, xShift, yShift, IPPI_INTER_CUBIC); IPP 9.0 call to Resize method: int pSpecSize = 0, pInitBufSize = 0; ippiResizeGetSize_32f(srcSize, dstRoiSize, ippCubic, 0/*antialiasing*/, &pSpecSize, &pInitBufSize); IppiResizeSpec_32f* pSpec = (IppiResizeSpec_32f*)ippMalloc(pSpecSize); Ipp8u* pBuffer = (Ipp8u*)ippMalloc(pInitBufSize); ippiResizeCubicInit_32f(srcSize, dstRoiSize, 0.0f/*valueB*/, 0.5f/*valueC*/, pSpec, pBuffer); ippiResizeGetBufferSize_32f(pSpec, dstRoiSize/*dstSize*/, 1/*numChannels*/, &pInitBufSize); ippFree(pBuffer); pBuffer = (Ipp8u*)ippMalloc(pInitBufSize); ippiResizeCubic_32f_C1R(src, srcStep, dstStart, dstStep, { xShift, yShift }/*Offset*/, dstRoiSize/* dstSize*/, ippBorderInMem, 0/*borderValue*/, pSpec, pBuffer); ippFree(pBuffer); ippFree(pSpec); Am i missing any preprocessing step required for IPP 9.0 ? Files attached include : ResizeCubicIn.png -> input image to IPP 6.1 & IPP 9.0 resize method calls. ResizeCubicOut_IPP_90.png -> output image for IPP 9.0 resize() method ResizeShiftOut_IPP61.png -> output image for IPP 6.1 resizeShift() mehtod.
0 Kudos
1 Solution
Valentin_K_Intel
Employee
1,434 Views

Hi Komal,

You can use WarpAffineCubic instead of ResizeShift with Cubic interpolation. The interpolation used by WarpAffineCubic is not the same cubic interpolation as ResizeShift uses, but the quality of the output image is the similar to the quality of the image produced by ResizeShift. Details of the cubic interpolation used by WarpAffine can be found here: https://software.intel.com/en-us/node/505191

To get the transform similar to ResizeShift, you need to set warp affine coefficients in the following way:
coeffs[0][0] = xFr   coeffs[0][1] = 0      coeffs[0][2] = xShift * xFr
coeffs[1][0] = 0      coeffs[1][1] = yFr   coeffs[1][2] = yShift * yFr

IPP 9.0 Resize functionality does not support subpixel shifts and scale factors. Scale factors are defined automatically by the ratio of image sizes as dst.width/src.width and dst.height/src.height.

On top of that the resize model is slightly changed, ResizeShift considers image as a set of pixel points and it resizes a number of "distances" between image pixels, while IPP 9.0 Resize considers images as a set of "square" pixels and it resizes a number of such "squares". For example, if we 2x increase 4x4 image, in the first case for image width = 4 we have 3 distances and applying scale=2 we'll have 6 distances and 7 pixels output, while for the second approach we'll have 8 pixels.

Thanks,
Valentin

 

View solution in original post

0 Kudos
5 Replies
Valentin_K_Intel
Employee
1,435 Views

Hi Komal,

You can use WarpAffineCubic instead of ResizeShift with Cubic interpolation. The interpolation used by WarpAffineCubic is not the same cubic interpolation as ResizeShift uses, but the quality of the output image is the similar to the quality of the image produced by ResizeShift. Details of the cubic interpolation used by WarpAffine can be found here: https://software.intel.com/en-us/node/505191

To get the transform similar to ResizeShift, you need to set warp affine coefficients in the following way:
coeffs[0][0] = xFr   coeffs[0][1] = 0      coeffs[0][2] = xShift * xFr
coeffs[1][0] = 0      coeffs[1][1] = yFr   coeffs[1][2] = yShift * yFr

IPP 9.0 Resize functionality does not support subpixel shifts and scale factors. Scale factors are defined automatically by the ratio of image sizes as dst.width/src.width and dst.height/src.height.

On top of that the resize model is slightly changed, ResizeShift considers image as a set of pixel points and it resizes a number of "distances" between image pixels, while IPP 9.0 Resize considers images as a set of "square" pixels and it resizes a number of such "squares". For example, if we 2x increase 4x4 image, in the first case for image width = 4 we have 3 distances and applying scale=2 we'll have 6 distances and 7 pixels output, while for the second approach we'll have 8 pixels.

Thanks,
Valentin

 

0 Kudos
Komal_S_
Beginner
1,434 Views
Thanks Valentin, for the precise explanation. I tried WarpAffineCubic() method, result looks better now, not exactly same as IPP 6.1, but should be workable now.
On top of that the resize model is slightly changed, ResizeShift considers image as a set of pixel points and it resizes a number of "distances" between image pixels, while IPP 9.0 Resize considers images as a set of "square" pixels and it resizes a number of such "squares". For example, if we 2x increase 4x4 image, in the first case for image width = 4 we have 3 distances and applying scale=2 we'll have 6 distances and 7 pixels output, while for the second approach we'll have 8 pixels.
so is this applicable for IPP 9.0 WarpAffine() method as well ? Does WarpAffine() method too considers image as a set of "square" pixels ?
0 Kudos
Valentin_K_Intel
Employee
1,434 Views

No, this is not applicable for IPP 9.0 WarpAffine() method. It works with image pixels as with points. So the used approach is similar to ResizeShift.

Thanks,
​Valentin

0 Kudos
Komal_S_
Beginner
1,434 Views
Hi, As mentioned earlier, I used WarpAffine() method with ippCubic(i.e. 2-parameter Cubic interpolation) from IPP 9.0 which gave me similar, but not equal, results as compared to IPP 6.1 ResizeShift() using IPPI_INTER_CUBIC. But now i'm in a need to further minimize the difference between these 2 implementations. So, is there any reference for IPPI_INTER_CUBIC approach, that i can use for my own implementation ? Thanks, Komal
0 Kudos
Valentin_K_Intel
Employee
1,434 Views

Hi Komal,

Sorry for the delay with the answer, I was on sick leave. 

The interpolation IPPI_INTER_CUBIC has the same form as the ippCubic interpolation (https://software.intel.com/en-us/node/505191), but it uses different formulas:

k(x) = (1.0/6.0) * ( {3.0 * (x^3) - 6.0*(x^2) - 3.0*x + 6.0; |x|<1}; {-(x^3) + 6.0*(x^2) - 11.0 * x + 6.0; 1<=|x|<2}; {0; |x|>=2} )

Best regards,
Valentin

0 Kudos
Reply