latest version v1.9 - last update 10 Apr 2010 |
Image pyramid to represent the scale space. More...
#include <ltiScaleSpacePyramid.h>
Classes | |
class | parameters |
Parameters for the generation of scaleSpace pyramids. More... | |
Public Types | |
enum | eExtremaType { NoExtremum = 0, Minimum, Maximum } |
typedef T::value_type | value_type |
Public Member Functions | |
scaleSpacePyramid () | |
scaleSpacePyramid (const int levels, const parameters &par=parameters()) | |
scaleSpacePyramid (const scaleSpacePyramid< T > &other) | |
virtual | ~scaleSpacePyramid () |
virtual const char * | getTypeName () const |
scaleSpacePyramid< T > & | copy (const scaleSpacePyramid< T > &other) |
scaleSpacePyramid< T > & | operator= (const scaleSpacePyramid< T > &other) |
virtual mathObject * | clone () const |
void | resize (const int &levels, const bool ©Data=true) |
virtual bool | setParameters (const parameters &par) |
const parameters & | getParameters () const |
void | generate (const T &src) |
void | generate (const T &src, const int &numLevels) |
float | getScaleForRadius (const float radius) const |
float | getRadiusForScale (const float scale) const |
const double & | getLevelScale (const int level) const |
eExtremaType | interpolateExtremum (const int row, const int col, const int level, float &spRow, float &spCol) const |
eExtremaType | interpolateExtremum (const int row, const int col, const int level, float &spRow, float &spCol, float &scale) const |
bool | interpolateMaximum (const int row, const int col, const int level, float &spRow, float &spCol) const |
bool | interpolateMaximum (const int row, const int col, const int level, float &spRow, float &spCol, float &scale) const |
bool | checkMaximum (const int row, const int col, const int level) const |
bool | checkInterlevelMaximum (const int row, const int col, const int level) const |
void | mapToLevel0 (const int level, const float row, const float col, float &row0, float &col0) const |
void | mapToLevel (const int level, const float &row0, const float &col0, float &row, float &col) const |
void | mapToLevel (const int fromLevel, const int toLevel, const float &rowFrom, const float &colFrom, float &rowTo, float &colTo) const |
Scale-space access operators | |
The scale space can be accessed at any real x,y and scale values. Interpolation is necessary to get a spatial subpixel or a value between scales. The methods can use several one-dimensional interpolations, which is relative fast to compute, or can use more precise but much expensive two or three dimensional interpolation polynoms. The spatial coordinates are always given with respect to the first level (level 0), which mean they must be between (0,0) and (at(0).lastColumn(),at(0).lastRow()). | |
value_type | nearestAt (const float y, const float x, const int lev) const |
value_type | bilinearAt (const float y, const float x, const int lev) const |
value_type | biquadraticAt (const float y, const float x, const int lev) const |
value_type | quadraticAt (const float y, const float x, const int lev) const |
value_type | trilinearAt (const float y, const float x, const float s) const |
value_type | triquadraticAt (const float y, const float x, const float s) const |
value_type | quadraticAt (const float y, const float x, const float s) const |
Protected Member Functions | |
value_type | cstAt (const T &img, const int y, const int x) const |
const value_type & | tacc (const value_type &in, value_type &out) const |
void | initLevelFactor () |
Protected Attributes | |
nearestNeighborInterpolator < value_type > | nnIpl |
bilinearInterpolator< value_type > | bilinIpl |
biquadraticInterpolator < value_type > | biquadIpl |
parameters | param |
dvector | levelFactor |
Image pyramid to represent the scale space.
This pyramid can be used for scale-dependent image access. At construction time the input channel is downsampled to several scales as specified with the resize()-method.
Each channel is downsampled by "factor"-parameter with Gaussian convolution applied. This factor is usually greater than 0.5 (the usual one in image pyramids), but still must be less than 1.0. This is done to archieve a much higher precision.
As with other pyramids, the template type T represents the image type. Usually you will want to use an scaleSpacePyramid<channel>.
For this class the term "level" denotes one of the existent layers of the pyramid. The term "scale" denotes a real value. The "levels" have explicit scales, that can be obtaind with getLevelScale().
typedef T::value_type lti::scaleSpacePyramid< T >::value_type |
Type of elements of the channels of type T.
enum lti::scaleSpacePyramid::eExtremaType |
lti::scaleSpacePyramid< T >::scaleSpacePyramid | ( | ) |
Default constructor.
lti::scaleSpacePyramid< T >::scaleSpacePyramid | ( | const int | levels, | |
const parameters & | par = parameters() | |||
) |
Create a pyramid with the given number of levels and the given parameters.
lti::scaleSpacePyramid< T >::scaleSpacePyramid | ( | const scaleSpacePyramid< T > & | other | ) |
Copy constructor.
other | the object to be copied |
virtual lti::scaleSpacePyramid< T >::~scaleSpacePyramid | ( | ) | [virtual] |
Destructor.
value_type lti::scaleSpacePyramid< T >::bilinearAt | ( | const float | y, | |
const float | x, | |||
const int | lev | |||
) | const |
Get an "in level" bilinear interpolation.
The given level lev must be in the pyramid.
value_type lti::scaleSpacePyramid< T >::biquadraticAt | ( | const float | y, | |
const float | x, | |||
const int | lev | |||
) | const |
Get an "in level" biquadratic interpolation.
The given level lev must be in the pyramid.
bool lti::scaleSpacePyramid< T >::checkInterlevelMaximum | ( | const int | row, | |
const int | col, | |||
const int | level | |||
) | const |
Check if the given pixel at the given level (in the respective coordinates) is a maximum in the 3x3x3 neighborhood.
row | row of the point to be checked. It must be between 0 and at(level).lastRow(), but for the borders false will be always returned, as a "constant boundary" will be always assumed. | |
col | column of the point to be checked. It must be between 0 and at(level).lastColumn(), but for the borders false will be always returned, as a "constant boundary" will be always assumed. | |
level | the level where the maximum has to be checked. |
bool lti::scaleSpacePyramid< T >::checkMaximum | ( | const int | row, | |
const int | col, | |||
const int | level | |||
) | const |
Check if the given pixel at the given level (in the respective coordinate system) is a maximum in the 3x3 neighborhood.
row | row of the point to be checked. It must be between 0 and at(level).lastRow(), but for the borders false will be always returned, as a "constant boundary" will be always assumed. | |
col | column of the point to be checked. It must be between 0 and at(level).lastColumn(), but for the borders false will be always returned, as a "constant boundary" will be always assumed. | |
level | the level where the maximum has to be checked. |
virtual mathObject* lti::scaleSpacePyramid< T >::clone | ( | ) | const [virtual] |
Returns a pointer to a clone of this pyramid.
Reimplemented from lti::pyramid< T >.
scaleSpacePyramid<T>& lti::scaleSpacePyramid< T >::copy | ( | const scaleSpacePyramid< T > & | other | ) |
Copy data of "other" functor.
other | the functor to be copied |
Reimplemented from lti::pyramid< T >.
value_type lti::scaleSpacePyramid< T >::cstAt | ( | const T & | img, | |
const int | y, | |||
const int | x | |||
) | const [inline, protected] |
Access with constant boundary.
void lti::scaleSpacePyramid< T >::generate | ( | const T & | src, | |
const int & | numLevels | |||
) |
void lti::scaleSpacePyramid< T >::generate | ( | const T & | src | ) |
const double& lti::scaleSpacePyramid< T >::getLevelScale | ( | const int | level | ) | const [inline] |
Return the scale for the levels of the pyramid.
const parameters& lti::scaleSpacePyramid< T >::getParameters | ( | ) | const |
Get a read-only reference to parameters.
float lti::scaleSpacePyramid< T >::getRadiusForScale | ( | const float | scale | ) | const |
Get the radius of one "pixel" for the given level.
At the level 0, the radius of a pixel is 0.5.
float lti::scaleSpacePyramid< T >::getScaleForRadius | ( | const float | radius | ) | const |
Get the scale corresponding for a circular area of the given radius.
At the scale 0, the radius of a pixel is 0.5.
virtual const char* lti::scaleSpacePyramid< T >::getTypeName | ( | ) | const [virtual] |
Returns the name of this type ("scaleSpacePyramid\<T\>").
Reimplemented from lti::pyramid< T >.
void lti::scaleSpacePyramid< T >::initLevelFactor | ( | ) | [protected] |
Initialize the values for the levelFactor.
It assumes that the vector has the proper size.
eExtremaType lti::scaleSpacePyramid< T >::interpolateExtremum | ( | const int | row, | |
const int | col, | |||
const int | level, | |||
float & | spRow, | |||
float & | spCol, | |||
float & | scale | |||
) | const |
Seaches for an extremum with sub-pixel accuracy in a 3x3x3 region around the given access point.
A 3D quadratic function will be used to compute the sub-pixel values.
This function will only work if the parameters::factor is in ]0.5,1.0[.
Note that in makes only sense to call this method if the (col,row) point of the given level is already a extremum in the discrete coordinates system, i.e. if the point is greater than its 26 neighbors. Otherwise this method will just return "NoExtremum".
row | row in coordinates of the given level, i.e. this value must be between 0 and at(level).rows() | |
col | column in coordinates of the given level, i.e. this value must be between 0 and at(level).columns() | |
level | level at which the extremum must be looked for. | |
spRow | in case an extremum is found in the 3x3x3 region, this is the row of the found extremum using the coordinates of the corresponding level. | |
spCol | in case an extremum is found in the 3x3x3 region, this is the column of the found extremum using the coordinates of the corresponding level. | |
scale | in case an extremum is found in the 3x3x3 region, this is the scale of the found extremum. |
eExtremaType lti::scaleSpacePyramid< T >::interpolateExtremum | ( | const int | row, | |
const int | col, | |||
const int | level, | |||
float & | spRow, | |||
float & | spCol | |||
) | const |
Seaches for an extremum with sub-pixel accuracy in a 3x3 region around the given access point.
A 2D quadratic function will be used to compute the sub-pixel values.
Note that it only makes sense to call this method if the (col,row) point of the given level is already a extremum or a minimum in the discrete coordinates system, i.e. if the point is greater (smaller) than its eight neighbors. Otherwise this method will just return "NoExtremum".
row | row in coordinates of the given level, i.e. this value must be between 0 and at(level).rows() | |
col | column in coordinates of the given level, i.e. this value must be between 0 and at(level).columns() | |
level | level at which the extremum must be looked for. | |
spRow | in case a extremum is found in the 3x3 region, this is the row of the found extremum using the coordinates of the corresponding level. | |
spCol | in case a extremum is found in the 3x3 region, this is the column of the found extremum using the coordinates of the corresponding level. |
bool lti::scaleSpacePyramid< T >::interpolateMaximum | ( | const int | row, | |
const int | col, | |||
const int | level, | |||
float & | spRow, | |||
float & | spCol, | |||
float & | scale | |||
) | const |
Seaches the maximum with sub-pixel accuracy in a 3x3x3 region around the access point.
A 3D quadratic function will be used to compute the sub-pixel values.
This function will only work if the parameters::factor is in ]0.5,1.0[.
Note that in makes only sense to call this method if the (col,row) point of the given level is already a maximum in the discrete coordinates system, i.e. if the point is greater than its 26 neighbors. Otherwise this method will just return false
row | row in coordinates of the given level, i.e. this value must be between 0 and at(level).rows() | |
col | column in coordinates of the given level, i.e. this value must be between 0 and at(level).columns() | |
level | level at which the maximum must be looked for. | |
spRow | in case a maximum is found in the 3x3x3 region, this is the row of the found extremum using the coordinates of the corresponding level. | |
spCol | in case an maximum is found in the 3x3x3 region, this is the column of the found extremum using the coordinates of the corresponding level. | |
scale | in case an maximum is found in the 3x3x3 region, this is the scale of the found extremum. |
bool lti::scaleSpacePyramid< T >::interpolateMaximum | ( | const int | row, | |
const int | col, | |||
const int | level, | |||
float & | spRow, | |||
float & | spCol | |||
) | const |
Seaches the maximum with sub-pixel accuracy in a 3x3 region around the access point.
A 2D quadratic function will be used to compute the sub-pixel values.
Note that in makes only sense to call this method if the (col,row) point of the given level is already a maximum in the discrete coordinates system, i.e. if the point is greater than its eight neighbors. Otherwise this method will just return false
row | row in coordinates of the given level, i.e. this value must be between 0 and at(level).rows() | |
col | column in coordinates of the given level, i.e. this value must be between 0 and at(level).columns() | |
level | level at which the maximum must be looked for. | |
spRow | in case a maximum is found in the 3x3 region, this is the row of the found maximum using the coordinates of the corresponding level. | |
spCol | in case a maximum is found in the 3x3 region, this is the column of the found maximum using the coordinates of the corresponding level. |
void lti::scaleSpacePyramid< T >::mapToLevel | ( | const int | fromLevel, | |
const int | toLevel, | |||
const float & | rowFrom, | |||
const float & | colFrom, | |||
float & | rowTo, | |||
float & | colTo | |||
) | const [inline] |
Map the coordinates from level "from" to level "to".
void lti::scaleSpacePyramid< T >::mapToLevel | ( | const int | level, | |
const float & | row0, | |||
const float & | col0, | |||
float & | row, | |||
float & | col | |||
) | const [inline] |
Map the coordinates of level 0 into the coordinates of the given level.
void lti::scaleSpacePyramid< T >::mapToLevel0 | ( | const int | level, | |
const float | row, | |||
const float | col, | |||
float & | row0, | |||
float & | col0 | |||
) | const [inline] |
Map the coordinates of the given level into coordinates of level 0.
value_type lti::scaleSpacePyramid< T >::nearestAt | ( | const float | y, | |
const float | x, | |||
const int | lev | |||
) | const |
Get an "in level" nearest neighbor interpolation.
The given level lev must be in the pyramid.
scaleSpacePyramid<T>& lti::scaleSpacePyramid< T >::operator= | ( | const scaleSpacePyramid< T > & | other | ) |
Alias for copy member.
other | the functor to be copied |
Reimplemented from lti::pyramid< T >.
value_type lti::scaleSpacePyramid< T >::quadraticAt | ( | const float | y, | |
const float | x, | |||
const float | s | |||
) | const |
Compute for the given (x,y) spatial coordinates three "in-level" quadratic interpolations at the three nearest levels of the given scale s, and from the three new values interpolate quadratically for the corresponding scale value.
The given scale s must be in the pyramid, i.e. s>=0 and s<=parametersfactor^(size()-1)
This is therefore a combination between 2D and 1D quadratic interpolations.
Note that if the scale s is integer it is faster to call the other quadraticAt method that expects the level of the pyramid.
value_type lti::scaleSpacePyramid< T >::quadraticAt | ( | const float | y, | |
const float | x, | |||
const int | lev | |||
) | const |
Get an "in level" quadratic interpolation.
The given level lev must be in the pyramid.
Since the pixel (x,y) at level lev has eight neighbors and the quadratic function only six coefficients, the least square error quadratic surface passing exactly through the middle point will be computed, i.e. five of the six coefficients will be determined using the eight neighbor points of the middle one.
Please note that there is an overload of this function for a scale value s instead of a level, which does a similar task but also interpolates between levels (see quadraticAt(const float,const float,const float)).
void lti::scaleSpacePyramid< T >::resize | ( | const int & | levels, | |
const bool & | copyData = true | |||
) | [virtual] |
Change the number of resolutions of the pyramid.
levels | the new number of levels or layers of the pyramid | |
copyData | if true (default), the old data will be keeped. If false, all data will be lost. |
Reimplemented from lti::pyramid< T >.
virtual bool lti::scaleSpacePyramid< T >::setParameters | ( | const parameters & | par | ) | [virtual] |
set parameters
const value_type& lti::scaleSpacePyramid< T >::tacc | ( | const value_type & | in, | |
value_type & | out | |||
) | const [inline, protected] |
This "transparent" accumulator returns the first input value, while it accumulates in the second variable.
value_type lti::scaleSpacePyramid< T >::trilinearAt | ( | const float | y, | |
const float | x, | |||
const float | s | |||
) | const |
Get a "between-scales" trilinear interpolation.
The given scale s must be in the pyramid, i.e. s>=0 and s<=parametersfactor^size()-1
value_type lti::scaleSpacePyramid< T >::triquadraticAt | ( | const float | y, | |
const float | x, | |||
const float | s | |||
) | const |
Get an "between-scales" triquadratic interpolation.
The given scale s must be in the pyramid, i.e. s>=0 and s<=parametersfactor^size()-1
bilinearInterpolator<value_type> lti::scaleSpacePyramid< T >::bilinIpl [protected] |
Functor used to bilinear interpolate.
biquadraticInterpolator<value_type> lti::scaleSpacePyramid< T >::biquadIpl [protected] |
Functor used to biquadratic interpolate.
dvector lti::scaleSpacePyramid< T >::levelFactor [protected] |
nearestNeighborInterpolator<value_type> lti::scaleSpacePyramid< T >::nnIpl [protected] |
Functor used for nearest neighbor interpolation.
parameters lti::scaleSpacePyramid< T >::param [protected] |
The parameters in use.