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

bad result for ippiResizeSuper_8u_C1R function

P__Ella
Beginner
955 Views

Hi,

I’m upgrading my code from ipp8.2 to ipp18.

In the old version, I used the function ippiResizeSqrPixel_8u_C1R with interpolation method = IPPI_INTER_SUPER. In the new version, I’m using the function ippiResizeSuper_8u_C1R. I’ve expected to get identical images as an output, however, they are different.

I’ve tested the reduces images’ histogram. In the old ipp version, the histogram is smooth. But in the the new one it has a shape of comb (see attached)

 

int bufSize;

IppiBorderType borderType = ippBorderRepl;

Ipp8u borderValue = 0;

Ipp32u antialiasing = interpolationMethod | IPPI_ANTIALIASING;

IppiInterpolationType interpolation = ippSuper;

int pSpecSize, pInitBufSize;

IppStatus sts2 = ippiResizeGetSize_8u(src.GetSize(), dst.GetSize(), interpolation, antialiasing,  &pSpecSize, &pInitBufSize);

IppiResizeSpec_32f* pSpec = (IppiResizeSpec_32f*)AllocReuseMem(pSpecSize);

Ipp8u* pInitBuf = AllocReuseMem(pInitBufSize);

ippiResizeSuperInit_8u(src.GetSize(), dst.GetSize(), pSpec);

 

ippiResizeGetBufferSize_8u(pSpec, dst.GetSize(), 1/*numChannels*/, &bufSize);

Ipp8u* pBuffer = AllocReuseMem(bufSize);

 

IppiPoint dstOffset = { 0,0 };

ippiResizeSuper_8u_C1R(src.GetData(), src.GetPitch(), dst.GetData(), dst.GetPitch(), dstOffset, dst.GetSize(), pSpec, pBuffer);

ippsFree(pSpec);

ippsFree(pBuffer);

 

 

any ideas?

Thanks!

0 Kudos
8 Replies
Tatyana_B_Intel
Employee
955 Views

Hello,

The first idea is to check statuses for all IPP function calls. 

If all the statuses are ippStsNoErr, could you please provide the source code of using ippiResizeSqrPixel and image sizes you used?

Thanks in advance,

Tatyana

0 Kudos
P__Ella
Beginner
955 Views

Hi Tatyana,

I've checked the statuses, and they all equal to ippStsNoErr.

I'm using the function to resize image by factor of 2, from 2048x2048 to 1024x1024.

the ipp8.2 code used ippiResizeSqrPixel which produced the correct result is:

int erpolationMethod = IPPI_INTER_SUPER;
double resizeFactX = double(dst.GetWidth())/src.GetWidth();
double resizeFactY = double(dst.GetHeight())/src.GetHeight();
ippiResizeSqrPixel_8u_C1R (src.GetData(), src.GetSize(), src.GetPitch(), src.GetROI(), dst.GetData(),dst.GetPitch(),dst.GetROI(),resizeFactX, resizeFactY,0.0,0.0, interpolationMethod,buf);
 
thanks, 
Ella
 
0 Kudos
Tatyana_B_Intel
Employee
955 Views

Hi Ella,

I've tried to reproduce your issue. 

I filled source image randomly and checked the difference between ippiResizeSuper_8u_C1R and ippiResizeSqrPixel_8u_C1R destination images.

The maximal difference in pixel values is 1. And this behavior is expected.

Could you please check the maximal difference by pixel values of your destination images? If it is less or equal to 1 it's expected. 

If it's more than 1, we need your the source image to reproduce.

Best regards,

Tatyana

 

0 Kudos
P__Ella
Beginner
955 Views

Hi Tatyana,

The maximal difference is indeed 1. Why is it expected? isn't it the same algorithm?

in addition, the main issue is that the destination image histogram is strange. Please take a look at the attached chart.

thanks,

Ella

0 Kudos
Tatyana_B_Intel
Employee
955 Views

Ella,

It's expected due to rounding. The algorithms' implementations are in floats.

Why do you think that the destination image histogram is strange? How do you calculate the histogram? 

Best regards,

Tatyana

0 Kudos
P__Ella
Beginner
955 Views

the histogram is calculate in a simple way - counting the number of occurrences of each gray level (from 0 to 255)

the histogram shape should be smooth. In this histogram, it seems that there are much more odd values, that even. part of the histogram's values, from gray level 230 to 245:

486
701
331
492
222
334
149
267
166
255
159
252
164
391
459
801
0 Kudos
Tatyana_B_Intel
Employee
955 Views

Ella,

Thank you for explanation!

I've checked the histograms for several random images using ippiResizeSuper_8u_C1R and received more even values than the odd ones.

And it is expected for ippiResizeSuper_8u_C1R due to "nearest even" rounding mode. Please see the documentation: https://software.intel.com/en-us/ipp-dev-reference-rounding-mode-1 ;

The internal implementation of ippiResizeSqrPixel_8u_C1R was different.

Best regards,
Tatyana

0 Kudos
P__Ella
Beginner
955 Views

ok, thanks for the clarification.

 

0 Kudos
Reply