Applies bilinear interpolation to a 2-dimensional grid


DSP style:

typedef struct {
    Ipp16u  numRows;
    Ipp16u  numCols;
    Ipp32f *pData;
} ippsq_bilinear_interp_instance_f32;

float32_t ippsq_bilinear_interp_f32 (const ippsq_bilinear_interp_instance_f32 *S, float32_t X, float32_t Y);

typedef struct {
    Ipp16u  numRows;
    Ipp16u  numCols;
    Ipp16s *pData;
} ippsq_bilinear_interp_instance_q15;

q15_t ippsq_bilinear_interp_q15 (ippsq_bilinear_interp_instance_q15 *S, q31_t X, q31_t Y);

typedef struct {
    Ipp16u  numRows;
    Ipp16u  numCols;
    Ipp32s *pData;
} ippsq_bilinear_interp_instance_q31;

q31_t ippsq_bilinear_interp_q31 (ippsq_bilinear_interp_instance_q31 *S, q31_t X, q31_t Y);

Include Files




Pointer to the data table.


Data table width.


Data table height.


Interpolation coordinate X input value.


Interpolation coordinate Y input value.


This function applies bilinear interpolation to find an intermediate point D(xs, ys) by the specified coordinates (xs, ys) between 2-dimensional grid points using linear polynomials. The grid is defined by the pData matrix with nColumns and nRows.

The output value is a value of the source matrix grid S that is closest to the point (xs, ys): D(xD,yD)=S(round(xS), round(yS)). The linear interpolation algorithm uses source matrix grid intensities at the four pixels (xS0, yS0), (xS1, yS0), (xS0, yS1), (xS1, yS1) that are closest to (xS, yS) in the source grid:

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

The bilinear interpolation function performs the following:

  1. Interpolates the intensity values along the x-axis to produce two intermediate results I0 and I1 (see the figure below):

    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)

  2. Computes the intensity D(xD, yD) by interpolating the intermediate values I0 and I1 along the y-axis:

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

Before using the floating point f32 flavor of the interpolation function, initialize the matrix structure S with 2-dimensional grid data. The function returns zero if the pointer to the S structure is NULL or coordinates (xs, ys) are out of 2-dimensional grid.

If you use Q15 and Q31 integer functions, the (xs, ys) coordinate must be in 12.20 format, where the 12-bit integer part is a position in the pData matrix and 20-bit fractional part of the (xs, ys) coordinate is between four nearest pData matrix values.

For more complete information about compiler optimizations, see our Optimization Notice.