![]() |
last update 20 Sep 2009 |
![]() |
#include <cvrGenericInterpolation.h>
Classes | |
class | parameters |
The parameters for the class genericInterpolation. More... | |
Public Types | |
enum | eInterpolationKernelType { BilinearKernel, BicubicKernel, GenericKernel } |
Public Member Functions | |
genericInterpolation () | |
genericInterpolation (const parameters ¶ms) | |
genericInterpolation (const eBoundaryType boundaryType) | |
genericInterpolation (const genericInterpolation< T > &other) | |
virtual | ~genericInterpolation () |
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 fpoint &p) const |
T | apply (const float &row, const float &col) const |
T | apply (const fpoint &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) const |
T | interpolateUnchk (const float row, const float col) const |
genericInterpolation & | copy (const genericInterpolation &other) |
genericInterpolation< T > & | operator= (const genericInterpolation< T > &other) |
virtual const std::string & | name () const |
virtual genericInterpolation * | clone () const |
virtual genericInterpolation * | newInstance () const |
const parameters & | getParameters () const |
virtual bool | updateParameters () |
int | getRangeOfInfluence () const |
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 | 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 () |
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.
enum cvr::genericInterpolation::eInterpolationKernelType |
Types for interpolation kernels.
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
|
GenericKernel |
Generic interpolation.
The generic interpolation uses the kernelLUT given in the parameters. |
cvr::genericInterpolation< T >::genericInterpolation | ( | ) |
default constructor
cvr::genericInterpolation< T >::genericInterpolation | ( | const parameters & | params | ) |
Construct an interpolator with the given parameters.
cvr::genericInterpolation< T >::genericInterpolation | ( | const eBoundaryType | boundaryType | ) |
Construct an interpolator with the given boundary type.
cvr::genericInterpolation< T >::genericInterpolation | ( | const genericInterpolation< T > & | other | ) |
virtual cvr::genericInterpolation< T >::~genericInterpolation | ( | ) | [virtual] |
destructor
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.
p | the real valued position to be interpolated. |
Implements cvr::fixedGridInterpolation< 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).
row | which row | |
col | which column |
Implements cvr::fixedGridInterpolation< 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.
src | matrix<T> with the source data. | |
p | the real valued position to be interpolated. |
Implements cvr::fixedGridInterpolation< 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).
src | matrix<T> with the source data. | |
row | which row | |
col | which column |
Implements cvr::fixedGridInterpolation< 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.
x | the real valued position to be interpolated. |
Implements cvr::fixedGridInterpolation< 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.
src | vector<T> with the source data. | |
x | the real valued position to be interpolated. |
Implements cvr::fixedGridInterpolation< T >.
virtual genericInterpolation* cvr::genericInterpolation< T >::clone | ( | ) | const [virtual] |
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.
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 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.
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. |
genericInterpolation& cvr::genericInterpolation< T >::copy | ( | const genericInterpolation< T > & | other | ) |
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.
const parameters& cvr::genericInterpolation< T >::getParameters | ( | ) | const |
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 and the interpolated position is
all pixels with coordinates in
may be considered by the interpolation functor.
Implements cvr::fixedGridInterpolation< 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 \
bool cvr::genericInterpolation< T >::initBilinearLUT | ( | ) | [protected] |
Initialization of the bilinear kernel.
Two unit intervals wlll be initialized.
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.
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.
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
row | which row | |
col | which column |
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
src | matrix<T> with the source data. | |
row | which row | |
col | which column |
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
row | which row | |
col | which column |
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.
src | matrix<T> with the source data. | |
row | which row | |
col | which column |
virtual const std::string& cvr::genericInterpolation< T >::name | ( | ) | const [virtual] |
virtual genericInterpolation* cvr::genericInterpolation< T >::newInstance | ( | ) | const [virtual] |
genericInterpolation<T>& cvr::genericInterpolation< T >::operator= | ( | const genericInterpolation< T > & | other | ) |
virtual bool cvr::genericInterpolation< T >::updateParameters | ( | ) | [virtual] |
matrix<T> cvr::genericInterpolation< T >::buffer_ [mutable, protected] |
This is a small window that can be used to save temporarily the sample supporting points.
const T** cvr::genericInterpolation< T >::bufferRows_ [protected] |
This is initialized to point a the buffer's rows.
vector<T> cvr::genericInterpolation< T >::column_ [protected] |
For the two dimensional interpolation, this vector will administrate the memory array required.
T* cvr::genericInterpolation< T >::firstElemColumn_ [protected] |
This pointer will always point to the first element of column.
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;
vector<float> cvr::genericInterpolation< T >::interpolationKernel_ [protected] |
Interpolation kernel.
This is initialized by the initLUT
int cvr::genericInterpolation< T >::intervalSize_ [protected] |
Interval size taken from the parameters numSamplesPerInterval;.
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
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.
int cvr::genericInterpolation< T >::rangeOfInfluence_ [protected] |
range of influence
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.