Community
cancel
Showing results for 
Search instead for 
Did you mean: 
QiXin_Y_
Beginner
191 Views

substitute for ippiResizeSqrPixel ippiResizeGetBufSize

My project is using the ippiResizeSqrPixel_16u_C1R to resize image with IPPI_INTER_CUBIC mode, and using ippiResizeGetBufSize to initialize the buffer in advance.

But unfortunately ipp9.0 doesn't support both apis, and the "Substitution or Workaround" for both are N/A.

Could you give me a work around solution?

Thanks and regards,

Yang Qi Xin

0 Kudos
8 Replies
Jonghak_K_Intel
Employee
191 Views

Hi Yang,

If you look at the reference manual in your IPP installed documentation,

IPP now has functions for resizing similar to this : https://software.intel.com/en-us/node/504353 (Using Intel® IPP Resize Functions with Prior Initialization, IPP 2017 )

 

Capture.PNG\

you might want to try out 'ippiResizeCubic_16u_C1R'

You also can refer the IPP resize example included in your installation. It shows the initialization procedure of resizing functions so you can definitely use them as references.

In case you are not able to find the code , I'm attaching the example code of resize.cpp.

 

Thank you

QiXin_Y_
Beginner
191 Views

Dear JON,

Thanks a lot for the reply, and with your example and the reference, I have basically completed the modification of the code.

There are still 2 questions:

1. One thing I am curious about is that, the examples are with _8u  suffix, and all the called functions use _8u, it is OK;

But in my case, the core function is ippiResizeCubic_16u_C1R, and it's init ippiResizeCubicInit_16u.

Are the following functions correct?

ippiResizeGetSize_16u (to get spec size and iInitSize)

ippiMalloc_16u_C1 (to get the step bytes)

ippsMalloc_8u (to allocate the initial buffer);

2. What value should be of the parameters [Ipp32f valueB] and [Ipp32f valueC] used in ippiResizeCubicInit?

Thanks and regards,

Yang Qi Xin

Jing_X_Intel
Employee
191 Views

Hi QiXin,

Regarding to the 2nd question about [Ipp32f valueB] and [Ipp32f valueC], they are variables to provide different approximation to cubic filtering. The fomular is given as the following (https://software.intel.com/en-us/node/505191).

0EF01A88-F874-4ECB-B2B6-3ADC38636CD4-imageId=C412702A-209D-4CCD-A099-989A2E18A085.jpg

If more detailed information is needed, please refer to the following reference.

Don P. Mitchell, Arun N. Netravali. Reconstruction Filters in Computer Graphics. Computer Graphics, Volume 22, Number 4, AT&T Bell Laboratories, Murray Hill, New Jersey, August 1988.

 

Trying different B & C in several experiments to verify which pair has the best performance would be a good idea.

---------------------------------------------------------------------------------------------------

Reference:

https://software.intel.com/en-us/forums/intel-integrated-performance-primitives/topic/499132

https://software.intel.com/en-us/node/505191

https://software.intel.com/en-us/node/505193#MITCHELL88

Jonghak_K_Intel
Employee
191 Views

Regarding the second question, Jing's answer is right.

You can try different values for B and C parameters and choose the best result for you.

Just for an example, in the example code they choose

 m_fBVal   = 1; // for B
 m_fCVal   = 0; // for C
 

 

For the question #1,

ippiResizeGetSize_16u (to get spec size and iInitSize) -> Correct

ippiMalloc_16u_C1 (to get the step bytes) -> Correct

ippsMalloc_8u (to allocate the initial buffer) -> you can use Ipp16u* ippsMalloc_16u(int len);

 

Thanks

 

QiXin_Y_
Beginner
191 Views

Dear Jing and JON,

Many thanks to both of you!  Now I understand B and C, and notice the values used in JON's cpp example, I will try with them.

Now let's focus on the API versions and thus, data types:

And I followed the instruction on the web page you given in the first reply, "Resizing the Whole Image" section.

In it's example, there are 2 buffers: pBuffer (call it working buffer), and pInitBuffer(initial buffer), both Ipp8u* type.

So in my case they should be Ipp16u*, and use ippsMalloc_16u to allocate buffers?

 

And also the  IppiResizeSpec_32f* pSpec;

It's size is obtained by ippiResizeGetSize_16u in my case, so it should be allocated with ippsMalloc_16u instead of ippsMalloc_8u?

Thanks and regards,

Yang Qi Xin

 

 

Jing_X_Intel
Employee
191 Views

According to the api reference shown below, I think both of pBuffer and pInitBuffer should be in type Ipp8u*, no matter what the mod type is.(But larger size won't be any problem)

IppStatus ippiResizeLanczosInit_<mod>(IppiSize srcSize, IppiSize dstSize, Ipp32u numLobes, IppiResizeSpec_32f* pSpec, Ipp8u* pInitBuf);
IppStatus ippiResizeLanczos_<mod>(const Ipp<datatype>* pSrc, Ipp32s srcStep, Ipp<datatype>* pDst, Ipp32s dstStep, IppiPoint dstOffset, IppiSize dstSize, IppiBorderType border, const Ipp<datatype>* pBorderValue, const IppiResizeSpec_32f* pSpec, Ipp8u* pBuffer);

Regarding to pSpec, I think you are right.

Since the size is retrieved from ippiResizeGetSize_16u, the value is corresponding to the number of 16u, thus ippsMalloc_16u should be applied in mallocing space.

Actually, by executing the following code, you will find that the outputs of two types are the same.

int specSize_8u = 0;
int initBufSize_8u = 0;
ippiResizeGetSize_8u(srcSize, dstSize, ippLanczos, 0, &specSize_8u, &initBufSize_8u);
int specSize_16u = 0;
int initBufSize_16u = 0;
ippiResizeGetSize_16u(srcSize, dstSize, ippLanczos, 0, &specSize_16u, &initBufSize_16u);
printf("%d, %d\n%d, %d\n", specSize_8u, initBufSize_8u, specSize_16u, initBufSize_16u);
// Result is specSize_8u == specSize_16u; initBufSize_8u == initBufSize_16u

--------------------

Reference:

https://software.intel.com/en-us/node/504361

https://software.intel.com/en-us/node/504373

QiXin_Y_
Beginner
191 Views

Dear both, 

So can we summarize:

Data:

    Ipp16u* pInitBuffer = NULL ;
    Ipp16u* pWorkingBuffer = NULL ;
    IppiResizeSpec_32f* pSpec = NULL;
    Ipp16u* pTmpImage = NULL;

buffer allocation:

 IppStatus status = ippiResizeGetSize_16u(..., &iSpecSize, &iInitBufferSize);

 pSpec = (IppiResizeSpec_32f*)ippsMalloc_16u(iSpecSize);
 pInitBuffer = ippsMalloc_16u(iInitBufferSize);

 status = ippiResizeCubicInit_16u(..., pSpec, pInitBuffer);
 status = ippiResizeGetBufferSize_16u(..., &iWorkingBufferSize);

 pWorkingBuffer = ippsMalloc_16u(iWorkingBufferSize);
 pTmpImage = ippiMalloc_16u_C1(..., &iStepBytes);
 status = ippiResizeCubic_16u_C1R(...);

(all buffers using 16u to allocate.)

Thanks and regards,

Yang Qi Xin

 

 

Valentin_K_Intel
Employee
191 Views

Hi QiXin,

The all sizes returned by the function ResizeGetSize and ResizeGetBufferSize are in bytes. So the function ippsMalloc_8u should be used to allocate the memory for the buffers pSpec, pInitBuffer, pWorkingBuffer.

The resize functions flavor 16u means that the processing function works with the image of 16u data. 

Data:

    Ipp8u* pInitBuffer = NULL ;
    Ipp8u* pWorkingBuffer = NULL ;
    IppiResizeSpec_32f* pSpec = NULL;
    Ipp16u* pTmpImage = NULL;

Buffer allocation:

 IppStatus status = ippiResizeGetSize_16u(..., &iSpecSize, &iInitBufferSize);

 pSpec = (IppiResizeSpec_32f*)ippsMalloc_8u(iSpecSize);
 pInitBuffer = ippsMalloc_8u(iInitBufferSize);

 status = ippiResizeCubicInit_16u(..., pSpec, pInitBuffer);
 status = ippiResizeGetBufferSize_16u(..., &iWorkingBufferSize);

 pWorkingBuffer = ippsMalloc_8u(iWorkingBufferSize);
 pTmpImage = ippiMalloc_16u_C1(..., &iStepBytes);
 status = ippiResizeCubic_16u_C1R(...);

Best regards,
Valentin

Reply