ImFusion SDK 4.3
ImFusion::Math::Interpolation Namespace Reference

Helper functions for N-linear interpolation of N-cells(pixel, voxel, etc. ) More...

Detailed Description

Helper functions for N-linear interpolation of N-cells(pixel, voxel, etc. )

Typedefs

template<int N>
using vecNd = Eigen::Matrix<double, N, 1>
 
template<int N>
using vecNi = Eigen::Matrix<int, N, 1>
 

Functions

template<typename T, int N>
void linear (const T *nCellData, const vecNi< N > &dimensions, int nChannels, const vecNd< N > &position, double *output)
 N-linear interpolation.
 
template<typename T>
void linear (const T *nCellData, int dimensions, int nChannels, double position, double *output)
 Convenience overload for 1D linear interpolation.
 
template<typename T, int N>
void linear (const TypedImage< T > &img, const vecNd< N > &position, double *output)
 Convenience overload for N-dimensional linear interpolation of a TypedImage.
 
template<typename T, int N>
void linearClampToBorder (const T *nCellData, const vecNi< N > &dim, int nChannels, const vecNd< N > &position, double *output, const double *borderVal, bool interpolateBorder, bool *wasInside=nullptr)
 N-dimensional linear interpolation with border value.
 
template<typename T>
void linearClampToBorder (const T *nCellData, int dim, int nChannels, double position, double *output, const double *borderVal, bool interpolateBorder, bool *wasInside=nullptr)
 Convenience overload for 1D linear interpolation with border value.
 
template<typename T, int N>
void linearClampToBorder (const TypedImage< T > &img, const vecNd< N > &position, double *output, const double *borderVal, bool interpolateBorder, bool *wasInside=nullptr)
 Convenience overload for N-dimensional linear interpolation with border value of a TypedImage.
 
template<typename T, int N>
void linearClampToEdge (const T *nCellData, const vecNi< N > &dim, int nChannels, vecNd< N > position, double *output)
 N-dimensional linear interpolation with clamping.
 
template<typename T>
void linearClampToEdge (const T *nCellData, int dim, int nChannels, double position, double *output)
 Convenience overload for 1D linear interpolation with clamping.
 
template<typename T, int N>
void linearClampToEdge (const TypedImage< T > &img, const vecNd< N > &position, double *output)
 Convenience overload for N-dimensional linear interpolation with clamping of a TypedImage.
 
template<typename T, int N>
void linearClampToEdge (const T *nCellData, const vecNi< N > &dim, int nChannels, const vecNd< N > &position, double *output, bool &wasInside)
 N-dimensional linear interpolation with clamping.
 
template<typename T>
void linearClampToEdge (const T *nCellData, int dim, int nChannels, double position, double *output, bool &wasInside)
 Convenience overload for 1D linear interpolation with clamping.
 
template<typename T, int N>
void linearClampToEdge (const TypedImage< T > &img, const vecNd< N > &position, double *output, bool &insideVolume)
 Convenience overload for N-dimensional linear interpolation with clamping of a TypedImage.
 
template<typename T, int N>
bool linearLegacy (const T *nCellData, const vecNi< N > &dim, int nChannels, const vecNd< N > &position, double *output, const double *borderVal, bool clamp)
 N-dimensional linear interpolation with same clamping behavior as the deprecated Math::interp functions.
 

Function Documentation

◆ linear() [1/3]

template<typename T, int N>
void linear ( const T * nCellData,
const vecNi< N > & dimensions,
int nChannels,
const vecNd< N > & position,
double * output )

N-linear interpolation.

The N-cells are assumed to be centered on integer coordinates and have a diameter of 1. Note that this fast version does not do any validity checks on the lookup position and may crash if out of bounds.

Parameters
nCellDataRaw N-cell data in the shape of dimensions and nChannels
dimensionsNumber of N-cells in each dimension in input data
nChannelsNumber of color channels in input data
positionLookup coordinate in N-cell space
outputOutput buffer for interpolated value, buffer needs to be able to hold nChannels values
Template Parameters
TType of the N-cell data to interpolate
NDimensionality of the image to interpolate

◆ linear() [2/3]

template<typename T>
void linear ( const T * nCellData,
int dimensions,
int nChannels,
double position,
double * output )

Convenience overload for 1D linear interpolation.

N-linear interpolation.

The N-cells are assumed to be centered on integer coordinates and have a diameter of 1. Note that this fast version does not do any validity checks on the lookup position and may crash if out of bounds.

Parameters
nCellDataRaw N-cell data in the shape of dimensions and nChannels
dimensionsNumber of N-cells in each dimension in input data
nChannelsNumber of color channels in input data
positionLookup coordinate in N-cell space
outputOutput buffer for interpolated value, buffer needs to be able to hold nChannels values
Template Parameters
TType of the N-cell data to interpolate
NDimensionality of the image to interpolate

◆ linear() [3/3]

template<typename T, int N>
void linear ( const TypedImage< T > & img,
const vecNd< N > & position,
double * output )

Convenience overload for N-dimensional linear interpolation of a TypedImage.

The N-cells are assumed to be centered on integer coordinates and have a diameter of 1. Note that this fast version does not do any validity checks on the lookup position and may crash if out of bounds.

Parameters
imgInput image to perform the interpolation on
positionLookup coordinate in N-cell space
outputOutput buffer for interpolated value, buffer needs to be able to hold nChannels values
Template Parameters
TType of the N-cell data to interpolate
NDimensionality of the image to interpolate

◆ linearClampToBorder() [1/3]

template<typename T, int N>
void linearClampToBorder ( const T * nCellData,
const vecNi< N > & dim,
int nChannels,
const vecNd< N > & position,
double * output,
const double * borderVal,
bool interpolateBorder,
bool * wasInside = nullptr )

N-dimensional linear interpolation with border value.

The N-cells are assumed to be centered on integer coordinates and have a diameter of 1. This version treats all N-cells outside of the given volume as having the value borderVal.

Parameters
nCellDataRaw N-cell data in the shape of dimensions and nChannels
dimensionsNumber of N-cells in each dimension in input data
nChannelsNumber of color channels in input data
positionLookup coordinate in N-cell space
outputOutput buffer for interpolated value, buffer needs to be able to hold nChannels values
borderValIntensity value outside the volume, buffer needs to hold nChannels values
interpolateBorderWhether borderVal may be interpolated with the volume content when slightly out of bounds (OpenGL behavior)
wasInsideOptional output variable indicating whether position was inside the volume
Template Parameters
TType of the N-cell data to interpolate
NDimensionality of the image to interpolate

◆ linearClampToBorder() [2/3]

template<typename T>
void linearClampToBorder ( const T * nCellData,
int dim,
int nChannels,
double position,
double * output,
const double * borderVal,
bool interpolateBorder,
bool * wasInside = nullptr )

Convenience overload for 1D linear interpolation with border value.

N-dimensional linear interpolation with border value.

The N-cells are assumed to be centered on integer coordinates and have a diameter of 1. This version treats all N-cells outside of the given volume as having the value borderVal.

Parameters
nCellDataRaw N-cell data in the shape of dimensions and nChannels
dimensionsNumber of N-cells in each dimension in input data
nChannelsNumber of color channels in input data
positionLookup coordinate in N-cell space
outputOutput buffer for interpolated value, buffer needs to be able to hold nChannels values
borderValIntensity value outside the volume, buffer needs to hold nChannels values
interpolateBorderWhether borderVal may be interpolated with the volume content when slightly out of bounds (OpenGL behavior)
wasInsideOptional output variable indicating whether position was inside the volume
Template Parameters
TType of the N-cell data to interpolate
NDimensionality of the image to interpolate

◆ linearClampToBorder() [3/3]

template<typename T, int N>
void linearClampToBorder ( const TypedImage< T > & img,
const vecNd< N > & position,
double * output,
const double * borderVal,
bool interpolateBorder,
bool * wasInside = nullptr )

Convenience overload for N-dimensional linear interpolation with border value of a TypedImage.

The N-cells are assumed to be centered on integer coordinates and have a diameter of 1. This version treats all N-cells outside of the given volume as having the value borderVal.

Parameters
nCellDataRaw N-cell data in the shape of dimensions and nChannels
positionLookup coordinate in N-cell space
outputOutput buffer for interpolated value, buffer needs to be able to hold nChannels values
borderValIntensity value outside the volume, buffer needs to hold nChannels values
interpolateBorderWhether borderVal may be interpolated with the volume content when slightly out of bounds (OpenGL behavior)
wasInsideOptional output variable indicating whether position was inside the volume
Template Parameters
TType of the N-cell data to interpolate
NDimensionality of the image to interpolate

◆ linearClampToEdge() [1/6]

template<typename T, int N>
void linearClampToEdge ( const T * nCellData,
const vecNi< N > & dim,
int nChannels,
vecNd< N > position,
double * output )

N-dimensional linear interpolation with clamping.

The N-cells are assumed to be centered on integer coordinates and have a diameter of 1. This version clamps the lookup position to end up inside the volume.

Parameters
N-cellDataRaw N-cell data in the shape of dimensions and nChannels
dimensionsNumber of N-cells in each dimension in input data
nChannelsNumber of color channels in input data
positionLookup coordinate in N-cell space
outputOutput buffer for interpolated value, buffer needs to be able to hold nChannels values
Template Parameters
TType of the N-cell data to interpolate
NDimensionality of the image to interpolate

◆ linearClampToEdge() [2/6]

template<typename T>
void linearClampToEdge ( const T * nCellData,
int dim,
int nChannels,
double position,
double * output )

Convenience overload for 1D linear interpolation with clamping.

N-dimensional linear interpolation with clamping.

The N-cells are assumed to be centered on integer coordinates and have a diameter of 1. This version clamps the lookup position to end up inside the volume.

Parameters
N-cellDataRaw N-cell data in the shape of dimensions and nChannels
dimensionsNumber of N-cells in each dimension in input data
nChannelsNumber of color channels in input data
positionLookup coordinate in N-cell space
outputOutput buffer for interpolated value, buffer needs to be able to hold nChannels values
Template Parameters
TType of the N-cell data to interpolate
NDimensionality of the image to interpolate

◆ linearClampToEdge() [3/6]

template<typename T, int N>
void linearClampToEdge ( const TypedImage< T > & img,
const vecNd< N > & position,
double * output )

Convenience overload for N-dimensional linear interpolation with clamping of a TypedImage.

The N-cells are assumed to be centered on integer coordinates and have a diameter of 1. This version clamps the lookup position to end up inside the volume.

Parameters
nCellDataRaw N-cell data in the shape of dimensions and nChannels
positionLookup coordinate in N-cell space
outputOutput buffer for interpolated value, buffer needs to be able to hold nChannels values
Template Parameters
TType of the N-cell data to interpolate
NDimensionality of the image to interpolate

◆ linearClampToEdge() [4/6]

template<typename T, int N>
void linearClampToEdge ( const T * nCellData,
const vecNi< N > & dim,
int nChannels,
const vecNd< N > & position,
double * output,
bool & wasInside )

N-dimensional linear interpolation with clamping.

The N-cells are assumed to be centered on integer coordinates and have a diameter of 1. This version clamps the lookup position to end up inside the volume and additionally outputs whether the original position was valid. Note that there is computational overhead for this additional output and that a version without it is available as well.

Parameters
nCellDataRaw N-cell data in the shape of dimensions and nChannels
dimensionsNumber of N-cells in each dimension in input data
nChannelsNumber of color channels in input data
positionLookup coordinate in N-cell space
outputOutput buffer for interpolated value, buffer needs to be able to hold nChannels values
wasInsideOutput variable whether the coordinate in position was inside the volume and did not have to be clamped
Template Parameters
TType of the N-cell data to interpolate
NDimensionality of the image to interpolate

◆ linearClampToEdge() [5/6]

template<typename T>
void linearClampToEdge ( const T * nCellData,
int dim,
int nChannels,
double position,
double * output,
bool & wasInside )

Convenience overload for 1D linear interpolation with clamping.

N-dimensional linear interpolation with clamping.

The N-cells are assumed to be centered on integer coordinates and have a diameter of 1. This version clamps the lookup position to end up inside the volume and additionally outputs whether the original position was valid. Note that there is computational overhead for this additional output and that a version without it is available as well.

Parameters
nCellDataRaw N-cell data in the shape of dimensions and nChannels
dimensionsNumber of N-cells in each dimension in input data
nChannelsNumber of color channels in input data
positionLookup coordinate in N-cell space
outputOutput buffer for interpolated value, buffer needs to be able to hold nChannels values
wasInsideOutput variable whether the coordinate in position was inside the volume and did not have to be clamped
Template Parameters
TType of the N-cell data to interpolate
NDimensionality of the image to interpolate

◆ linearClampToEdge() [6/6]

template<typename T, int N>
void linearClampToEdge ( const TypedImage< T > & img,
const vecNd< N > & position,
double * output,
bool & insideVolume )

Convenience overload for N-dimensional linear interpolation with clamping of a TypedImage.

The N-cells are assumed to be centered on integer coordinates and have a diameter of 1. This version clamps the lookup position to end up inside the volume and additionally outputs whether the original position was valid. Note that there is computational overhead for this additional output and that a version without it is available as well.

Parameters
nCellDataRaw N-cell data in the shape of dimensions and nChannels
positionLookup coordinate in N-cell space
outputOutput buffer for interpolated value, buffer needs to be able to hold nChannels values
wasInsideOutput variable whether the coordinate in position was inside the volume and did not have to be clamped
Template Parameters
TType of the N-cell data to interpolate
NDimensionality of the image to interpolate

◆ linearLegacy()

template<typename T, int N>
bool linearLegacy ( const T * nCellData,
const vecNi< N > & dim,
int nChannels,
const vecNd< N > & position,
double * output,
const double * borderVal,
bool clamp )

N-dimensional linear interpolation with same clamping behavior as the deprecated Math::interp functions.

Interpolates using N-cell coordinates.

The N-cells are assumed to be centered on integer coordinates and have a diameter of 1. The boundary behavior is as follows:

  • If the target is more than half a N-cell out of bounds, the clamp param is ignored and the border value is returned. This includes close cases where OpenGL would still interpolate with the edge N-cells.
  • If the target is less than half a N-cell out of bounds and clamp is disabled, the border value is returned as well.
  • If instead clamp is enabled, the method clamps to the edge N-cells in this case. Note that as a consequence of the behavior above, the borderVal is never interpolated.
  • If clamp=true the return value specifies whether the operation did not require clamping to edge.
  • If clamp=false the return value instead specifies whether the operation did not interpolate with the border. Note that for N-cells close to the boundary but still within the volume this is not equivalent.
Parameters
vN-cell data
dimData size in N-cells
nChannelsNumber of color channels in input data
xLookup coordinate in N-cells
outputInterpolated value, buffer needs to be able to hold nChannels values
borderValIntensity value outside the volume, buffer needs to hold nChannels values
clampControls out of bounds clamping behavior, see above
Search Tab / S to search, Esc to close