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

WarpAffine does not properly support linear interpolation

anniezh
Beginner
787 Views

I used WarpAffine in my application. I found WarpAffine did not properly support linear interpolation except for pure translation. I did the resize {{xFactor, 0.0, 0.0}, {0.0, yFactor, 0.0}} using WarpAffine and got the same result using NN or linear interpolation. I did the same tests for Shear using WarpAffine and also got the same results using NN or linear interpolation.

Could you please let me know if there is an issue with WarpAffine support for different interpolation methods?

0 Kudos
13 Replies
SergeyKostrov
Valued Contributor II
787 Views
Please provide more details about version of IPP you're using and exact name of WarpAffine function. There are many WarpAffine functions in two IPP domains, that is, Image Processing and Realistic Rendering.
0 Kudos
anniezh
Beginner
787 Views

The exact function name is "WarpAffine" in Image and Video processing. I used IPP version 7.0. Thanks.

0 Kudos
SergeyKostrov
Valued Contributor II
787 Views
I don't see any IPP functions with WarpAffine name. However, there are lots of ippi-functions with names like: ... IPPAPI(IppStatus, ippiWarpAffine_8u_C1R... IPPAPI(IppStatus, ippiWarpAffine_8u_C3R... IPPAPI(IppStatus, ippiWarpAffine_8u_C4R... IPPAPI(IppStatus, ippiWarpAffine_8u_AC4R... IPPAPI(IppStatus, ippiWarpAffine_8u_P3R... IPPAPI(IppStatus, ippiWarpAffine_8u_P4R... IPPAPI(IppStatus, ippiWarpAffine_16u_C1R... IPPAPI(IppStatus, ippiWarpAffine_16u_C3R... IPPAPI(IppStatus, ippiWarpAffine_16u_C4R... IPPAPI(IppStatus, ippiWarpAffine_16u_AC4R... IPPAPI(IppStatus, ippiWarpAffine_16u_P3R... IPPAPI(IppStatus, ippiWarpAffine_16u_P4R... IPPAPI(IppStatus, ippiWarpAffine_32f_C1R... IPPAPI(IppStatus, ippiWarpAffine_32f_C3R... IPPAPI(IppStatus, ippiWarpAffine_32f_C4R... IPPAPI(IppStatus, ippiWarpAffine_32f_AC4R... IPPAPI(IppStatus, ippiWarpAffine_32f_P3R... IPPAPI(IppStatus, ippiWarpAffine_32f_P4R... IPPAPI(IppStatus, ippiWarpAffine_64f_C1R... IPPAPI(IppStatus, ippiWarpAffine_64f_C3R... IPPAPI(IppStatus, ippiWarpAffine_64f_C4R... IPPAPI(IppStatus, ippiWarpAffine_64f_AC4R... IPPAPI(IppStatus, ippiWarpAffine_64f_P3R... IPPAPI(IppStatus, ippiWarpAffine_64f_P4R... ... and many more.
0 Kudos
anniezh
Beginner
787 Views

I used ippiWarpAffine_32f_C1R for the testing. I used coeffs = {{ { 0.5, 0.0, 0.0}, {0.0, 0.5, 0.0} }; for resize test and coeffs = { { 1.0, 0, 0.0}, {0.5, 1.0, 0.0} };for shear test.

0 Kudos
Valentin_K_Intel
Employee
787 Views

Hi anniezh,

Could you please provide sample code with ippiWarpAffine_32f_C1R function usage, and the input/output images for NN and linear interpolation, which were obtained.

Regards, Valentin

0 Kudos
anniezh
Beginner
787 Views

Hi Valentin,

Here is the sample code:

octet* pSrc = src_data.get_indexed_offset(0, 0);  octet* pDst = dst_data.get_indexed_offset(0, 0);

 Imaging::DimensionSize src_dimx = src_data.get_dim_length(0);     Imaging::DimensionSize src_dimy = src_data.get_dim_length(1);

 IppiSize size_src_xy = {(int) src_dimx, (int) src_dimy};  IppiRect srcROI = {0, 0, (int) src_dimx, (int) src_dimy};

 int srcStep = (int) src_data.get_dim_stride(1); // length in bytes of each row (see IPP documentation)  int dstStep = (int) dst_data.get_dim_stride(1); // length in bytes of each row (see IPP documentation)

 IppiRect dstROI = {0, 0, (int) dst_data.get_dim_length(0), (int) dst_data.get_dim_length(1)};

 ippStatus = ippiWarpAffine_32f_C1R((Ipp32f*)pSrc, srcSize, srcStep, srcRoi, (Ipp32f*)pDst, dstStep, dstRoi, coeffs, interpolationType);

One can do the testing by passing different coeffs and interpolationType.

I tried resize using coeffs = { { 0.5, 0.0, 0.0}, {0.0, 0.5, 0.0} }; interpolationType as 1 or 2. Got exactly the same result image.

shear using coeffs = { { 1.0, 0.0, 0.0}, {0.5, 1.0, 0.0} }; interpolationType as 1 or 2. Got exactly the same result image.

Attached please find the images.

Regards,

Annie

 

 

 

 

0 Kudos
anniezh
Beginner
787 Views

Hi Valentin,

Can you reproduce the problem I found when using ippiWarpAffine_32f_C1R? Is this a software bug? Thanks.

Annie

 

0 Kudos
Valentin_K_Intel
Employee
787 Views

Hi Annie,

I was on vacation and now I am investigating this issue.

Regards, Valentin

0 Kudos
Valentin_K_Intel
Employee
787 Views

Hi Annie,

Sorry for the delay with the answer. I have investigated this issue. It has turned out that the root cause of the issue consists in the transformation coefficients. If the source indices calculated by the function are integer, the linear interpolation is computed with the coefficients {0,1} that is equal to Nearest Neighbor interpolation.
You can check that the function works with linear interpolation by changing coefficients from { { 0.5, 0.0, 0.0}, {0.0, 0.5, 0.0} } to { { 0.55, 0.0, 0.0}, {0.0, 0.55, 0.0} } for example. 

Thanks, Valentin

0 Kudos
anniezh
Beginner
787 Views

Hi Valentin,

Thanks for your reply! I think the interplation type that the function apply should depends on the interplation type that the user pass in, not on the coefficients that the user pass in. The function should work with linear interplation for all coefficients as long as the user choose the interplation type as linear interplation. Please let me know what you think. Thanks.

Annie

 

 

 

0 Kudos
Valentin_K_Intel
Employee
787 Views

Hi Annie,

The current function implementation calculates a new position for each pixel by rotation of the top-left pixel corner. This approach gives the same results for nearest neighbor and linear interpolations, if the source image size is multiple of the destination image size.

Best regards, Valentin

0 Kudos
anniezh
Beginner
787 Views

Hi Valentin,

I tested ippiResizeSqrPixel_32f_C1R to resize the image in half. Use Nearest neighbor vs linear interpolation give different results, while use ippiWarpAffine_32f_C1R to resize the image in half, nearest neighbor and linear interpolation give the same results. Is there something wrong with the WarpAffine calculation? Thanks,

Annie

 

 

0 Kudos
Valentin_K_Intel
Employee
787 Views

Hi Annie,

ippiWarpAffine_32f_C1R considers an image as a grid with pixels as nodes, while ResizeSqrPixel considers pixels as "squares". Thus these functions use the different approaches for image transformation.

Best regards, Valentin

0 Kudos
Reply