Linear Interpolation

template<typename T>
struct linear

1D linear interpolation

Template Parameters:

T – The datatype to use for the interpolation. E.g. float/double/etc.

Public Types

typedef T VALUE_TYPE

The data type this function is operating with, e.g. for float images, it is float.

Public Functions

inline T operator()(const Data<linear<T>, 1> &p, double x)

Compute the linear interpolation of the given points and position.

Given 2 values, and a position in the interval [0, 1], this function returns the interpolated value using simple linear interpolation.

Note

This function operates in double mode. The result is cast to the set template type T. NO rounding to nearest etc. is performed for e.g. integers.

Parameters:
  • p[in] The 2 values to interpolate

  • x[in] The position in the interval [0, 1] to interpolate

Returns:

The result of the interpolation

Public Static Attributes

static constexpr int NUMBER_OF_VALUES = 2

The number of datapoints required to perform the interpolation. Linear interpolation needs two datapoints.