latest version v1.9 - last update 10 Apr 2010 |
This functor use a generic interpolation concept based on look-up-tables for the interpolation kernels. More...
#include <ltiGenericInterpolator.h>
Classes | |
class | parameters |
The parameters for the class genericInterpolator. More... | |
Public Member Functions | |
genericInterpolator () | |
genericInterpolator (const parameters ¶ms) | |
genericInterpolator (const eBoundaryType boundaryType) | |
genericInterpolator (const genericInterpolator< T > &other) | |
virtual | ~genericInterpolator () |
virtual const char * | getTypeName () const |
T | apply (const vector< T > &src, const float &x) const |
T | apply (const float &x) const |
T | apply (const matrix< T > &src, const float &row, const float &col) const |
T | apply (const matrix< T > &src, const tpoint< float > &p) const |
T | apply (const float &row, const float &col) const |
T | apply (const tpoint< float > &p) const |
T | interpolate (const matrix< T > &src, const float row, const float col) const |
T | interpolate (const float row, const float col) const |
T | interpolateUnchk (const matrix< T > &src, const float row, const float col) |
T | interpolateUnchk (const float row, const float col) |
genericInterpolator & | copy (const genericInterpolator &other) |
virtual functor * | clone () const |
const parameters & | getParameters () const |
virtual bool | updateParameters () |
const vector< float > & | getLUT () const |
T | compute (const float fx, const T *data) const |
T | 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 () |
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.
lti::genericInterpolator< T >::genericInterpolator | ( | ) |
default constructor
lti::genericInterpolator< T >::genericInterpolator | ( | const parameters & | params | ) |
Construct an interpolator with the given parameters.
lti::genericInterpolator< T >::genericInterpolator | ( | const eBoundaryType | boundaryType | ) |
Construct an interpolator with the given boundary type.
lti::genericInterpolator< T >::genericInterpolator | ( | const genericInterpolator< T > & | other | ) |
copy constructor
other | the object to be copied |
virtual lti::genericInterpolator< T >::~genericInterpolator | ( | ) | [virtual] |
destructor
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.
p | the real valued position to be interpolated. |
Implements lti::scalarValuedInterpolation< 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).
row | which row | |
col | which column |
Implements lti::scalarValuedInterpolation< 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.
src | matrix<T> with the source data. | |
p | the real valued position to be interpolated. |
Implements lti::scalarValuedInterpolation< 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).
src | matrix<T> with the source data. | |
row | which row | |
col | which column |
Implements lti::scalarValuedInterpolation< 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.
x | the real valued position to be interpolated. |
Implements lti::scalarValuedInterpolation< 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.
src | vector<T> with the source data. | |
x | the real valued position to be interpolated. |
Implements lti::scalarValuedInterpolation< T >.
virtual functor* lti::genericInterpolator< T >::clone | ( | ) | const [virtual] |
returns a pointer to a clone of this functor.
Implements lti::scalarValuedInterpolation< 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.
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. |
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.
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. |
genericInterpolator& lti::genericInterpolator< T >::copy | ( | const genericInterpolator< T > & | other | ) |
copy data of "other" functor.
other | the functor to be copied |
Reimplemented from lti::scalarValuedInterpolation< 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.
const parameters& lti::genericInterpolator< T >::getParameters | ( | ) | const |
returns used parameters
Reimplemented from lti::scalarValuedInterpolation< T >.
virtual const char* lti::genericInterpolator< T >::getTypeName | ( | ) | const [virtual] |
returns the name of this type ("genericInterpolator")
Reimplemented from lti::scalarValuedInterpolation< 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 \
bool lti::genericInterpolator< T >::initBilinearLUT | ( | ) | [protected] |
Initialization of the bilinear kernel.
Two unit intervals wlll be initialized.
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.
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.
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
row | which row | |
col | which column |
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
src | matrix<T> with the source data. | |
row | which row | |
col | which column |
Referenced by lti::genericInterpolator< ubyte >::interpolate().
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
row | which row | |
col | which column |
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.
src | matrix<T> with the source data. | |
row | which row | |
col | which column |
virtual bool lti::genericInterpolator< T >::updateParameters | ( | ) | [virtual] |
returns used parameters
Reimplemented from lti::functor.
matrix<T> lti::genericInterpolator< T >::buffer [mutable, protected] |
This is a small window that can be used to save temporarily the sample supporting points.
const T** lti::genericInterpolator< T >::bufferRows [protected] |
This is initialized to point a the buffer's rows.
vector<T> lti::genericInterpolator< T >::column [protected] |
T* lti::genericInterpolator< T >::firstElemColumn [protected] |
This pointer will always point to the first element of column.
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;
vector<float> lti::genericInterpolator< T >::interpolationKernel [protected] |
Interpolation kernel.
This is initialized by the initLUT
int lti::genericInterpolator< T >::intervalSize [protected] |
Interval size taken from the parameters numSamplesPerInterval;.
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
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.
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.