LIBML  Version 3.2.4
LIBML DSP Software Library
Functions
Bilinear Interpolation
Collaboration diagram for Bilinear Interpolation:

Functions

static f32_t tpt_bilinear_interpolate_f32 (const tpt_bilinear_interpolate_f32_t *aFunction, f32_t aX, f32_t aY)
 Floating-point bilinear interpolation. More...
 
static q31_t tpt_bilinear_interpolate_q31 (tpt_bilinear_interpolate_q31_t *aFunction, q31_t aX, q31_t aY)
 Q31 bilinear interpolation. More...
 
static q15_t tpt_bilinear_interpolate_q15 (tpt_bilinear_interpolate_q15_t *aFunction, q31_t aX, q31_t aY)
 Q15 bilinear interpolation. More...
 
static q7_t tpt_bilinear_interpolate_q7 (tpt_bilinear_interpolate_q7_t *aFunction, q31_t aX, q31_t aY)
 Q7 bilinear interpolation. More...
 

Detailed Description

Bilinear interpolation is an extension of linear interpolation applied to a two dimensional grid. The underlying function f(x, y) is sampled on a regular grid and the interpolation process determines values between the grid points. Bilinear interpolation is equivalent to two step linear interpolation, first in the x-dimension and then in the y-dimension. Bilinear interpolation is often used in image processing to rescale images. This DSP library provides bilinear interpolation functions for Q7, Q15, Q31, and floating-point data types.

Algorithm

The instance structure used by the bilinear interpolation functions describes a two dimensional data table. For floating-point, the instance structure is defined as:

typedef struct tpt_bilinear_interpolate_f32_s { uint16_t uRows; uint16_t uCols; f32_t* pData; } tpt_bilinear_interpolate_f32_t;

where uRows specifies the number of rows in the table; uCols specifies the number of columns in the table; and pData points to an array of size uRows * uCols values. The data table pTable is organized in row order and the supplied data values fall on integer indexes. That is, table element (x,y) is located at pTable[x + y * uCols] where x and y are integers.
Let (x, y) specify the desired interpolation point. Then define:
  XF = floor(x)
  YF = floor(y)
The interpolated output point is computed as:
  f(x, y) = f(XF, YF) * (1 - (x - XF)) * (1 - (y - YF))
          + f(XF + 1, YF) * (x - XF) * (1 - (y - YF))
          + f(XF, YF + 1) * (1 - (x - XF)) * (y - YF)
          + f(XF + 1, YF + 1) * (x - XF) * (y - YF);
Note that the coordinates (x, y) contain integer and fractional components. The integer components specify which portion of the table to use while the fractional components control the interpolation processor.
If (x, y) are outside of the table boundary, Bilinear interpolation returns zero output.

Function Documentation

◆ tpt_bilinear_interpolate_f32()

static f32_t tpt_bilinear_interpolate_f32 ( const tpt_bilinear_interpolate_f32_t aFunction,
f32_t  aX,
f32_t  aY 
)
inlinestatic

Floating-point bilinear interpolation.

Parameters
[in,out]aFunctionpoints to an instance of the interpolation structure.
[in]aXinterpolation coordinate
[in]aYinterpolation coordinate
Returns
out interpolated value.

◆ tpt_bilinear_interpolate_q15()

static q15_t tpt_bilinear_interpolate_q15 ( tpt_bilinear_interpolate_q15_t aFunction,
q31_t  aX,
q31_t  aY 
)
inlinestatic

Q15 bilinear interpolation.

Parameters
[in,out]aFunctionpoints to an instance of the interpolation structure.
[in]aXinterpolation coordinate in 12.20 format
[in]aYinterpolation coordinate in 12.20 format
Returns
out interpolated value.

◆ tpt_bilinear_interpolate_q31()

static q31_t tpt_bilinear_interpolate_q31 ( tpt_bilinear_interpolate_q31_t aFunction,
q31_t  aX,
q31_t  aY 
)
inlinestatic

Q31 bilinear interpolation.

Parameters
[in,out]aFunctionpoints to an instance of the interpolation structure.
[in]aXinterpolation coordinate in 12.20 format
[in]aYinterpolation coordinate in 12.20 format
Returns
out interpolated value.

◆ tpt_bilinear_interpolate_q7()

static q7_t tpt_bilinear_interpolate_q7 ( tpt_bilinear_interpolate_q7_t aFunction,
q31_t  aX,
q31_t  aY 
)
inlinestatic

Q7 bilinear interpolation.

Parameters
[in,out]aFunctionpoints to an instance of the interpolation
[in]aXinterpolation coordinate in 12.20 format
[in]aYinterpolation coordinate in 12.20 format
Returns
out interpolated value.