ITK  4.1.0
Insight Segmentation and Registration Toolkit
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Member Functions
itk::AffineTransform< TScalarType, NDimensions > Class Template Reference

#include <itkAffineTransform.h>

+ Inheritance diagram for itk::AffineTransform< TScalarType, NDimensions >:
+ Collaboration diagram for itk::AffineTransform< TScalarType, NDimensions >:

List of all members.

Public Types

typedef Superclass::CenterType CenterType
typedef SmartPointer< const SelfConstPointer
typedef
Superclass::InputCovariantVectorType 
InputCovariantVectorType
typedef Superclass::InputPointType InputPointType
typedef Superclass::InputVectorType InputVectorType
typedef
Superclass::InputVnlVectorType 
InputVnlVectorType
typedef
Superclass::InverseMatrixType 
InverseMatrixType
typedef
InverseTransformBaseType::Pointer 
InverseTransformBasePointer
typedef
Superclass::InverseTransformBaseType 
InverseTransformBaseType
typedef Superclass::JacobianType JacobianType
typedef Superclass::MatrixType MatrixType
typedef Superclass::OffsetType OffsetType
typedef
Superclass::OutputCovariantVectorType 
OutputCovariantVectorType
typedef Superclass::OutputPointType OutputPointType
typedef
Superclass::OutputVectorType 
OutputVectorType
typedef
Superclass::OutputVnlVectorType 
OutputVnlVectorType
typedef Superclass::ParametersType ParametersType
typedef SmartPointer< SelfPointer
typedef Superclass::ScalarType ScalarType
typedef AffineTransform Self
typedef
MatrixOffsetTransformBase
< TScalarType, NDimensions,
NDimensions > 
Superclass
typedef Superclass::TranslationType TranslationType

Public Member Functions

InputCovariantVectorType BackTransform (const OutputCovariantVectorType &vector) const
InputPointType BackTransformPoint (const OutputPointType &point) const
virtual ::itk::LightObject::Pointer CreateAnother (void) const
bool GetInverse (Self *inverse) const
virtual InverseTransformBasePointer GetInverseTransform () const
virtual const char * GetNameOfClass () const
ScalarType Metric (const Self *other) const
ScalarType Metric (void) const
void Rotate2D (TScalarType angle, bool pre=0)
void Rotate3D (const OutputVectorType &axis, TScalarType angle, bool pre=0)
void Scale (const OutputVectorType &factor, bool pre=0)
void Scale (const TScalarType &factor, bool pre=0)
void Shear (int axis1, int axis2, TScalarType coef, bool pre=0)
void Translate (const OutputVectorType &offset, bool pre=0)
void Rotate (int axis1, int axis2, TScalarType angle, bool pre=0)
InputPointType BackTransform (const OutputPointType &point) const
InputVectorType BackTransform (const OutputVectorType &vector) const
InputVnlVectorType BackTransform (const OutputVnlVectorType &vector) const

Static Public Member Functions

static Pointer New ()

Static Public Attributes

static const unsigned int InputSpaceDimension = NDimensions
static const unsigned int OutputSpaceDimension = NDimensions
static const unsigned int SpaceDimension = NDimensions
static const unsigned int ParametersDimension = NDimensions *( NDimensions + 1 )

Protected Member Functions

void PrintSelf (std::ostream &s, Indent indent) const
virtual ~AffineTransform ()
 AffineTransform (const MatrixType &matrix, const OutputVectorType &offset)
 AffineTransform (unsigned int paramDims)
 AffineTransform ()

Private Member Functions

 AffineTransform (const Self &other)
const Selfoperator= (const Self &)

Detailed Description

template<class TScalarType = double, unsigned int NDimensions = 3>
class itk::AffineTransform< TScalarType, NDimensions >

Affine transformation of a vector space (e.g. space coordinates)

This class allows the definition and manipulation of affine transformations of an n-dimensional affine space (and its associated vector space) onto itself. One common use is to define and manipulate Euclidean coordinate transformations in two and three dimensions, but other uses are possible as well.

An affine transformation is defined mathematically as a linear transformation plus a constant offset. If A is a constant n x n matrix and b is a constant n-vector, then y = Ax+b defines an affine transformation from the n-vector x to the n-vector y.

The difference between two points is a vector and transforms linearly, using the matrix only. That is, (y1-y2) = A*(x1-x2).

The AffineTransform class determines whether to transform an object as a point or a vector by examining its type. An object of type Point transforms as a point; an object of type Vector transforms as a vector.

One common use of affine transformations is to define coordinate conversions in two- and three-dimensional space. In this application, x is a two- or three-dimensional vector containing the "source" coordinates of a point, y is a vector containing the "target" coordinates, the matrix A defines the scaling and rotation of the coordinate systems from the source to the target, and b defines the translation of the origin from the source to the target. More generally, A can also define anisotropic scaling and shearing transformations. Any good textbook on computer graphics will discuss coordinate transformations in more detail. Several of the methods in this class are designed for this purpose and use the language appropriate to coordinate conversions.

Any two affine transformations may be composed and the result is another affine transformation. However, the order is important. Given two affine transformations T1 and T2, we will say that "precomposing T1 with T2" yields the transformation which applies T1 to the source, and then applies T2 to that result to obtain the target. Conversely, we will say that "postcomposing T1 with T2" yields the transformation which applies T2 to the source, and then applies T1 to that result to obtain the target. (Whether T1 or T2 comes first lexicographically depends on whether you choose to write mappings from right-to-left or vice versa; we avoid the whole problem by referring to the order of application rather than the textual order.)

There are two template parameters for this class:

ScalarT The type to be used for scalar numeric values. Either float or double.

NDimensions The number of dimensions of the vector space.

This class provides several methods for setting the matrix and vector defining the transform. To support the registration framework, the transform parameters can also be set as an Array<double> of size (NDimension + 1) * NDimension using method SetParameters(). The first (NDimension x NDimension) parameters defines the matrix in row-major order (where the column index varies the fastest). The last NDimension parameters defines the translation in each dimensions.

This class also supports the specification of a center of rotation (center) and a translation that is applied with respect to that centered rotation. By default the center of rotation is set to the origin.

Definition at line 104 of file itkAffineTransform.h.


Member Typedef Documentation

template<class TScalarType = double, unsigned int NDimensions = 3>
typedef Superclass::CenterType itk::AffineTransform< TScalarType, NDimensions >::CenterType
template<class TScalarType = double, unsigned int NDimensions = 3>
typedef SmartPointer< const Self > itk::AffineTransform< TScalarType, NDimensions >::ConstPointer
template<class TScalarType = double, unsigned int NDimensions = 3>
typedef Superclass::InputCovariantVectorType itk::AffineTransform< TScalarType, NDimensions >::InputCovariantVectorType
template<class TScalarType = double, unsigned int NDimensions = 3>
typedef Superclass::InputPointType itk::AffineTransform< TScalarType, NDimensions >::InputPointType
template<class TScalarType = double, unsigned int NDimensions = 3>
typedef Superclass::InputVectorType itk::AffineTransform< TScalarType, NDimensions >::InputVectorType
template<class TScalarType = double, unsigned int NDimensions = 3>
typedef Superclass::InputVnlVectorType itk::AffineTransform< TScalarType, NDimensions >::InputVnlVectorType
template<class TScalarType = double, unsigned int NDimensions = 3>
typedef Superclass::InverseMatrixType itk::AffineTransform< TScalarType, NDimensions >::InverseMatrixType
template<class TScalarType = double, unsigned int NDimensions = 3>
typedef InverseTransformBaseType::Pointer itk::AffineTransform< TScalarType, NDimensions >::InverseTransformBasePointer
template<class TScalarType = double, unsigned int NDimensions = 3>
typedef Superclass::InverseTransformBaseType itk::AffineTransform< TScalarType, NDimensions >::InverseTransformBaseType

Base inverse transform type. This type should not be changed to the concrete inverse transform type or inheritance would be lost.

Reimplemented from itk::MatrixOffsetTransformBase< TScalarType, NDimensions, NDimensions >.

Reimplemented in itk::CenteredAffineTransform< TScalarType, NDimensions >, and itk::ScalableAffineTransform< TScalarType, NDimensions >.

Definition at line 151 of file itkAffineTransform.h.

template<class TScalarType = double, unsigned int NDimensions = 3>
typedef Superclass::JacobianType itk::AffineTransform< TScalarType, NDimensions >::JacobianType
template<class TScalarType = double, unsigned int NDimensions = 3>
typedef Superclass::MatrixType itk::AffineTransform< TScalarType, NDimensions >::MatrixType
template<class TScalarType = double, unsigned int NDimensions = 3>
typedef Superclass::OffsetType itk::AffineTransform< TScalarType, NDimensions >::OffsetType
template<class TScalarType = double, unsigned int NDimensions = 3>
typedef Superclass::OutputCovariantVectorType itk::AffineTransform< TScalarType, NDimensions >::OutputCovariantVectorType
template<class TScalarType = double, unsigned int NDimensions = 3>
typedef Superclass::OutputPointType itk::AffineTransform< TScalarType, NDimensions >::OutputPointType
template<class TScalarType = double, unsigned int NDimensions = 3>
typedef Superclass::OutputVectorType itk::AffineTransform< TScalarType, NDimensions >::OutputVectorType
template<class TScalarType = double, unsigned int NDimensions = 3>
typedef Superclass::OutputVnlVectorType itk::AffineTransform< TScalarType, NDimensions >::OutputVnlVectorType
template<class TScalarType = double, unsigned int NDimensions = 3>
typedef Superclass::ParametersType itk::AffineTransform< TScalarType, NDimensions >::ParametersType
template<class TScalarType = double, unsigned int NDimensions = 3>
typedef SmartPointer< Self > itk::AffineTransform< TScalarType, NDimensions >::Pointer
template<class TScalarType = double, unsigned int NDimensions = 3>
typedef Superclass::ScalarType itk::AffineTransform< TScalarType, NDimensions >::ScalarType
template<class TScalarType = double, unsigned int NDimensions = 3>
typedef AffineTransform itk::AffineTransform< TScalarType, NDimensions >::Self
template<class TScalarType = double, unsigned int NDimensions = 3>
typedef MatrixOffsetTransformBase< TScalarType, NDimensions, NDimensions > itk::AffineTransform< TScalarType, NDimensions >::Superclass
template<class TScalarType = double, unsigned int NDimensions = 3>
typedef Superclass::TranslationType itk::AffineTransform< TScalarType, NDimensions >::TranslationType

Constructor & Destructor Documentation

template<class TScalarType = double, unsigned int NDimensions = 3>
itk::AffineTransform< TScalarType, NDimensions >::AffineTransform ( const MatrixType matrix,
const OutputVectorType offset 
) [protected]

Construct an AffineTransform object

This method constructs a new AffineTransform object and initializes the matrix and offset parts of the transformation to values specified by the caller. If the arguments are omitted, then the AffineTransform is initialized to an identity transformation in the appropriate number of dimensions.

template<class TScalarType = double, unsigned int NDimensions = 3>
itk::AffineTransform< TScalarType, NDimensions >::AffineTransform ( unsigned int  paramDims) [protected]

Construct an AffineTransform object

This method constructs a new AffineTransform object and initializes the matrix and offset parts of the transformation to values specified by the caller. If the arguments are omitted, then the AffineTransform is initialized to an identity transformation in the appropriate number of dimensions.

template<class TScalarType = double, unsigned int NDimensions = 3>
itk::AffineTransform< TScalarType, NDimensions >::AffineTransform ( ) [protected]

Construct an AffineTransform object

This method constructs a new AffineTransform object and initializes the matrix and offset parts of the transformation to values specified by the caller. If the arguments are omitted, then the AffineTransform is initialized to an identity transformation in the appropriate number of dimensions.

template<class TScalarType = double, unsigned int NDimensions = 3>
virtual itk::AffineTransform< TScalarType, NDimensions >::~AffineTransform ( ) [protected, virtual]

Destroy an AffineTransform object

template<class TScalarType = double, unsigned int NDimensions = 3>
itk::AffineTransform< TScalarType, NDimensions >::AffineTransform ( const Self other) [private]

Member Function Documentation

template<class TScalarType , unsigned int NDimensions>
AffineTransform< TScalarType, NDimensions >::InputPointType itk::AffineTransform< TScalarType, NDimensions >::BackTransform ( const OutputPointType point) const [inline]

Back transform by an affine transformation

This method finds the point or vector that maps to a given point or vector under the affine transformation defined by self. If no such point exists, an exception is thrown.

Deprecated:
Please use GetInverseTransform and then call the forward transform function

Back transform a point

Reimplemented in itk::AzimuthElevationToCartesianTransform< TScalarType, NDimensions >.

Definition at line 382 of file itkAffineTransform.h.

template<class TScalarType , unsigned int NDimensions>
AffineTransform< TScalarType, NDimensions >::InputVectorType itk::AffineTransform< TScalarType, NDimensions >::BackTransform ( const OutputVectorType vect) const [inline]

Back transform a vector

Definition at line 321 of file itkAffineTransform.h.

template<class TScalarType , unsigned int NDimensions>
AffineTransform< TScalarType, NDimensions >::InputVnlVectorType itk::AffineTransform< TScalarType, NDimensions >::BackTransform ( const OutputVnlVectorType vect) const [inline]

Back transform a vnl_vector

Definition at line 335 of file itkAffineTransform.h.

template<class TScalarType , unsigned int NDimensions>
AffineTransform< TScalarType, NDimensions >::InputCovariantVectorType itk::AffineTransform< TScalarType, NDimensions >::BackTransform ( const OutputCovariantVectorType vec) const [inline]

Back Transform a CovariantVector

Definition at line 349 of file itkAffineTransform.h.

template<class TScalarType , unsigned int NDimensions>
AffineTransform< TScalarType, NDimensions >::InputPointType itk::AffineTransform< TScalarType, NDimensions >::BackTransformPoint ( const OutputPointType point) const [inline]

Back transform a point by an affine transform

This method finds the point that maps to a given point under the affine transformation defined by self. If no such point exists, an exception is thrown. The returned value is (a pointer to) a brand new point created with new.

Deprecated:
Please use GetInverseTransform and then call the forward transform function

Back transform a given point which is represented as type PointType

Reimplemented in itk::AzimuthElevationToCartesianTransform< TScalarType, NDimensions >.

Definition at line 373 of file itkAffineTransform.h.

template<class TScalarType = double, unsigned int NDimensions = 3>
virtual::itk::LightObject::Pointer itk::AffineTransform< TScalarType, NDimensions >::CreateAnother ( void  ) const [virtual]

Create an object from an instance, potentially deferring to a factory. This method allows you to create an instance of an object that is exactly the same type as the referring object. This is useful in cases where an object has been cast back to a base class.

Reimplemented from itk::MatrixOffsetTransformBase< TScalarType, NDimensions, NDimensions >.

Reimplemented in itk::AzimuthElevationToCartesianTransform< TScalarType, NDimensions >, itk::CenteredAffineTransform< TScalarType, NDimensions >, itk::FixedCenterOfRotationAffineTransform< TScalarType, NDimensions >, and itk::ScalableAffineTransform< TScalarType, NDimensions >.

template<class TScalarType = double, unsigned int NDimensions = 3>
bool itk::AffineTransform< TScalarType, NDimensions >::GetInverse ( Self inverse) const
template<class TScalarType = double, unsigned int NDimensions = 3>
virtual InverseTransformBasePointer itk::AffineTransform< TScalarType, NDimensions >::GetInverseTransform ( ) const [virtual]
template<class TScalarType = double, unsigned int NDimensions = 3>
virtual const char* itk::AffineTransform< TScalarType, NDimensions >::GetNameOfClass ( ) const [virtual]
template<class TScalarType = double, unsigned int NDimensions = 3>
ScalarType itk::AffineTransform< TScalarType, NDimensions >::Metric ( const Self other) const

Compute distance between two affine transformations

This method computes a ``distance'' between two affine transformations. This distance is guaranteed to be a metric, but not any particular metric. (At the moment, the algorithm is to collect all the elements of the matrix and offset into a vector, and compute the euclidean (L2) norm of that vector. Some metric which could be used to estimate the distance between two points transformed by the affine transformation would be more useful, but I don't have time right now to work out the mathematical details.)

template<class TScalarType = double, unsigned int NDimensions = 3>
ScalarType itk::AffineTransform< TScalarType, NDimensions >::Metric ( void  ) const

This method computes the distance from self to the identity transformation, using the same metric as the one-argument form of the Metric() method.

template<class TScalarType = double, unsigned int NDimensions = 3>
static Pointer itk::AffineTransform< TScalarType, NDimensions >::New ( ) [static]
template<class TScalarType = double, unsigned int NDimensions = 3>
const Self& itk::AffineTransform< TScalarType, NDimensions >::operator= ( const Self ) [private]
template<class TScalarType = double, unsigned int NDimensions = 3>
void itk::AffineTransform< TScalarType, NDimensions >::PrintSelf ( std::ostream &  s,
Indent  indent 
) const [protected, virtual]
template<class TScalarType = double, unsigned int NDimensions = 3>
void itk::AffineTransform< TScalarType, NDimensions >::Rotate ( int  axis1,
int  axis2,
TScalarType  angle,
bool  pre = 0 
)

Compose affine transformation with an elementary rotation

This method composes self with a rotation that affects two specified axes, replacing the current value of self. The rotation angle is in radians. The axis of rotation goes through the origin. The transformation is given by

y[axis1] = vcl_cos(angle)*x[axis1] + vcl_sin(angle)*x[axis2] y[axis2] = -sin(angle)*x[axis1] + vcl_cos(angle)*x[axis2].

All coordinates other than axis1 and axis2 are unchanged; a rotation of pi/2 radians will carry +axis1 into +axis2. The rotation is precomposed with self if pre is true, and postcomposed otherwise. Note that the rotation is applied centered at the origin.

template<class TScalarType = double, unsigned int NDimensions = 3>
void itk::AffineTransform< TScalarType, NDimensions >::Rotate2D ( TScalarType  angle,
bool  pre = 0 
)

Compose 2D affine transformation with a rotation

This method composes self, which must be a 2D affine transformation, with a clockwise rotation through a given angle in radians. The center of rotation is the origin. The rotation is precomposed with self if pre is true, and postcomposed otherwise. Note that the rotation is applied centered at the origin.

Warning:
Only to be use in two dimensions
Todo:
Find a way to generate a compile-time error is this is used with NDimensions != 2.
template<class TScalarType = double, unsigned int NDimensions = 3>
void itk::AffineTransform< TScalarType, NDimensions >::Rotate3D ( const OutputVectorType axis,
TScalarType  angle,
bool  pre = 0 
)

Compose 3D affine transformation with a rotation

This method composes self, which must be a 3D affine transformation, with a clockwise rotation around a specified axis. The rotation angle is in radians; the axis of rotation goes through the origin. The rotation is precomposed with self if pre is true, and postcomposed otherwise. Note that the rotation is applied centered at the origin.

Warning:
Only to be used in dimension 3
Todo:
Find a way to generate a compile-time error is this is used with NDimensions != 3.
template<class TScalarType = double, unsigned int NDimensions = 3>
void itk::AffineTransform< TScalarType, NDimensions >::Scale ( const OutputVectorType factor,
bool  pre = 0 
)

Compose affine transformation with a scaling

This method modifies self to magnify the source by a given factor along each axis. If all factors are the same, or only a single factor is given, then the scaling is isotropic; otherwise it is anisotropic. If an odd number of factors are negative, then the parity of the image changes. If any of the factors is zero, then the transformation becomes a projection and is not invertible. The scaling is precomposed with self if pre is true, and postcomposed otherwise. Note that the scaling is applied centered at the origin.

template<class TScalarType = double, unsigned int NDimensions = 3>
void itk::AffineTransform< TScalarType, NDimensions >::Scale ( const TScalarType &  factor,
bool  pre = 0 
)
template<class TScalarType = double, unsigned int NDimensions = 3>
void itk::AffineTransform< TScalarType, NDimensions >::Shear ( int  axis1,
int  axis2,
TScalarType  coef,
bool  pre = 0 
)

Compose affine transformation with a shear

This method composes self with a shear transformation, replacing the original contents of self. The shear is precomposed with self if pre is true, and postcomposed otherwise. The transformation is given by

y[axis1] = x[axis1] + coef*x[axis2] y[axis2] = x[axis2].

Note that the shear is applied centered at the origin.

template<class TScalarType = double, unsigned int NDimensions = 3>
void itk::AffineTransform< TScalarType, NDimensions >::Translate ( const OutputVectorType offset,
bool  pre = 0 
)

Compose affine transformation with a translation

This method modifies self to include a translation of the origin. The translation is precomposed with self if pre is true, and postcomposed otherwise. This updates Translation based on current center.


Member Data Documentation

template<class TScalarType = double, unsigned int NDimensions = 3>
const unsigned int itk::AffineTransform< TScalarType, NDimensions >::InputSpaceDimension = NDimensions [static]
template<class TScalarType = double, unsigned int NDimensions = 3>
const unsigned int itk::AffineTransform< TScalarType, NDimensions >::OutputSpaceDimension = NDimensions [static]
template<class TScalarType = double, unsigned int NDimensions = 3>
const unsigned int itk::AffineTransform< TScalarType, NDimensions >::ParametersDimension = NDimensions *( NDimensions + 1 ) [static]
template<class TScalarType = double, unsigned int NDimensions = 3>
const unsigned int itk::AffineTransform< TScalarType, NDimensions >::SpaceDimension = NDimensions [static]

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