LTI-Lib latest version v1.9 - last update 10 Apr 2010

lti::genericInterpolator< T > Class Template Reference

This functor use a generic interpolation concept based on look-up-tables for the interpolation kernels. More...

#include <ltiGenericInterpolator.h>

Inheritance diagram for lti::genericInterpolator< T >:
Inheritance graph
[legend]
Collaboration diagram for lti::genericInterpolator< T >:
Collaboration graph
[legend]

List of all members.

Classes

class  parameters
 The parameters for the class genericInterpolator. More...

Public Member Functions

 genericInterpolator ()
 genericInterpolator (const parameters &params)
 genericInterpolator (const eBoundaryType boundaryType)
 genericInterpolator (const genericInterpolator< T > &other)
virtual ~genericInterpolator ()
virtual const char * getTypeName () const
apply (const vector< T > &src, const float &x) const
apply (const float &x) const
apply (const matrix< T > &src, const float &row, const float &col) const
apply (const matrix< T > &src, const tpoint< float > &p) const
apply (const float &row, const float &col) const
apply (const tpoint< float > &p) const
interpolate (const matrix< T > &src, const float row, const float col) const
interpolate (const float row, const float col) const
interpolateUnchk (const matrix< T > &src, const float row, const float col)
interpolateUnchk (const float row, const float col)
genericInterpolatorcopy (const genericInterpolator &other)
virtual functorclone () const
const parametersgetParameters () const
virtual bool updateParameters ()
const vector< float > & getLUT () const
compute (const float fx, const T *data) const
compute (const float fy, const float fx, const T **data) const

Protected Attributes

int lastIntervalFirstSample
int numberOfIntervals
int firstSampleOffset
int intervalSize
Buffers



vector< T > column
T * firstElemColumn
matrix< T > buffer
const T ** rows
const T ** bufferRows

Kernel initialization routines



vector< float > interpolationKernel
bool initLUT ()
bool initBilinearLUT ()
bool initBicubicLUT ()
bool initGenericLUT ()

Detailed Description

template<class T>
class lti::genericInterpolator< T >

This functor use a generic interpolation concept based on look-up-tables for the interpolation kernels.

The LUT allow to considerably accelerate the computation times, but a little bit precision is lost due to the unavoidable quantization present in the LUT.

The type T of the template is the type of the elements of the vector or matrix used.


Constructor & Destructor Documentation

template<class T>
lti::genericInterpolator< T >::genericInterpolator (  ) 

default constructor

template<class T>
lti::genericInterpolator< T >::genericInterpolator ( const parameters params  ) 

Construct an interpolator with the given parameters.

template<class T>
lti::genericInterpolator< T >::genericInterpolator ( const eBoundaryType  boundaryType  ) 

Construct an interpolator with the given boundary type.

template<class T>
lti::genericInterpolator< T >::genericInterpolator ( const genericInterpolator< T > &  other  ) 

copy constructor

Parameters:
other the object to be copied
template<class T>
virtual lti::genericInterpolator< T >::~genericInterpolator (  )  [virtual]

destructor


Member Function Documentation

template<class T>
T lti::genericInterpolator< T >::apply ( const tpoint< float > &  p  )  const [virtual]

Returns the interpolated value of the matrix specified with use() at the real valued position p.

Parameters:
p the real valued position to be interpolated.
Returns:
the interpolated value of the matrix.

Implements lti::scalarValuedInterpolation< T >.

template<class T>
T lti::genericInterpolator< T >::apply ( const float &  row,
const float &  col 
) const [virtual]

Returns the interpolated value of the matrix specified with use() at the real valued position (row,col).

Parameters:
row which row
col which column
Returns:
the interpolated value of the matrix.

Implements lti::scalarValuedInterpolation< T >.

template<class T>
T lti::genericInterpolator< T >::apply ( const matrix< T > &  src,
const tpoint< float > &  p 
) const [virtual]

Returns the interpolated value of the matrix at the real valued position p.

Parameters:
src matrix<T> with the source data.
p the real valued position to be interpolated.
Returns:
the interpolated value of the matrix.

Implements lti::scalarValuedInterpolation< T >.

template<class T>
T lti::genericInterpolator< T >::apply ( const matrix< T > &  src,
const float &  row,
const float &  col 
) const [virtual]

Returns the interpolated value of the matrix at the real valued position (row,col).

Parameters:
src matrix<T> with the source data.
row which row
col which column
Returns:
the interpolated value of the matrix.

Implements lti::scalarValuedInterpolation< T >.

template<class T>
T lti::genericInterpolator< T >::apply ( const float &  x  )  const [virtual]

Returns the interpolated value of the vector specified with use() at the real valued position x.

Parameters:
x the real valued position to be interpolated.
Returns:
the interpolated value of the vector.

Implements lti::scalarValuedInterpolation< T >.

template<class T>
T lti::genericInterpolator< T >::apply ( const vector< T > &  src,
const float &  x 
) const [virtual]

Returns the interpolated value of the vector at the real valued position x.

Parameters:
src vector<T> with the source data.
x the real valued position to be interpolated.
Returns:
the interpolated value of the vector.

Implements lti::scalarValuedInterpolation< T >.

template<class T>
virtual functor* lti::genericInterpolator< T >::clone (  )  const [virtual]

returns a pointer to a clone of this functor.

Implements lti::scalarValuedInterpolation< T >.

template<class T>
T lti::genericInterpolator< T >::compute ( const float  fy,
const float  fx,
const T **  data 
) const [inline]

Compute the generic interpolated value for the given coefficients and values.

This method is provided for convenience only. Use at your own risk.

Parameters:
fy fractional term between 0.0 and 1.0
fx fractional term between 0.0 and 1.0
data pointer to an array of arrays with the support samples.
Returns:
interpolated value between the four corners
template<class T>
T lti::genericInterpolator< T >::compute ( const float  fx,
const T *  data 
) const [inline]

Compute the generic interpolated value for the given coefficients and values.

This method is provided for convenience only. Use at your own risk.

Parameters:
fx fractional term between 0.0f (inclusive) and 1.0f (exclusive)
data pointer to an array with the support samples. It has at least n elements, with n the number of unit intervals in the interpolation kernel. Their position will be assumed to be from -(n/2-1) to n/2, so that the interval 0..1 lies exaclty in the middle.
Returns:
interpolated value between the three values
template<class T>
genericInterpolator& lti::genericInterpolator< T >::copy ( const genericInterpolator< T > &  other  ) 

copy data of "other" functor.

Parameters:
other the functor to be copied
Returns:
a reference to this functor object

Reimplemented from lti::scalarValuedInterpolation< T >.

template<class T>
const vector<float>& lti::genericInterpolator< T >::getLUT (  )  const [inline]

Return a read only reference to the last computed LUT.

This method is mainly used for debugging purposes.

template<class T>
const parameters& lti::genericInterpolator< T >::getParameters (  )  const

returns used parameters

Reimplemented from lti::scalarValuedInterpolation< T >.

template<class T>
virtual const char* lti::genericInterpolator< T >::getTypeName (  )  const [virtual]

returns the name of this type ("genericInterpolator")

Reimplemented from lti::scalarValuedInterpolation< T >.

template<class T>
bool lti::genericInterpolator< T >::initBicubicLUT (  )  [protected]

Initialization of the bicubic kernel.

Four unit intervals wlll be initialized. The kernel provided here is after Sonka et.al. page 67:

           /     
          |  1-2|x|^2 + |x|^3           for 0<=x<=1
  h(x) = <   4-8|x|^2 + 5|x|^2 - |x|^3  for 1<x<=2
          |  0                          otherwise 
           \
template<class T>
bool lti::genericInterpolator< T >::initBilinearLUT (  )  [protected]

Initialization of the bilinear kernel.

Two unit intervals wlll be initialized.

template<class T>
bool lti::genericInterpolator< T >::initGenericLUT (  )  [protected]

Generic kernel initialization.

This method checks that the kernelLUT in the parameters is a valid kernel and sets all required attributes.

template<class T>
bool lti::genericInterpolator< T >::initLUT (  )  [protected]

Initialize the interpolation kernel LUT based on the parameters settings.

The LUT has only positive entries, but represents the interval from -halfSize+1 to halfSize. No use of the symmetrical properties of the kernel are exploited to improve efficiency, since less comparisons are required.

template<class T>
T lti::genericInterpolator< T >::interpolate ( const float  row,
const float  col 
) const [inline]

Returns the interpolated value of the matrix specified with use() at the real valued position (row,col).

This method is not virtual and can be used if this interpolation type is used as template parameter in time critical situations

Parameters:
row which row
col which column
Returns:
the interpolated value of the matrix.
template<class T>
T lti::genericInterpolator< T >::interpolate ( const matrix< T > &  src,
const float  row,
const float  col 
) const

Returns the interpolated value of the matrix at the real valued position (row,col).

This method is not virtual and can be used if this interpolation type is used as template parameter in time critical situations

Parameters:
src matrix<T> with the source data.
row which row
col which column
Returns:
the interpolated value of the matrix.

Referenced by lti::genericInterpolator< ubyte >::interpolate().

template<class T>
T lti::genericInterpolator< T >::interpolateUnchk ( const float  row,
const float  col 
) [inline]

Returns the interpolated value of the matrix specified with use() at the real valued position (row,col).

This method is not virtual and can be used if this interpolation type is used as template parameter in time critical situations

Parameters:
row which row
col which column
Returns:
the interpolated value of the matrix.
template<class T>
T lti::genericInterpolator< T >::interpolateUnchk ( const matrix< T > &  src,
const float  row,
const float  col 
) [inline]

Returns the interpolated value of the matrix at the real valued position (row,col).

This method does not check if the given coordinates and the rest of used points in the src matrix lie within the valid range. This is left to you. Please consider that for the generic interpolation not only the point(trunc(col),trunc(row)) is used, but a nxn neighborhood centered such that (col,row) is nearest to the center.

This method is not virtual and can be used in time critical situations, where you prefer to take the boundary control by yourself.

Parameters:
src matrix<T> with the source data.
row which row
col which column
Returns:
the interpolated value of the matrix.
template<class T>
virtual bool lti::genericInterpolator< T >::updateParameters (  )  [virtual]

returns used parameters

Reimplemented from lti::functor.


Member Data Documentation

template<class T>
matrix<T> lti::genericInterpolator< T >::buffer [mutable, protected]

This is a small window that can be used to save temporarily the sample supporting points.

template<class T>
const T** lti::genericInterpolator< T >::bufferRows [protected]

This is initialized to point a the buffer's rows.

template<class T>
vector<T> lti::genericInterpolator< T >::column [protected]

For the two dimensional interpolation, this vector will administrate the memory array required.

template<class T>
T* lti::genericInterpolator< T >::firstElemColumn [protected]

This pointer will always point to the first element of column.

template<class T>
int lti::genericInterpolator< T >::firstSampleOffset [protected]

This is the number that need to be substracted to a position point to get the first valid support sample.

It is usually numberOfIntervals/2 - 1;

template<class T>
vector<float> lti::genericInterpolator< T >::interpolationKernel [protected]

Interpolation kernel.

This is initialized by the initLUT

template<class T>
int lti::genericInterpolator< T >::intervalSize [protected]

Interval size taken from the parameters numSamplesPerInterval;.

template<class T>
int lti::genericInterpolator< T >::lastIntervalFirstSample [protected]

The interpolation kernel is traversed in revers order than the data.

To save the first computation time, we store the sample index for the first element of the last interval

template<class T>
int lti::genericInterpolator< T >::numberOfIntervals [protected]

Number of intervals really used.

The value given in the parameters might be ignored depending on the chosen kernel type.

template<class T>
const T** lti::genericInterpolator< T >::rows [mutable, protected]

This pointer to arrays is initialized to have the proper size, but you have to set the second pointers by yourself.


The documentation for this class was generated from the following file:

Generated on Sat Apr 10 15:27:20 2010 for LTI-Lib by Doxygen 1.6.1