- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Initially I was using older version of IPP resize API (ippiResize_16u_C1R) with linear interpolation and BorderType Const. Since the IPP9.0 ResizeLinear with takes only two type of BorderType parameter (ippBorderInMem & ippBorderRepl), so I used src image with margin and border value zero and called ippiResizeLinear_16u_C1R with border type ippBorderInMem. But output of ippiResizeLinear_16u_C1R API is different from that resize API in older version.
Even the resize API from legacy(ippiresizeSqrPixel_16u_C1R) gives different output for linear interpolation. All three Resize API have different output for linear interpolation.
Given below is my code
IppiBorderType borderType = ippBorderInMem; Ipp16u boarderValue = 0; IppiBorderSize borderSize; ResizeLinearInit_16u(src.getRoiSize(), dst.getRoiSize(), pSpec); ResizeGetBufferSize_16u(pSpec, dst.getRoiSize(), 1, &workBufSize); ResizeGetBorderSize_16u(pSpec, &borderSize); ResizeLinear(srcWithMargin, dst, Point(0, 0), dst.getRoiSize(), borderType, &boarderValue, pSpec, workBuffer);
I need to keep backward compatibility, so please suggest me cause of mismatch and what can be done..?
Regards
Ubhay
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Is the result different also well inside the image, away from borders? Some functions put the pixel position at the corner of the square and others at the center.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Results are different on border as well as inside.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
//IPP OLD Img<IP_16U> lena("Read Image"); Img<IP_16U> lenaRefdst(640, 640); double xFactorL = double(lenaRefdst.getRoi().size.width) / double(lena.getRoi().size.width); double yFactorL = double(lenaRefdst.getRoi().size.height) / double(lena.getRoi().size.height); ippiResize_16u_C1R(lena.getImgPtr(),lena.getSize(),lena.getWStep(),lena.getRoi().ToIppiRect(),lenaRefdst.getRoiPtr(),lenaRefdst.getWStep(),lenaRefdst.getRoiSize(),xFactorL, yFactorL, IPPI_INTER_LINEAR); //IPP Legacy Img<IP_16U> lenaLegacydst(640, 640); int nBufferSize; ippiResizeGetBufSize(lena.getRoi().ToRect(), lenaLegacydst.getRoi().ToRect(), 1, IPPI_INTER_LINEAR, &nBufferSize); Ipp8u* pBuffer = (Ipp8u*)ippMalloc(nBufferSize); ippiResizeSqrPixel_16u_C1R(lena.getRoiPtr(),lena.getRoiSize(),lena.getWStep(),lena.getRoi().ToIppiRect(), lenaLegacydst.getRoiPtr(), lenaLegacydst.getWStep(),lenaLegacydst.getRoi().ToIppiRect(),xFactorL, yFactorL, 0, 0,IPPI_INTER_LINEAR, pBuffer); //IPP 2017 IppiBorderType borderType = ippBorderInMem; Ipp16u boarderValue = 0; Img<IP_16U> lenaWithMargin(lena.getRoiSize().width, lena.getRoiSize().height, margin); Ipp::Copy(lena, lenaWithMargin); lenaWithMargin.SetConstBorder((IP_16U)0, margin); Img<IP_16U> lena2017dst(640, 640); int specSize1, initSize1, workBufSize1; Ipp::ResizeGetSize_16u(lenaWithMargin.getRoiSize(), lena2017dst.getRoiSize(),IPPI_INTER_LINEAR, 0, &specSize1, &initSize1); IppiResizeSpec_32f * pSpec1 = (IppiResizeSpec_32f *)ippMalloc(specSize1); Ipp::ResizeLinearInit_16u(lenaWithMargin.getRoiSize(), lena2017dst.getRoiSize(), pSpec1); Ipp::ResizeGetBufferSize_16u(pSpec1, lena2017dst.getRoiSize(), 1, &workBufSize1); Ipp8u* pBuffer1 = (Ipp8u*)ippMalloc(workBufSize1); Ipp::ResizeLinear(lenaWithMargin, lena2017dst, Point(0, 0), lena2017dst.getRoiSize(), borderType, &boarderValue, pSpec1, pBuffer1);
Please find source image and results image in attached zip file.
SrcImage = "lena.tif" (512x512)
IPP_OLD_Result = "lena_IPPOLD_ippiResize.tif" (640x640)
IPP_Legacy_result = "lena_Legacy_ippiResizeSqrPixel.tif" (640x640)
IPP2017_Result = "lena_IPP2017_ippiResizeLinear.tif" (640x640)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Ubhay,
Thank you for the provided materials. We will investigate the issue and get back with an answer.
Best regards,
Valentin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I was waiting for your response. Are you able to reproduce the error..?
Please update me if you have any solution.
Regards
Ubhay
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Ubhay,
Sorry for delay with the response. Your issue was investigated.
I see the only difference in borders processing. ippiResizeSqrPixel_16u_C1R uses Replicate border type by default. ippiResizeLinear_16u_C1R supports Replicate and InMem border types (and you used InMem border type with reconstructing border pixels with Constant border). As a result you received different output. If you would like to receive the similar output using these two functions, you have to use ippiResizeLinear_16u_C1R with Replicate border type.
As for receiving the same results using ippiResizeSqrPixel_16u_C1R, it's impossible due to different scaling approaches as it was mentioned above.
As for image quality, the scaling approach in ippiResizeLinear function seems to be more natural than the ippiResize approach. For example if we double 10x10 image using ippiResizeLinear approach we'll receive the image 20x20, while using the second approach with scaleFactor 0.5 the output size will be 19x19 image.
Best regards,
Tatyana Bysheva

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page