| 1 |
|
/*========================================================================= |
| 2 |
|
|
| 3 |
|
Program: Insight Segmentation & Registration Toolkit |
| 4 |
|
Module: $RCSfile: itkSimilarity2DTransform.h.html,v $ |
| 5 |
|
Language: C++ |
| 6 |
|
Date: $Date: 2006/01/17 19:15:47 $ |
| 7 |
|
Version: $Revision: 1.4 $ |
| 8 |
|
|
| 9 |
|
Copyright (c) Insight Software Consortium. All rights reserved. |
| 10 |
|
See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. |
| 11 |
|
|
| 12 |
|
This software is distributed WITHOUT ANY WARRANTY; without even |
| 13 |
|
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
| 14 |
|
PURPOSE. See the above copyright notices for more information. |
| 15 |
|
|
| 16 |
|
=========================================================================*/ |
| 17 |
|
|
| 18 |
|
#ifndef __itkSimilarity2DTransform_h |
| 19 |
|
#define __itkSimilarity2DTransform_h |
| 20 |
|
|
| 21 |
|
#include <iostream> |
| 22 |
|
#include "itkRigid2DTransform.h" |
| 23 |
|
|
| 24 |
|
namespace itk |
| 25 |
|
{ |
| 26 |
|
|
| 27 |
|
/** \brief Similarity2DTransform of a vector space (e.g. space coordinates) |
| 28 |
|
* |
| 29 |
|
* This transform applies a homogenous scale and rigid transform in |
| 30 |
|
* 2D space. The transform is specified as a scale and rotation around |
| 31 |
|
* a arbitrary center and is followed by a translation. |
| 32 |
LEN |
* given one angle for rotation, a homogeneous scale and a 2D offset for translation. |
| 33 |
|
* |
| 34 |
|
* The parameters for this transform can be set either using |
| 35 |
|
* individual Set methods or in serialized form using |
| 36 |
|
* SetParameters() and SetFixedParameters(). |
| 37 |
|
* |
| 38 |
|
* The serialization of the optimizable parameters is an array of 3 elements |
| 39 |
|
* ordered as follows: |
| 40 |
|
* p[0] = scale |
| 41 |
|
* p[1] = angle |
| 42 |
|
* p[2] = x component of the translation |
| 43 |
|
* p[3] = y component of the translation |
| 44 |
|
* |
| 45 |
|
* The serialization of the fixed parameters is an array of 2 elements |
| 46 |
|
* ordered as follows: |
| 47 |
|
* p[0] = x coordinate of the center |
| 48 |
|
* p[1] = y coordinate of the center |
| 49 |
|
* |
| 50 |
|
* Access methods for the center, translation and underlying matrix |
| 51 |
|
* offset vectors are documented in the superclass MatrixOffsetTransformBase. |
| 52 |
|
* |
| 53 |
|
* Access methods for the angle are documented in superclass Rigid2DTransform. |
| 54 |
|
* |
| 55 |
|
* \sa Transform |
| 56 |
|
* \sa MatrixOffsetTransformBase |
| 57 |
|
* \sa Rigid2DTransform |
| 58 |
|
* |
| 59 |
|
* \ingroup Transforms |
| 60 |
|
*/ |
| 61 |
LEN |
template < class TScalarType=double > // Data type for scalars (float or double) |
| 62 |
MCM |
class ITK_EXPORT Similarity2DTransform : |
| 63 |
IND |
************public Rigid2DTransform< TScalarType > |
| 64 |
|
{ |
| 65 |
|
public: |
| 66 |
|
/** Standard class typedefs. */ |
| 67 |
|
typedef Similarity2DTransform Self; |
| 68 |
TDA |
typedef Rigid2DTransform< TScalarType > Superclass; |
| 69 |
TDA |
typedef SmartPointer<Self> Pointer; |
| 70 |
TDA |
typedef SmartPointer<const Self> ConstPointer; |
| 71 |
|
|
| 72 |
|
/** New macro for creation of through a Smart Pointer. */ |
| 73 |
|
itkNewMacro( Self ); |
| 74 |
|
|
| 75 |
|
/** Run-time type information (and related methods). */ |
| 76 |
|
itkTypeMacro( Similarity2DTransform, Rigid2DTransform ); |
| 77 |
|
|
| 78 |
|
/** Dimension of parameters. */ |
| 79 |
|
itkStaticConstMacro(SpaceDimension, unsigned int, 2); |
| 80 |
|
itkStaticConstMacro(InputSpaceDimension, unsigned int, 2); |
| 81 |
|
itkStaticConstMacro(OutputSpaceDimension, unsigned int, 2); |
| 82 |
|
itkStaticConstMacro(ParametersDimension, unsigned int, 4); |
| 83 |
|
|
| 84 |
|
/** Scalar type. */ |
| 85 |
|
typedef typename Superclass::ScalarType ScalarType; |
| 86 |
|
typedef TScalarType ScaleType; |
| 87 |
|
|
| 88 |
|
/** Parameters type. */ |
| 89 |
|
typedef typename Superclass::ParametersType ParametersType; |
| 90 |
|
|
| 91 |
|
/** Jacobian type. */ |
| 92 |
|
typedef typename Superclass::JacobianType JacobianType; |
| 93 |
|
|
| 94 |
|
/** Offset type. */ |
| 95 |
|
typedef typename Superclass::OffsetType OffsetType; |
| 96 |
|
|
| 97 |
|
/** Matrix type. */ |
| 98 |
|
typedef typename Superclass::MatrixType MatrixType; |
| 99 |
|
|
| 100 |
|
/** Point type. */ |
| 101 |
|
typedef typename Superclass::InputPointType InputPointType; |
| 102 |
|
typedef typename Superclass::OutputPointType OutputPointType; |
| 103 |
|
|
| 104 |
|
/** Vector type. */ |
| 105 |
|
typedef typename Superclass::InputVectorType InputVectorType; |
| 106 |
|
typedef typename Superclass::OutputVectorType OutputVectorType; |
| 107 |
|
|
| 108 |
|
/** CovariantVector type. */ |
| 109 |
LEN |
typedef typename Superclass::InputCovariantVectorType InputCovariantVectorType; |
| 110 |
LEN |
typedef typename Superclass::OutputCovariantVectorType OutputCovariantVectorType; |
| 111 |
|
|
| 112 |
|
/** VnlVector type. */ |
| 113 |
|
typedef typename Superclass::InputVnlVectorType InputVnlVectorType; |
| 114 |
|
typedef typename Superclass::OutputVnlVectorType OutputVnlVectorType; |
| 115 |
|
|
| 116 |
|
/** Set the Scale part of the transform. */ |
| 117 |
|
void SetScale( ScaleType scale ); |
| 118 |
|
itkGetConstReferenceMacro( Scale, ScaleType ); |
| 119 |
|
|
| 120 |
|
/** Set the transformation from a container of parameters |
| 121 |
IND |
***** This is typically used by optimizers. |
| 122 |
IND |
***** There are 4 parameters. The first one represents the |
| 123 |
IND |
***** scale, the second represents the angle of rotation |
| 124 |
IND |
***** and the last two represent the translation. |
| 125 |
IND |
***** The center of rotation is fixed. |
| 126 |
IND |
***** |
| 127 |
IND |
***** \sa Transform::SetParameters() |
| 128 |
IND |
***** \sa Transform::SetFixedParameters() */ |
| 129 |
|
void SetParameters( const ParametersType & parameters ); |
| 130 |
|
|
| 131 |
|
/** Get the parameters that uniquely define the transform |
| 132 |
|
* This is typically used by optimizers. |
| 133 |
|
* There are 4 parameters. The first one represents the |
| 134 |
|
* scale, the second represents the angle of rotation, |
| 135 |
|
* and the last two represent the translation. |
| 136 |
|
* The center of rotation is fixed. |
| 137 |
|
* |
| 138 |
|
* \sa Transform::GetParameters() |
| 139 |
|
* \sa Transform::GetFixedParameters() */ |
| 140 |
|
const ParametersType & GetParameters( void ) const; |
| 141 |
|
|
| 142 |
IND |
***/** This method computes the Jacobian matrix of the transformation |
| 143 |
|
* at a given input point. |
| 144 |
|
* |
| 145 |
|
* \sa Transform::GetJacobian() */ |
| 146 |
IND |
*const JacobianType & GetJacobian(const InputPointType &point ) const; |
| 147 |
|
|
| 148 |
|
/** Set the transformation to an identity. */ |
| 149 |
|
virtual void SetIdentity( void ); |
| 150 |
|
|
| 151 |
|
/** |
| 152 |
|
* This method creates and returns a new Similarity2DTransform object |
| 153 |
|
* which is the inverse of self. |
| 154 |
|
**/ |
| 155 |
|
void CloneInverseTo( Pointer & newinverse ) const; |
| 156 |
|
|
| 157 |
|
/** |
| 158 |
|
* This method creates and returns a new Similarity2DTransform object |
| 159 |
|
* which has the same parameters. |
| 160 |
|
**/ |
| 161 |
|
void CloneTo( Pointer & clone ) const; |
| 162 |
|
|
| 163 |
|
/** |
| 164 |
|
* Set the rotation Matrix of a Similarity 2D Transform |
| 165 |
|
* |
| 166 |
|
* This method sets the 2x2 matrix representing a similarity |
| 167 |
|
* transform. The Matrix is expected to be a valid |
| 168 |
|
* similarity transform with a certain tolerance. |
| 169 |
|
* |
| 170 |
|
* \warning This method will throw an exception if the matrix |
| 171 |
|
* provided as argument is not valid. |
| 172 |
|
* |
| 173 |
|
* \sa MatrixOffsetTransformBase::SetMatrix() |
| 174 |
|
* |
| 175 |
|
**/ |
| 176 |
|
virtual void SetMatrix( const MatrixType & matrix ); |
| 177 |
|
|
| 178 |
|
protected: |
| 179 |
|
Similarity2DTransform(); |
| 180 |
|
Similarity2DTransform( unsigned int spaceDimension, |
| 181 |
|
unsigned int parametersDimension); |
| 182 |
|
|
| 183 |
|
~Similarity2DTransform(){}; |
| 184 |
|
void PrintSelf(std::ostream &os, Indent indent) const; |
| 185 |
|
|
| 186 |
|
/** Compute matrix from angle and scale. This is used in Set methods |
| 187 |
|
* to update the underlying matrix whenever a transform parameter |
| 188 |
|
* is changed. */ |
| 189 |
|
virtual void ComputeMatrix(void); |
| 190 |
|
|
| 191 |
|
/** Compute the angle and scale from the matrix. This is used to compute |
| 192 |
|
* transform parameters from a given matrix. This is used in |
| 193 |
|
* MatrixOffsetTransformBase::Compose() and |
| 194 |
|
* MatrixOffsetTransformBase::GetInverse(). */ |
| 195 |
|
virtual void ComputeMatrixParameters(void); |
| 196 |
|
|
| 197 |
|
/** Set the scale without updating underlying variables. */ |
| 198 |
|
void SetVarScale( ScaleType scale ) |
| 199 |
|
{ m_Scale = scale; } |
| 200 |
|
|
| 201 |
|
private: |
| 202 |
|
Similarity2DTransform(const Self&); //purposely not implemented |
| 203 |
|
void operator=(const Self&); //purposely not implemented |
| 204 |
|
|
| 205 |
|
ScaleType m_Scale; |
| 206 |
|
|
| 207 |
|
}; //class Similarity2DTransform |
| 208 |
|
|
| 209 |
|
|
| 210 |
|
} // namespace itk |
| 211 |
|
|
| 212 |
|
|
| 213 |
|
#ifndef ITK_MANUAL_INSTANTIATION |
| 214 |
|
#include "itkSimilarity2DTransform.txx" |
| 215 |
|
#endif |
| 216 |
|
|
| 217 |
|
#endif /* __itkSimilarity2DTransform_h */ |
| 218 |
|
|