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

lti::geometricTransform Class Reference
[Simple geometry classes and functions]

This functor implements an generic geometric transform based on a homogeneous matrix, which is able to represent rotations, translations scalings and all other possibilites of homographies. More...

#include <ltiGeometricTransform.h>

Inheritance diagram for lti::geometricTransform:
Inheritance graph
[legend]
Collaboration diagram for lti::geometricTransform:
Collaboration graph
[legend]

List of all members.

Classes

struct  fastMatrix
 Structure to avoid the use of the access operator of matrices. More...
class  parameters
 The parameters for the class geometricTransform. More...

Public Member Functions

 geometricTransform ()
 geometricTransform (const parameters &par)
 geometricTransform (const geometricTransform &other)
virtual ~geometricTransform ()
virtual const char * getTypeName () const
geometricTransformcopy (const geometricTransform &other)
virtual functorclone () const
const parametersgetParameters () const
virtual bool updateParameters ()
Apply methods for points and point lists



template<class T >
bool apply (tpoint< T > &srcdest) const
template<class T >
bool apply (const tpoint< T > &src, tpoint< T > &dest) const
template<class T >
bool apply (tpointList< T > &srcdest) const
template<class T >
bool apply (const tpointList< T > &src, tpointList< T > &dest) const
Apply methods for matrices



template<class T >
bool apply (matrix< T > &srcdest) const
template<class T >
bool apply (const matrix< T > &src, matrix< T > &dest, point &offset) const
template<class T >
bool apply (const matrix< T > &src, matrix< T > &dest) const
Shortcuts for usual transformations.

Example:

 // Usual parameters
 lti::geometricTransform::parameters geoPar;
 geoPar.keepDimensions = true;
 geoPar.boundaryType = lti::Mirror;

 // Create geometric transformation object
 lti::geometricTransform geoTrans(geoPar);

 // images 
 lti::image img(256,256,lti::Black),res;

 // initialize your image with something
 (img.getRow(img.rows()/2)).fill(lti::Red);

 // Rotate an image using shortcuts and default interpolator
 geoTrans.rotate(img,res,45*Pi/180);  // rotate 45 degrees


template<class T >
bool scale (const matrix< T > &src, matrix< T > &dest, const tpoint< float > &factor)
template<class T >
bool scale (matrix< T > &srcdest, const tpoint< float > &factor)
template<class T >
bool rotate (const matrix< T > &src, matrix< T > &dest, const double &angle, const point &center=point(std::numeric_limits< int >::max(), std::numeric_limits< int >::max()))
template<class T >
bool rotate (matrix< T > &srcdest, const double &angle, const point &center=point(std::numeric_limits< int >::max(), std::numeric_limits< int >::max()))

Protected Member Functions

template<class value_type >
void transf (const tpoint< value_type > &src, tpoint< value_type > &dest, const fastMatrix &m) const



interpolatorCollection< double > dcollect
interpolatorCollection< float > fcollect
interpolatorCollection< int > icollect
interpolatorCollection< ubytebcollect
interpolatorCollection< rgbPixelccollect
const interpolatorCollection
< double > & 
getCollection (double &a) const
const interpolatorCollection
< float > & 
getCollection (float &a) const
const interpolatorCollection
< int > & 
getCollection (int &a) const
const interpolatorCollection
< ubyte > & 
getCollection (ubyte &a) const
const interpolatorCollection
< rgbPixel > & 
getCollection (rgbPixel &a) const

Detailed Description

This functor implements an generic geometric transform based on a homogeneous matrix, which is able to represent rotations, translations scalings and all other possibilites of homographies.

You can use your own matrix to generate a special geometric transformation, or you can use the member functions of the parameters class to generate the matrix and vectors for a given translation, rotation and scaling.

You can use all the three functions in arbitrary order and number to build your transform matrix sequentially.

With the invert() member of the parameters class you can invert the matrix for the reverse transformation. The speed in general only depends on the size of the image or the size of the pointList.

Please note that even if the transformation can have a 3D nature (4x4 homogeneous matrix) and you can turn, shift or scale the image plane in any of the three coordinates, the input image is always a 2D object with z-coordinate zero. A typical error is trying to apply the inverse transformation matrix to reconstruct a 3D rotation: this cannot work because of the missing third coordinate for each pixel.

There are also a few specialized functors to achieve isolated transformation tasks in a much faster way. A derived class also restricts the transformation to a similarity transformation (see lti::similarityTransform2D).

See also:
lti::flipImage, lti::rotation, lti::scaling

Constructor & Destructor Documentation

lti::geometricTransform::geometricTransform (  ) 

Default constructor.

lti::geometricTransform::geometricTransform ( const parameters par  ) 

Default constructor with parameters object.

lti::geometricTransform::geometricTransform ( const geometricTransform other  ) 

Copy constructor.

Parameters:
other the object to be copied
virtual lti::geometricTransform::~geometricTransform (  )  [virtual]

Destructor.


Member Function Documentation

template<class T >
bool lti::geometricTransform::apply ( const matrix< T > &  src,
matrix< T > &  dest 
) const [inline]

Applies the geometric transformation on the given parameter.

The transformation is applied on each point of the matrix.

Parameters:
src matrix with the source data.
dest the result will be left here.
Returns:
true if successful or false otherwise.

References apply().

template<class T >
bool lti::geometricTransform::apply ( const matrix< T > &  src,
matrix< T > &  dest,
point offset 
) const [inline]

Applies the geometric transformation on the given parameter.

The transformation is applied on each point of the matrix.

Parameters:
src matrix with the source data.
dest the result will be left here.
offset if you specified parameters::keepDimensions as false, then this is the offset added to each pixel transformation to obtain the results in a positive range. It is usefull if you also transform some points and want to obtain their value in the destination image.
Returns:
true if successful or false otherwise.

References lti::BicubicInterpolator, lti::BiquadraticInterpolator, getCollection(), getParameters(), and lti::NearestNeighborInterpolator.

template<class T >
bool lti::geometricTransform::apply ( matrix< T > &  srcdest  )  const [inline]

Applies the geometric transformation on the given parameter.

The transformation is applied on each point of the matrix.

Parameters:
srcdest matix with the source data. The result will be left here too.
Returns:
true if successful or false otherwise.

References apply(), and lti::genericMatrix< T >::detach().

template<class T >
bool lti::geometricTransform::apply ( const tpointList< T > &  src,
tpointList< T > &  dest 
) const [inline]

Applies the geometric transformation on the given parameter.

The transformation is applied on each point of the list.

Parameters:
src pointList with the source data.
dest pointList where the result will be left.
Returns:
true if successful, false otherwise

References lti::tpointList< T >::begin(), lti::tpointList< T >::clear(), lti::tpointList< T >::end(), getParameters(), lti::tpointList< T >::push_back(), and transf().

template<class T >
bool lti::geometricTransform::apply ( tpointList< T > &  srcdest  )  const [inline]

Applies the geometric transformation on the given parameter.

The transformation is applied on each point of the list.

Parameters:
srcdest pointList with the source data. The result will be left here too.
Returns:
true if successful, false otherwise

References lti::tpointList< T >::begin(), lti::tpointList< T >::end(), getParameters(), and transf().

template<class T >
bool lti::geometricTransform::apply ( const tpoint< T > &  src,
tpoint< T > &  dest 
) const [inline]

Apply the geometric transformation on src point and leave the result on dest.

Parameters:
src point with the source data.
dest point where the result will be left.
Returns:
true if successful, false otherwise

References getParameters(), and transf().

template<class T >
bool lti::geometricTransform::apply ( tpoint< T > &  srcdest  )  const [inline]

Apply the geometric transformation to the given point.

Parameters:
srcdest point with the source data. The result will be left here too.
Returns:
true if successful, false otherwise

Referenced by apply(), rotate(), and scale().

virtual functor* lti::geometricTransform::clone (  )  const [virtual]

Returns a pointer to a clone of this functor.

Implements lti::functor.

geometricTransform& lti::geometricTransform::copy ( const geometricTransform other  ) 

Copy data of "other" functor.

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

Reimplemented from lti::functor.

const interpolatorCollection<rgbPixel>& lti::geometricTransform::getCollection ( rgbPixel a  )  const [inline, protected]

Some attributes with the interpolators to save the creation time in the apply methods.

References ccollect.

const interpolatorCollection<ubyte>& lti::geometricTransform::getCollection ( ubyte a  )  const [inline, protected]

Some attributes with the interpolators to save the creation time in the apply methods.

References bcollect.

const interpolatorCollection<int>& lti::geometricTransform::getCollection ( int &  a  )  const [inline, protected]

Some attributes with the interpolators to save the creation time in the apply methods.

References icollect.

const interpolatorCollection<float>& lti::geometricTransform::getCollection ( float &  a  )  const [inline, protected]

Some attributes with the interpolators to save the creation time in the apply methods.

References fcollect.

const interpolatorCollection<double>& lti::geometricTransform::getCollection ( double &  a  )  const [inline, protected]

Methods that return the proper collection type.

The dummy argument a is only there to allow the compiler to chose the proper method.

References dcollect.

Referenced by apply().

const parameters& lti::geometricTransform::getParameters (  )  const

Returns used parameters.

Reimplemented from lti::modifier.

Referenced by apply(), rotate(), and scale().

virtual const char* lti::geometricTransform::getTypeName (  )  const [virtual]

Returns the name of this type ("geometricTransform").

Reimplemented from lti::modifier.

template<class T >
bool lti::geometricTransform::rotate ( matrix< T > &  srcdest,
const double &  angle,
const point center = point(std::numeric_limits<int>::max(),                                          std::numeric_limits<int>::max()) 
) [inline]

Rotate the image on place.

See also:
lti::rotation
Parameters:
srcdest matrix with source data and where the result will be left
angle angle in radians to rotate the image
center rotation point (takes effect only if keepDimensions in the parameters is set to true). The default value ensures rotation on the image center.
Returns:
true if successful, false otherwise.

References lti::genericMatrix< T >::detach(), and rotate().

template<class T >
bool lti::geometricTransform::rotate ( const matrix< T > &  src,
matrix< T > &  dest,
const double &  angle,
const point center = point(std::numeric_limits<int>::max(),                                          std::numeric_limits<int>::max()) 
) [inline]

Rotate the src image on copy.

See also:
lti::rotation
Parameters:
src source image
dest matrix where the result will be left
angle angle in radians to rotate the image
center rotation point (takes effect only if keepDimensions in the parameters is set to true). The default value ensures rotation on the image center.
Returns:
true if successful, false otherwise.

References apply(), lti::genericMatrix< T >::columns(), getParameters(), lti::max(), lti::genericMatrix< T >::rows(), lti::functor::setParameters(), lti::tpoint3D< T >::x, lti::tpoint3D< T >::y, and lti::tpoint3D< T >::z.

Referenced by rotate().

template<class T >
bool lti::geometricTransform::scale ( matrix< T > &  srcdest,
const tpoint< float > &  factor 
) [inline]

Scale the srcdest image on-place.

You usually want to set parameters::keepDimensions to false when using this method.

See also:
lti::scaling
Parameters:
srcdest source image. The result will be left here too.
factor point containing the scaling factor for x and y coordinates
Returns:
true if successful, false otherwise.

References lti::genericMatrix< T >::detach(), and scale().

template<class T >
bool lti::geometricTransform::scale ( const matrix< T > &  src,
matrix< T > &  dest,
const tpoint< float > &  factor 
) [inline]

Scale the src image on copy.

You usually want to set parameters::keepDimensions to false when using this method.

See also:
lti::scaling
Parameters:
src source image
dest matrix where the result will be left
factor point containing the scaling factor for x and y coordinates
Returns:
true if successful, false otherwise.

References apply(), getParameters(), and lti::functor::setParameters().

Referenced by scale().

template<class value_type >
void lti::geometricTransform::transf ( const tpoint< value_type > &  src,
tpoint< value_type > &  dest,
const fastMatrix m 
) const [inline, protected]

Transform 2D point.

Uses the given "fastMatrix" to transform the source point into the destination point.

References lti::condRoundCastTo(), lti::geometricTransform::fastMatrix::m00, lti::tpoint< T >::x, and lti::tpoint< T >::y.

Referenced by apply().

virtual bool lti::geometricTransform::updateParameters (  )  [virtual]

Set parameters.

Reimplemented from lti::functor.


Member Data Documentation

interpolatorCollection<ubyte> lti::geometricTransform::bcollect [protected]

Some attributes with the interpolators to save the creation time in the apply methods.

Referenced by getCollection().

interpolatorCollection<rgbPixel> lti::geometricTransform::ccollect [protected]

Some attributes with the interpolators to save the creation time in the apply methods.

Referenced by getCollection().

interpolatorCollection<double> lti::geometricTransform::dcollect [protected]

Some attributes with the interpolators to save the creation time in the apply methods.

Referenced by getCollection().

interpolatorCollection<float> lti::geometricTransform::fcollect [protected]

Some attributes with the interpolators to save the creation time in the apply methods.

Referenced by getCollection().

interpolatorCollection<int> lti::geometricTransform::icollect [protected]

Some attributes with the interpolators to save the creation time in the apply methods.

Referenced by getCollection().


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

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