go home Home | Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Namespace Members | Data Fields | Globals | Related Pages
itkAdvancedBSplineDeformableTransformBase.h
Go to the documentation of this file.
00001 /*======================================================================
00002 
00003 This file is part of the elastix software.
00004 
00005 Copyright (c) University Medical Center Utrecht. All rights reserved.
00006 See src/CopyrightElastix.txt or http://elastix.isi.uu.nl/legal.php for
00007 details.
00008 
00009 This software is distributed WITHOUT ANY WARRANTY; without even
00010 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00011 PURPOSE. See the above copyright notices for more information.
00012 
00013 ======================================================================*/
00014 
00015 #ifndef __itkAdvancedBSplineDeformableTransformBase_h
00016 #define __itkAdvancedBSplineDeformableTransformBase_h
00017 
00018 #include "itkAdvancedTransform.h"
00019 #include "itkImage.h"
00020 #include "itkImageRegion.h"
00021 
00022 
00023 namespace itk
00024 {
00025 
00036 template <
00037     class TScalarType = double,          // Data type for scalars
00038     unsigned int NDimensions = 3 >       // Number of dimensions
00039 class ITK_EXPORT AdvancedBSplineDeformableTransformBase
00040   : public AdvancedTransform< TScalarType, NDimensions, NDimensions >
00041 {
00042 public:
00044   typedef AdvancedBSplineDeformableTransformBase    Self;
00045   typedef AdvancedTransform<
00046     TScalarType, NDimensions, NDimensions >         Superclass;
00047   typedef SmartPointer<Self>                        Pointer;
00048   typedef SmartPointer<const Self>                  ConstPointer;
00049 
00051   itkTypeMacro( AdvancedBSplineDeformableTransformBase, AdvancedTransform );
00052 
00054   itkStaticConstMacro( SpaceDimension, unsigned int, NDimensions );
00055 
00057   typedef typename Superclass::ParametersType         ParametersType;
00058   typedef typename Superclass::JacobianType           JacobianType;
00059   typedef typename Superclass::ScalarType             ScalarType;
00060   typedef typename Superclass::InputPointType         InputPointType;
00061   typedef typename Superclass::OutputPointType        OutputPointType;
00062   typedef typename Superclass::InputVectorType        InputVectorType;
00063   typedef typename Superclass::OutputVectorType       OutputVectorType;
00064   typedef typename Superclass::InputVnlVectorType     InputVnlVectorType;
00065   typedef typename Superclass::OutputVnlVectorType    OutputVnlVectorType;
00066   typedef typename Superclass::InputCovariantVectorType
00067     InputCovariantVectorType;
00068   typedef typename Superclass::OutputCovariantVectorType
00069     OutputCovariantVectorType;
00070 
00071   typedef typename Superclass
00072     ::NonZeroJacobianIndicesType                    NonZeroJacobianIndicesType;
00073   typedef typename Superclass::SpatialJacobianType  SpatialJacobianType;
00074   typedef typename Superclass
00075     ::JacobianOfSpatialJacobianType                 JacobianOfSpatialJacobianType;
00076   typedef typename Superclass::SpatialHessianType   SpatialHessianType;
00077   typedef typename Superclass
00078     ::JacobianOfSpatialHessianType                  JacobianOfSpatialHessianType;
00079   typedef typename Superclass::InternalMatrixType   InternalMatrixType;
00080 
00099   void SetParameters( const ParametersType & parameters );
00100 
00116   void SetFixedParameters( const ParametersType & parameters );
00117 
00134   void SetParametersByValue( const ParametersType & parameters );
00135 
00144   void SetIdentity( void );
00145 
00147   virtual const ParametersType& GetParameters( void ) const;
00148 
00150   virtual const ParametersType& GetFixedParameters( void ) const;
00151 
00153   typedef typename ParametersType::ValueType            PixelType;
00154   typedef Image< PixelType,
00155     itkGetStaticConstMacro( SpaceDimension )>           ImageType;
00156   typedef typename ImageType::Pointer                   ImagePointer;
00157 
00159   virtual ImagePointer * GetCoefficientImage( void )
00160     { return this->m_CoefficientImage; }
00161   virtual const ImagePointer * GetCoefficientImage( void ) const
00162     { return this->m_CoefficientImage; }
00163 
00175   virtual void SetCoefficientImage( ImagePointer images[] );
00176 
00178   typedef ImageRegion< itkGetStaticConstMacro( SpaceDimension ) > RegionType;
00179 
00180   typedef typename RegionType::IndexType    IndexType;
00181   typedef typename RegionType::SizeType     SizeType;
00182   typedef typename ImageType::SpacingType   SpacingType;
00183   typedef typename ImageType::DirectionType DirectionType;
00184   typedef typename ImageType::PointType     OriginType;
00185   typedef IndexType                         GridOffsetType;
00186 
00188   virtual void SetGridRegion( const RegionType& region ) = 0;
00189   itkGetMacro( GridRegion, RegionType );
00190   itkGetConstMacro( GridRegion, RegionType );
00191 
00193   virtual void SetGridSpacing( const SpacingType & spacing );
00194   itkGetMacro( GridSpacing, SpacingType );
00195   itkGetConstMacro( GridSpacing, SpacingType );
00196 
00198   virtual void SetGridDirection( const DirectionType & spacing );
00199   itkGetMacro( GridDirection, DirectionType );
00200   itkGetConstMacro( GridDirection, DirectionType );
00201 
00203   virtual void SetGridOrigin( const OriginType& origin );
00204   itkGetMacro( GridOrigin, OriginType );
00205   itkGetConstMacro( GridOrigin, OriginType );
00206 
00208   typedef Transform< ScalarType,
00209     itkGetStaticConstMacro( SpaceDimension ),
00210     itkGetStaticConstMacro( SpaceDimension ) >          BulkTransformType;
00211   typedef typename BulkTransformType::ConstPointer      BulkTransformPointer;
00212 
00216   itkSetConstObjectMacro( BulkTransform, BulkTransformType );
00217   itkGetConstObjectMacro( BulkTransform, BulkTransformType );
00218 
00220   typedef Array<unsigned long> ParameterIndexArrayType;
00221 
00225   virtual OutputVectorType TransformVector( const InputVectorType & ) const
00226     {
00227     itkExceptionMacro( << "Method not applicable for deformable transform." );
00228     return OutputVectorType();
00229     }
00230 
00234   virtual OutputVnlVectorType TransformVector(const InputVnlVectorType & ) const
00235     {
00236     itkExceptionMacro( << "Method not applicable for deformable transform. ");
00237     return OutputVnlVectorType();
00238     }
00239 
00243   virtual OutputCovariantVectorType TransformCovariantVector(
00244     const InputCovariantVectorType & ) const
00245     {
00246     itkExceptionMacro( << "Method not applicable for deformable transform. ");
00247     return OutputCovariantVectorType();
00248     }
00249 
00251   virtual unsigned int GetNumberOfParameters( void ) const;
00252 
00254   virtual unsigned int GetNumberOfParametersPerDimension( void ) const;
00255 
00257   itkGetConstReferenceMacro( ValidRegion, RegionType );
00258 
00264   virtual bool IsLinear( void ) const { return false; }
00265 
00266   virtual unsigned int GetNumberOfAffectedWeights( void ) const = 0;
00267 
00268   virtual unsigned long GetNumberOfNonZeroJacobianIndices( void ) const = 0;
00269 
00271   typedef ContinuousIndex<ScalarType, SpaceDimension> ContinuousIndexType;
00272 
00273 protected:
00275   virtual void PrintSelf( std::ostream &os, Indent indent ) const;
00276 
00277   AdvancedBSplineDeformableTransformBase();
00278   virtual ~AdvancedBSplineDeformableTransformBase();
00279 
00281   void WrapAsImages( void );
00282 
00284   void TransformPointToContinuousGridIndex(
00285    const InputPointType & point, ContinuousIndexType & index ) const;
00286 
00287   virtual void ComputeNonZeroJacobianIndices(
00288     NonZeroJacobianIndicesType & nonZeroJacobianIndices,
00289     const RegionType & supportRegion ) const = 0;
00290 
00292   virtual bool InsideValidRegion( const ContinuousIndexType& index ) const;
00293 
00295   BulkTransformPointer  m_BulkTransform;
00296 
00299   ImagePointer    m_CoefficientImage[ NDimensions ];
00300 
00302   RegionType          m_GridRegion;
00303   SpacingType         m_GridSpacing;
00304   DirectionType       m_GridDirection;
00305   OriginType          m_GridOrigin;
00306   GridOffsetType      m_GridOffsetTable;
00307 
00308   DirectionType       m_PointToIndexMatrix;
00309   SpatialJacobianType m_PointToIndexMatrix2;
00310   DirectionType       m_PointToIndexMatrixTransposed;
00311   SpatialJacobianType m_PointToIndexMatrixTransposed2;
00312   DirectionType       m_IndexToPoint;
00313 
00314   RegionType      m_ValidRegion;
00315 
00317   unsigned long   m_Offset;
00318   SizeType        m_SupportSize;
00319   ContinuousIndexType m_ValidRegionBegin;
00320   ContinuousIndexType m_ValidRegionEnd;
00321 
00323   bool m_SplineOrderOdd;
00324 
00326   const ParametersType *  m_InputParametersPointer;
00327 
00329   typedef typename JacobianType::ValueType      JacobianPixelType;
00330   typedef Image< JacobianPixelType,
00331     itkGetStaticConstMacro( SpaceDimension ) >  JacobianImageType;
00332 
00333   typename JacobianImageType::Pointer m_JacobianImage[ NDimensions ];
00334 
00338   mutable IndexType m_LastJacobianIndex;
00339 
00341   ImagePointer    m_WrappedImage[ NDimensions ];
00342 
00344   ParametersType          m_InternalParametersBuffer;
00345 
00346   void UpdateGridOffsetTable( void );
00347 
00348 private:
00349   AdvancedBSplineDeformableTransformBase(const Self&); //purposely not implemented
00350   void operator=(const Self&); //purposely not implemented
00351 
00352 }; //class AdvancedBSplineDeformableTransformBase
00353 
00354 
00355 }  // namespace itk
00356 
00357 // Define instantiation macro for this template.
00358 #define ITK_TEMPLATE_AdvancedBSplineDeformableTransformBase(_, EXPORT, x, y) namespace itk { \
00359   _(3(class EXPORT AdvancedBSplineDeformableTransformBase< ITK_TEMPLATE_3 x >)) \
00360   namespace Templates { typedef AdvancedBSplineDeformableTransformBase< ITK_TEMPLATE_3 x > \
00361                                                    AdvancedBSplineDeformableTransformBase##y; } \
00362   }
00363 
00364 #if ITK_TEMPLATE_EXPLICIT
00365 # include "Templates/itkAdvancedBSplineDeformableTransformBase+-.h"
00366 #endif
00367 
00368 #if ITK_TEMPLATE_TXX
00369 # include "itkAdvancedBSplineDeformableTransformBase.txx"
00370 #endif
00371 
00372 #endif /* __itkAdvancedBSplineDeformableTransformBase_h */


Generated on 11-05-2011 for elastix by doxygen 1.7.4 elastix logo