15 #ifndef itkSwitchableAffineTransform_h
16 #define itkSwitchableAffineTransform_h
19 #include <itkMatrix.h>
21 #include <itkExceptionObject.h>
23 #include <itkAffineTransform.h>
55 class TScalarType=double,
56 unsigned int NInputDimensions=3,
57 unsigned int NOutputDimensions=3>
59 :
public UCLBaseTransform< TScalarType, NInputDimensions, NOutputDimensions >
76 itkStaticConstMacro(InputSpaceDimension,
unsigned int, NInputDimensions);
77 itkStaticConstMacro(OutputSpaceDimension,
unsigned int, NOutputDimensions);
78 itkStaticConstMacro(ParametersDimension,
unsigned int, (NInputDimensions+1 * NOutputDimensions+1)-1);
90 typedef Vector<TScalarType,
92 typedef Vector<TScalarType,
96 typedef CovariantVector<TScalarType,
97 itkGetStaticConstMacro(InputSpaceDimension)>
99 typedef CovariantVector<TScalarType,
100 itkGetStaticConstMacro(OutputSpaceDimension)>
104 typedef vnl_vector_fixed<TScalarType,
105 itkGetStaticConstMacro(InputSpaceDimension)>
107 typedef vnl_vector_fixed<TScalarType,
108 itkGetStaticConstMacro(OutputSpaceDimension)>
112 typedef Point<TScalarType,
113 itkGetStaticConstMacro(InputSpaceDimension)>
115 typedef Point<TScalarType,
116 itkGetStaticConstMacro(OutputSpaceDimension)>
120 typedef Matrix<TScalarType, itkGetStaticConstMacro(OutputSpaceDimension),
121 itkGetStaticConstMacro(InputSpaceDimension)>
125 typedef Matrix<TScalarType, itkGetStaticConstMacro(InputSpaceDimension),
126 itkGetStaticConstMacro(OutputSpaceDimension)>
149 void SetIdentity(
void );
166 ParametersType parameters;
167 parameters.SetSize((NInputDimensions+1)*(NInputDimensions+1));
169 FullAffineMatrixType
matrix = GetFullAffineMatrix();
172 for (
unsigned int i = 0; i < NOutputDimensions+1; i++)
174 for (
unsigned int j = 0; j < NInputDimensions+1; j++)
176 parameters.SetElement(counter,
matrix(i,j));
182 m_AffineMatrixTransform->SetParameters(parameters);
183 return m_AffineMatrixTransform.GetPointer();
191 FullAffineMatrixType fullAffineMatrix;
193 fullAffineMatrix.SetIdentity();
194 for (
unsigned int i = 0; i < NOutputDimensions; i++)
196 for (
unsigned int j = 0; j < NInputDimensions; j++)
198 fullAffineMatrix(i,j) = this->m_Matrix(i,j);
201 for (
unsigned int i = 0; i < NOutputDimensions; i++)
203 fullAffineMatrix(i,NInputDimensions) = this->m_Offset[i];
205 return fullAffineMatrix;
213 this->m_Matrix.SetIdentity();
214 for (
unsigned int i = 0; i < NOutputDimensions; i++)
216 for (
unsigned int j = 0; j < NInputDimensions; j++)
218 this->m_Matrix(i,j) = fullAffineMatrix(i,j);
221 for (
unsigned int i = 0; i < NOutputDimensions; i++)
223 this->m_Offset[i] = fullAffineMatrix(i,NInputDimensions);
225 this->m_MatrixMTime.Modified();
233 FullAffineMatrixType fullAffineMatrix = GetFullAffineMatrix();
237 SetFullAffineMatrix(sqaureRoot);
245 this->ComputeMatrixAndOffset();
260 { m_Translation = translation;
261 this->ComputeMatrixAndOffset();
269 {
return m_Translation; }
275 { m_Rotation = rotation;
276 this->ComputeMatrixAndOffset();
284 {
return m_Rotation; }
291 this->ComputeMatrixAndOffset();
306 this->ComputeMatrixAndOffset();
321 m_TranslationRelativeWeighting = weighting;
328 m_TranslationRelativeWeighting.Fill( weighting );
336 m_RotationRelativeWeighting = weighting;
343 m_RotationRelativeWeighting.Fill( weighting );
350 m_ScaleRelativeWeighting = weighting;
357 m_ScaleRelativeWeighting.Fill( weighting );
364 m_SkewRelativeWeighting = weighting;
371 m_SkewRelativeWeighting.Fill( weighting );
383 void SetParameters(
const ParametersType & parameters );
401 const ParametersType& GetParameters(
void)
const;
411 if (parameters.GetSize() != 1+NInputDimensions)
412 itkExceptionMacro(
"SwitchableAffineTransform: number of expected fixed parameters does not match.");
413 SetNumberOfDOF(static_cast<int>(parameters.GetElement(0)));
414 for (
unsigned int d = 0; d < NInputDimensions; d++)
416 this->m_Center[d] = parameters.GetElement(1+d);
429 this->m_FixedParameters.SetSize(1+NInputDimensions);
431 this->m_FixedParameters.SetElement(0, this->GetNumberOfDOF());
432 for (
unsigned int d = 0; d < NInputDimensions; d++)
434 this->m_FixedParameters.SetElement(d+1, this->m_Center[d]);
436 return this->m_FixedParameters;
442 const RelativeParameterWeightingType& GetRelativeParameterWeightingFactors();
453 OutputVectorType TransformVector(
const InputVectorType & vector)
const;
454 OutputVnlVectorType TransformVector(
const InputVnlVectorType & vector)
const;
455 OutputCovariantVectorType TransformCovariantVector(
const InputCovariantVectorType &vector)
const;
457 itkSetMacro( OptimiseRotation,
bool );
458 itkGetConstMacro( OptimiseRotation,
bool );
459 itkBooleanMacro( OptimiseRotation );
461 itkSetMacro( OptimiseTranslation,
bool );
462 itkGetConstMacro( OptimiseTranslation,
bool );
463 itkBooleanMacro( OptimiseTranslation );
465 itkSetMacro( OptimiseScale,
bool );
466 itkGetConstMacro( OptimiseScale,
bool );
467 itkBooleanMacro( OptimiseScale );
469 itkSetMacro( OptimiseSkew,
bool );
470 itkGetConstMacro( OptimiseSkew,
bool );
471 itkBooleanMacro( OptimiseSkew );
478 return this->GetNumberOfDOF();
484 unsigned int GetNumberOfDOF()
const;
489 void SetNumberOfDOF(
int number);
496 OptimiseRotationOn();
497 OptimiseTranslationOn();
508 OptimiseRotationOn();
509 OptimiseTranslationOn();
520 OptimiseRotationOn();
521 OptimiseTranslationOn();
532 OptimiseRotationOff();
533 OptimiseTranslationOff();
544 OptimiseRotationOn();
545 OptimiseTranslationOff();
556 OptimiseRotationOff();
557 OptimiseTranslationOn();
573 virtual const JacobianType GetJacobian(
const InputPointType & point )
const = 0;
581 bool GetInverse(Self* inverse)
const;
589 unsigned int paramDims);
596 void PrintSelf(std::ostream &
s, Indent indent)
const;
605 void SetDefaultRelativeParameterWeightings(
void );
610 const InverseMatrixType & GetInverseMatrix(
void )
const;
613 {
return m_InverseMatrix; };
616 { m_InverseMatrix =
matrix; m_InverseMatrixMTime.Modified(); };
619 {
if(m_MatrixMTime != m_InverseMatrixMTime)
620 {
return true; }
else {
return false; } };
628 const Self & operator=(
const Self & );
631 TranslationType m_Translation;
632 RotationType m_Rotation;
635 bool m_OptimiseRotation;
636 bool m_OptimiseTranslation;
637 bool m_OptimiseScale;
640 RelativeParameterWeightingType m_TranslationRelativeWeighting;
641 RelativeParameterWeightingType m_RotationRelativeWeighting;
642 RelativeParameterWeightingType m_ScaleRelativeWeighting;
643 RelativeParameterWeightingType m_SkewRelativeWeighting;
644 RelativeParameterWeightingType m_AllRelativeWeightings;
647 mutable bool m_Singular;
649 FullAffineTransformPointer m_AffineMatrixTransform;
652 TimeStamp m_MatrixMTime;
653 mutable TimeStamp m_InverseMatrixMTime;
659 #ifndef ITK_MANUAL_INSTANTIATION
660 #include "itkSwitchableAffineTransform.txx"
GLuint counter
Definition: glew.h:2637
GLenum GLenum GLenum GLenum GLenum scale
Definition: glew.h:12017
GLenum GLenum GLenum input
Definition: glew.h:12016
Definition: niftkITKAffineResampleImage.cxx:74
itk::Point< double, 2 > InputPointType
Definition: EulerAffine2DJacobianTest.cxx:34
vnl_matrix< double > MatrixType
Definition: itkSuperEllipseFit.h:32
GLuint GLenum matrix
Definition: glew.h:12775
Definition: itkMatrixLinearCombinationFunctions.h:24
GLdouble s
Definition: glew.h:1374
itk::Point< double, 2 > OutputPointType
Definition: EulerAffine2DJacobianTest.cxx:35