Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Michele_Belotti
Beginner
50 Views

Using ResizeSqrPixel to perform SPLINE interpolation

Hello,
I'm trying to write a 2D matrix interpolator using ResizeSqrPixel without success. I try to use axes information to compute the ROI of original and interpolated version but I obtain matrix with huge quantity of not allocated value. Also in the very simple case without ROI shift I obtain the same results.

To determine the size of the calling I use the higher dimension between the original and the interpolated matrix

the code used is similar to this one

m_maxRange=IPPI_MAX(i_inputRange,i_outputRange);
m_maxAzimuth=IPPI_MAX(i_inputAzimuth,i_outputAzimuth);
IppiSize size = {m_maxRange,m_maxAzimuth};
IppiRect drect = {0,0,i_outputRange,i_outputAzimuth};
IppiRect srect = {0,0,i_inputRange,i_inputAzimuth};
SetSrcROI(srect);
SetDestROI(drect);

Ipp8u *buf;

int bufsize;
IppStatus status = ippStsNoErr;

IppiSize roi = {i_inputRange,i_inputAzimuth};

/* calculation of work buffer size */
ippiResizeGetBufSize_64f( srect, drect, 1, i_method, &bufsize );

/* memory allocate */
buf = ippsMalloc_8u( bufsize );

status = ippiResizeSqrPixel_64f_C1R(
are_core::os::reinterpret_ptr(i_bufferIn), size, i_inputRange*sizeof(Ipp64f), m_srcROI,
are_core::os::reinterpret_ptr(o_bufferOut), i_outputRange*sizeof(Ipp64f), m_dstROI,
m_xFactor, m_yFactor, m_xShift, m_yShift, i_method, buf );

Could you please give me a hint ? there is something wrong in ROI or IPPISize?

Thanks in advance
Michele
0 Kudos
2 Replies
Michele_Belotti
Beginner
50 Views

I manage to correct generate the resized image by setting the size to the source image size (it was in the doc... sorry about that).
However the comparison between matlab spline is not satisfactory. Do you suggest other function (at the moment performance are not an issue) to perform the interpolation?
If I would like to interpolate on axes how I can adjust xshift/yshift and xfactor/yfactor to perform interpolation on data from initial axis to final axis ? If I understand well axes should be regular it is correct?

Thanks

Michele
Ying_H_Intel
Employee
50 Views

Hi Michele,

Sorry for missing the issue for so long time.

You may refer to the discussion

http://software.intel.com/en-us/forums/showthread.php?t=65400&o=a&s=lr;

considerign the xshift/yshift (most of case, it is 0, 0 if interpolation Rect(0, 0, srcwidth, srcheight) to Rect(0, 0, dstwidth, dstheight)and xfactor/yfactor (which should be fixed too, dstwidth/srcwidth) .

But it may not comparsion between matabl spline as they may usingdifferent coefficients and algrithim. The algrithim of the intepolation of IPP, please refer to IPP manual.

Appendix B: Interpolation in Image Geometric Transform Functions


Linear Interpolation

This is the fastest and least accurate interpolation mode. The pixel value in the destination image is set to the value of the source image pixel closest to the point

(xS,yS):D(xD,yD) = S(round(xS), round(yS)).

The linear interpolation is slower but more accurate than the nearest neighbor interpolation. On the other hand, it is faster but less accurate than cubic interpolation. The linear interpolation algorithm uses source image intensities at the four pixels (xS0, yS0), (xS1, yS0), (xS0, yS1), (xS1, yS1) that are closest to (xS, yS) in the source image:

xS0 = int(xS), xS1 = xS0 + 1, yS0 = int(yS), yS1 = yS0 + 1.

First, the intensity values are interpolated along the x-axis to produce two intermediate results I0 and I1 (see FigureLinear Interpolation):

I0 = S(xS, yS0) = S(xS0, yS0)*(xS1 - xS) + S(xS1, yS0)*(xS - xS0)

I1 = S(xS, yS1) = S(xS0, yS1)*(xS1 - xS) + S(xS1, yS1)*(xS - xS0).

Then, the sought-for intensity D(xD, yD) is computed by interpolating the intermediate values I0 and I1 along the y-axis:

D(xD, yD) = I0*(yS1 - yS) + I1*(yS - yS0).

To use the linear interpolation, set the parameter interpolation to IPPI_INTER_LINEAR. For images with 8-bit unsigned color channels, the functions ippiWarpAffine, ippiRotate, and ippiShear compute the coordinates (xS, yS) with the accuracy 2-16 = 1/65536. For images with 16-bit unsigned color channels, these functions compute the coordinates with floating-point precision.

Linear Interpolation



Regards,
Ying

P.S If you'd like, you may try MKL (math kernal library), IPP's sister library. It providespline interpolation in the mathematical. Please see MKL doc : http://software.intel.com/sites/products/documentation/hpc/mkl/mklman/index.htm
data fitting domain

Partition of interpolation interval [a, b] , where

  • xi denotes breakpoints.
  • [xi, xi+1) denotes a sub-interval (cell) of size xi+1-xi .

{xi}i=1,...,n, where a = x1 < x2<... <xn = b

Vector-valued function of dimension p being fit

(x) = (1(x),..., p(x))

Piecewise polynomial (PP) function of order k+1

(x) Pi (x), if x [ xi, xi+1), i = 1,..., n-1

where

  • {xi}i= 1,..., n is a strictly increasing sequence of breakpoints.
  • Pi(x) = ci,0 + ci,1(x - xi) + ... + ci,k(x - xi)k is a polynomial of degree k (order k+1) over the interval x [ xi, xi+1).

Function p agrees with function g at the points {xi}i=1,...,n .

For every point in sequence {xi}i=1,...,n that occurs m times, the equality p(i-1)() = g(i-1)() holds for all i = 1,...,m, where p(i)(t) is the derivative of the i-th order.

The k-th divided difference of function g at points xi,..., xi + k. This difference is the leading coefficient of the polynomial of order k+1 that agrees with g at xi,..., xi + k.

[ xi,..., xi + k] g

In particular,

  • [x1]g = g(x1)
  • [ x1, x2] g = (g(x1) - g(x2)) / (x1 - x2)

A k-order derivative of interpolant (x) at interpolation site .

Reply