Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #ifndef __itkAdvancedMatrixOffsetTransformBase_h
00033 #define __itkAdvancedMatrixOffsetTransformBase_h
00034
00035 #include <iostream>
00036
00037 #include "itkMatrix.h"
00038 #include "itkAdvancedTransform.h"
00039 #include "itkExceptionObject.h"
00040 #include "itkMacro.h"
00041
00042 namespace itk
00043 {
00044
00045
00090 template <
00091 class TScalarType=double,
00092 unsigned int NInputDimensions=3,
00093 unsigned int NOutputDimensions=3>
00094 class AdvancedMatrixOffsetTransformBase
00095 : public AdvancedTransform< TScalarType, NInputDimensions, NOutputDimensions >
00096 {
00097 public:
00099 typedef AdvancedMatrixOffsetTransformBase Self;
00100 typedef AdvancedTransform< TScalarType,
00101 NInputDimensions, NOutputDimensions > Superclass;
00102 typedef SmartPointer<Self> Pointer;
00103 typedef SmartPointer<const Self> ConstPointer;
00104
00106 itkTypeMacro( AdvancedMatrixOffsetTransformBase, AdvancedTransform );
00107
00109 itkNewMacro( Self );
00110
00112 itkStaticConstMacro( InputSpaceDimension, unsigned int, NInputDimensions );
00113 itkStaticConstMacro( OutputSpaceDimension, unsigned int, NOutputDimensions );
00114 itkStaticConstMacro( ParametersDimension, unsigned int,
00115 NOutputDimensions * ( NInputDimensions + 1 ) );
00116
00118 typedef typename Superclass::ScalarType ScalarType;
00119 typedef typename Superclass::ParametersType ParametersType;
00120 typedef typename Superclass::JacobianType JacobianType;
00121 typedef typename Superclass::InputVectorType InputVectorType;
00122 typedef typename Superclass::OutputVectorType OutputVectorType;
00123 typedef typename Superclass
00124 ::InputCovariantVectorType InputCovariantVectorType;
00125 typedef typename Superclass
00126 ::OutputCovariantVectorType OutputCovariantVectorType;
00127 typedef typename Superclass::InputVnlVectorType InputVnlVectorType;
00128 typedef typename Superclass::OutputVnlVectorType OutputVnlVectorType;
00129 typedef typename Superclass::InputPointType InputPointType;
00130 typedef typename Superclass::OutputPointType OutputPointType;
00131
00132 typedef typename Superclass
00133 ::NonZeroJacobianIndicesType NonZeroJacobianIndicesType;
00134 typedef typename Superclass::SpatialJacobianType SpatialJacobianType;
00135 typedef typename Superclass
00136 ::JacobianOfSpatialJacobianType JacobianOfSpatialJacobianType;
00137 typedef typename Superclass::SpatialHessianType SpatialHessianType;
00138 typedef typename Superclass
00139 ::JacobianOfSpatialHessianType JacobianOfSpatialHessianType;
00140 typedef typename Superclass::InternalMatrixType InternalMatrixType;
00141
00143 typedef Matrix< TScalarType,
00144 itkGetStaticConstMacro( OutputSpaceDimension ),
00145 itkGetStaticConstMacro( InputSpaceDimension )> MatrixType;
00146
00148 typedef Matrix< TScalarType,
00149 itkGetStaticConstMacro( InputSpaceDimension ),
00150 itkGetStaticConstMacro( OutputSpaceDimension )> InverseMatrixType;
00151
00153 typedef InputPointType CenterType;
00154 typedef OutputVectorType OffsetType;
00155 typedef OutputVectorType TranslationType;
00156
00160 virtual void SetIdentity( void );
00161
00174 virtual void SetMatrix( const MatrixType & matrix )
00175 {
00176 this->m_Matrix = matrix;
00177 this->ComputeOffset();
00178 this->ComputeMatrixParameters();
00179 this->m_MatrixMTime.Modified();
00180 this->Modified();
00181 }
00182
00190 const MatrixType & GetMatrix( void ) const
00191 {
00192 return this->m_Matrix;
00193 }
00194
00204 void SetOffset( const OutputVectorType &offset )
00205 {
00206 this->m_Offset = offset;
00207 this->ComputeTranslation();
00208 this->Modified();
00209 }
00210
00217 const OutputVectorType & GetOffset( void ) const
00218 {
00219 return this->m_Offset;
00220 }
00221
00245 void SetCenter( const InputPointType & center )
00246 {
00247 this->m_Center = center;
00248 this->ComputeOffset();
00249 this->Modified();
00250 }
00251
00259 const InputPointType & GetCenter( void ) const
00260 {
00261 return this->m_Center;
00262 }
00263
00271 void SetTranslation( const OutputVectorType & translation )
00272 {
00273 this->m_Translation = translation;
00274 this->ComputeOffset();
00275 this->Modified();
00276 }
00277
00285 const OutputVectorType & GetTranslation( void ) const
00286 {
00287 return this->m_Translation;
00288 }
00289
00295 void SetParameters( const ParametersType & parameters );
00296
00298 const ParametersType & GetParameters( void ) const;
00299
00301 virtual void SetFixedParameters( const ParametersType & );
00302
00304 virtual const ParametersType & GetFixedParameters( void ) const;
00305
00318 void Compose( const Self * other, bool pre = 0 );
00319
00328 OutputPointType TransformPoint( const InputPointType & point ) const;
00329 OutputVectorType TransformVector( const InputVectorType & vector ) const;
00330 OutputVnlVectorType TransformVector( const InputVnlVectorType & vector ) const;
00331 OutputCovariantVectorType TransformCovariantVector(
00332 const InputCovariantVectorType & vector ) const;
00333
00351 bool GetInverse( Self * inverse ) const;
00352
00356 const InverseMatrixType & GetInverseMatrix( void ) const;
00357
00363 virtual bool IsLinear( void ) const
00364 {
00365 return true;
00366 }
00367
00369 const JacobianType & GetJacobian( const InputPointType & point ) const;
00370
00372 virtual void GetJacobian(
00373 const InputPointType &,
00374 JacobianType &,
00375 NonZeroJacobianIndicesType & ) const;
00376
00378 virtual void GetSpatialJacobian(
00379 const InputPointType &,
00380 SpatialJacobianType & ) const;
00381
00383 virtual void GetSpatialHessian(
00384 const InputPointType &,
00385 SpatialHessianType & ) const;
00386
00388 virtual void GetJacobianOfSpatialJacobian(
00389 const InputPointType &,
00390 JacobianOfSpatialJacobianType &,
00391 NonZeroJacobianIndicesType & ) const;
00392
00394 virtual void GetJacobianOfSpatialJacobian(
00395 const InputPointType &,
00396 SpatialJacobianType &,
00397 JacobianOfSpatialJacobianType &,
00398 NonZeroJacobianIndicesType & ) const;
00399
00401 virtual void GetJacobianOfSpatialHessian(
00402 const InputPointType &,
00403 JacobianOfSpatialHessianType &,
00404 NonZeroJacobianIndicesType & ) const;
00405
00408 virtual void GetJacobianOfSpatialHessian(
00409 const InputPointType & ipp,
00410 SpatialHessianType & sh,
00411 JacobianOfSpatialHessianType & jsh,
00412 NonZeroJacobianIndicesType & nonZeroJacobianIndices ) const;
00413
00414 protected:
00423 AdvancedMatrixOffsetTransformBase( const MatrixType & matrix,
00424 const OutputVectorType & offset );
00425 AdvancedMatrixOffsetTransformBase( unsigned int outputDims,
00426 unsigned int paramDims );
00427 AdvancedMatrixOffsetTransformBase();
00428
00430 virtual void PrecomputeJacobians(unsigned int outputDims, unsigned int paramDims);
00431
00433 virtual ~AdvancedMatrixOffsetTransformBase() {};
00434
00436 void PrintSelf( std::ostream &s, Indent indent ) const;
00437
00438 const InverseMatrixType & GetVarInverseMatrix( void ) const
00439 {
00440 return this->m_InverseMatrix;
00441 };
00442
00443 void SetVarInverseMatrix( const InverseMatrixType & matrix ) const
00444 {
00445 this->m_InverseMatrix = matrix;
00446 this->m_InverseMatrixMTime.Modified();
00447 };
00448
00449 bool InverseMatrixIsOld( void ) const
00450 {
00451 if ( this->m_MatrixMTime != this->m_InverseMatrixMTime )
00452 {
00453 return true;
00454 }
00455 else
00456 {
00457 return false;
00458 }
00459 };
00460
00461 virtual void ComputeMatrixParameters( void );
00462
00463 virtual void ComputeMatrix( void );
00464
00465 void SetVarMatrix( const MatrixType & matrix )
00466 {
00467 this->m_Matrix = matrix;
00468 this->m_MatrixMTime.Modified();
00469 };
00470
00471 virtual void ComputeTranslation( void );
00472
00473 void SetVarTranslation( const OutputVectorType & translation )
00474 {
00475 this->m_Translation = translation;
00476 };
00477
00478 virtual void ComputeOffset( void );
00479
00480 void SetVarOffset( const OutputVectorType & offset )
00481 {
00482 this->m_Offset = offset;
00483 };
00484
00485 void SetVarCenter( const InputPointType & center )
00486 {
00487 this->m_Center = center;
00488 };
00489
00493 NonZeroJacobianIndicesType m_NonZeroJacobianIndices;
00494 SpatialHessianType m_SpatialHessian;
00495 JacobianOfSpatialJacobianType m_JacobianOfSpatialJacobian;
00496 JacobianOfSpatialHessianType m_JacobianOfSpatialHessian;
00497
00498 private:
00499
00500 AdvancedMatrixOffsetTransformBase(const Self & other);
00501 const Self & operator=( const Self & );
00502
00504 MatrixType m_Matrix;
00505 OutputVectorType m_Offset;
00506 mutable InverseMatrixType m_InverseMatrix;
00507 mutable bool m_Singular;
00508
00509 InputPointType m_Center;
00510 OutputVectorType m_Translation;
00511
00513 TimeStamp m_MatrixMTime;
00514 mutable TimeStamp m_InverseMatrixMTime;
00515
00518 mutable NonZeroJacobianIndicesType m_NonZeroJacobianIndicesTemp;
00519
00520 };
00521
00522 }
00523
00524
00525 #define ITK_TEMPLATE_AdvancedMatrixOffsetTransformBase(_, EXPORT, x, y) namespace itk { \
00526 _(3(class EXPORT AdvancedMatrixOffsetTransformBase< ITK_TEMPLATE_3 x >)) \
00527 namespace Templates { typedef AdvancedMatrixOffsetTransformBase< ITK_TEMPLATE_3 x > AdvancedMatrixOffsetTransformBase##y; } \
00528 }
00529
00530 #if ITK_TEMPLATE_EXPLICIT
00531 # include "Templates/itkAdvancedMatrixOffsetTransformBase+-.h"
00532 #endif
00533
00534 #if ITK_TEMPLATE_TXX
00535 # include "itkAdvancedMatrixOffsetTransformBase.txx"
00536 #endif
00537
00538 #endif
00539