CVR-Lib last update 20 Sep 2009

cvr::genericInterpolation< T > Class Template Reference

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

#include <cvrGenericInterpolation.h>

Inheritance diagram for cvr::genericInterpolation< T >:

Inheritance graph
[legend]
Collaboration diagram for cvr::genericInterpolation< T >:

Collaboration graph
[legend]

List of all members.

Classes

class  parameters
 The parameters for the class genericInterpolation. More...

Public Types

enum  eInterpolationKernelType { BilinearKernel, BicubicKernel, GenericKernel }

Public Member Functions

 genericInterpolation ()
 genericInterpolation (const parameters &params)
 genericInterpolation (const eBoundaryType boundaryType)
 genericInterpolation (const genericInterpolation< T > &other)
virtual ~genericInterpolation ()
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 fpoint &p) const
apply (const float &row, const float &col) const
apply (const fpoint &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) const
interpolateUnchk (const float row, const float col) const
genericInterpolationcopy (const genericInterpolation &other)
genericInterpolation< T > & operator= (const genericInterpolation< T > &other)
virtual const std::string & name () const
virtual genericInterpolationclone () const
virtual genericInterpolationnewInstance () const
const parametersgetParameters () const
virtual bool updateParameters ()
int getRangeOfInfluence () const
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 rangeOfInfluence_
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 cvr::genericInterpolation< T >

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

The LUTs 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.


Member Enumeration Documentation

Types for interpolation kernels.

Enumerator:
BilinearKernel  Bilinear interpolation kernel.

The neighborhood size is always 2x2. This implementation is slower than the optimized version in the functor cvr::bilinearInterpolation, but is provided for completeness.

BicubicKernel  Bicubic interpolation.

The neighborhood size is always 4x4. The kernel provided here is after Sonka et.al. pp. 67

\[ h(x)=\begin{cases} 1-2|x|^2+|x|^3 & \text{for $0\leq|x|\leq 1$} \\ 4-8|x|+5|x|^2-|x|^3 & \text{for $1\leq|x|\leq 2$}\\ 0 & \text{otherwise} \end{cases} \]

GenericKernel  Generic interpolation.

The generic interpolation uses the kernelLUT given in the parameters.


Constructor & Destructor Documentation

template<class T>
cvr::genericInterpolation< T >::genericInterpolation (  ) 

default constructor

template<class T>
cvr::genericInterpolation< T >::genericInterpolation ( const parameters params  ) 

Construct an interpolator with the given parameters.

template<class T>
cvr::genericInterpolation< T >::genericInterpolation ( const eBoundaryType  boundaryType  ) 

Construct an interpolator with the given boundary type.

template<class T>
cvr::genericInterpolation< T >::genericInterpolation ( const genericInterpolation< T > &  other  ) 

copy constructor

Parameters:
other the object to be copied

template<class T>
virtual cvr::genericInterpolation< T >::~genericInterpolation (  )  [virtual]

destructor


Member Function Documentation

template<class T>
T cvr::genericInterpolation< T >::apply ( const fpoint 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 cvr::fixedGridInterpolation< T >.

template<class T>
T cvr::genericInterpolation< 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 cvr::fixedGridInterpolation< T >.

template<class T>
T cvr::genericInterpolation< T >::apply ( const matrix< T > &  src,
const fpoint 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 cvr::fixedGridInterpolation< T >.

template<class T>
T cvr::genericInterpolation< 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 cvr::fixedGridInterpolation< T >.

template<class T>
T cvr::genericInterpolation< 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 cvr::fixedGridInterpolation< T >.

template<class T>
T cvr::genericInterpolation< 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 cvr::fixedGridInterpolation< T >.

template<class T>
virtual genericInterpolation* cvr::genericInterpolation< T >::clone (  )  const [virtual]

returns a pointer to a clone of this functor.

Implements cvr::functor.

template<class T>
T cvr::genericInterpolation< 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 cvr::genericInterpolation< 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>
genericInterpolation& cvr::genericInterpolation< T >::copy ( const genericInterpolation< T > &  other  ) 

copy data of "other" functor.

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

template<class T>
const vector<float>& cvr::genericInterpolation< 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& cvr::genericInterpolation< T >::getParameters (  )  const

returns used parameters

Reimplemented from cvr::fixedGridInterpolation< T >.

template<class T>
int cvr::genericInterpolation< T >::getRangeOfInfluence (  )  const [virtual]

This method returns which pixel range around the interpolated postition is considered by the interpolation functor.

This is very useful for other functors to decide whether they should call the interpolate() methods or the faster interpolateUnchk() methods.

If the returned value is $a$ and the interpolated position is $(x,y)$ all pixels with coordinates in $ [x-a .. x+a] \times [y-a .. y+a] $ may be considered by the interpolation functor.

Implements cvr::fixedGridInterpolation< T >.

template<class T>
bool cvr::genericInterpolation< 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 cvr::genericInterpolation< T >::initBilinearLUT (  )  [protected]

Initialization of the bilinear kernel.

Two unit intervals wlll be initialized.

template<class T>
bool cvr::genericInterpolation< 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 cvr::genericInterpolation< 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 cvr::genericInterpolation< 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 cvr::genericInterpolation< 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.

template<class T>
T cvr::genericInterpolation< T >::interpolateUnchk ( 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 cvr::genericInterpolation< T >::interpolateUnchk ( const matrix< T > &  src,
const float  row,
const float  col 
) const [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 const std::string& cvr::genericInterpolation< T >::name (  )  const [virtual]

Returns the name of this type.

Reimplemented from cvr::fixedGridInterpolation< T >.

template<class T>
virtual genericInterpolation* cvr::genericInterpolation< T >::newInstance (  )  const [virtual]

returns a pointer to a new instance of this functor.

Implements cvr::functor.

template<class T>
genericInterpolation<T>& cvr::genericInterpolation< T >::operator= ( const genericInterpolation< T > &  other  ) 

Alias for copy member.

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

template<class T>
virtual bool cvr::genericInterpolation< T >::updateParameters (  )  [virtual]

returns used parameters

Reimplemented from cvr::parametersManager.


Member Data Documentation

template<class T>
matrix<T> cvr::genericInterpolation< 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** cvr::genericInterpolation< T >::bufferRows_ [protected]

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

template<class T>
vector<T> cvr::genericInterpolation< T >::column_ [protected]

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

template<class T>
T* cvr::genericInterpolation< T >::firstElemColumn_ [protected]

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

template<class T>
int cvr::genericInterpolation< 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> cvr::genericInterpolation< T >::interpolationKernel_ [protected]

Interpolation kernel.

This is initialized by the initLUT

template<class T>
int cvr::genericInterpolation< T >::intervalSize_ [protected]

Interval size taken from the parameters numSamplesPerInterval;.

template<class T>
int cvr::genericInterpolation< 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 cvr::genericInterpolation< 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>
int cvr::genericInterpolation< T >::rangeOfInfluence_ [protected]

range of influence

template<class T>
const T** cvr::genericInterpolation< 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 Sun Sep 20 22:08:45 2009 for CVR-Lib by Doxygen 1.5.8