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 const ImagePointer * GetCoefficientImage( void ) const
00160     { return this->m_CoefficientImage; }
00161 
00173   virtual void SetCoefficientImage( ImagePointer images[] );
00174 
00176   typedef ImageRegion< itkGetStaticConstMacro( SpaceDimension ) > RegionType;
00177 
00178   typedef typename RegionType::IndexType    IndexType;
00179   typedef typename RegionType::SizeType     SizeType;
00180   typedef typename ImageType::SpacingType   SpacingType;
00181   typedef typename ImageType::DirectionType DirectionType;
00182   typedef typename ImageType::PointType     OriginType;
00183   typedef IndexType                         GridOffsetType;
00184 
00186   virtual void SetGridRegion( const RegionType& region ) = 0;
00187   //itkGetMacro( GridRegion, RegionType );
00188   itkGetConstMacro( GridRegion, RegionType );
00189 
00191   virtual void SetGridSpacing( const SpacingType & spacing );
00192   //itkGetMacro( GridSpacing, SpacingType );
00193   itkGetConstMacro( GridSpacing, SpacingType );
00194 
00196   virtual void SetGridDirection( const DirectionType & direction );
00197   //itkGetMacro( GridDirection, DirectionType );
00198   itkGetConstMacro( GridDirection, DirectionType );
00199 
00201   virtual void SetGridOrigin( const OriginType& origin );
00202   //itkGetMacro( GridOrigin, OriginType );
00203   itkGetConstMacro( GridOrigin, OriginType );
00204 
00206   typedef Array<unsigned long> ParameterIndexArrayType;
00207 
00211   virtual OutputVectorType TransformVector( const InputVectorType & ) const
00212     {
00213     itkExceptionMacro( << "Method not applicable for deformable transform." );
00214     return OutputVectorType();
00215     }
00216 
00220   virtual OutputVnlVectorType TransformVector( const InputVnlVectorType & ) const
00221     {
00222     itkExceptionMacro( << "Method not applicable for deformable transform. ");
00223     return OutputVnlVectorType();
00224     }
00225 
00229   virtual OutputCovariantVectorType TransformCovariantVector(
00230     const InputCovariantVectorType & ) const
00231     {
00232     itkExceptionMacro( << "Method not applicable for deformable transform. ");
00233     return OutputCovariantVectorType();
00234     }
00235 
00237   virtual unsigned int GetNumberOfParameters( void ) const;
00238 
00240   virtual unsigned int GetNumberOfParametersPerDimension( void ) const;
00241 
00243   itkGetConstReferenceMacro( ValidRegion, RegionType );
00244 
00250   virtual bool IsLinear( void ) const { return false; }
00251 
00252   virtual unsigned int GetNumberOfAffectedWeights( void ) const = 0;
00253 
00254   virtual unsigned long GetNumberOfNonZeroJacobianIndices( void ) const = 0;
00255 
00259   typedef ContinuousIndex<ScalarType, SpaceDimension> ContinuousIndexType;
00260 
00261 protected:
00263   virtual void PrintSelf( std::ostream &os, Indent indent ) const;
00264 
00265   AdvancedBSplineDeformableTransformBase();
00266   virtual ~AdvancedBSplineDeformableTransformBase();
00267 
00269   void WrapAsImages( void );
00270 
00272   void TransformPointToContinuousGridIndex(
00273    const InputPointType & point, ContinuousIndexType & index ) const;
00274 
00275   virtual void ComputeNonZeroJacobianIndices(
00276     NonZeroJacobianIndicesType & nonZeroJacobianIndices,
00277     const RegionType & supportRegion ) const = 0;
00278 
00280   virtual bool InsideValidRegion( const ContinuousIndexType& index ) const;
00281 
00285   ImagePointer        m_CoefficientImage[ NDimensions ];
00286 
00288   RegionType          m_GridRegion;
00289   SpacingType         m_GridSpacing;
00290   DirectionType       m_GridDirection;
00291   OriginType          m_GridOrigin;
00292   GridOffsetType      m_GridOffsetTable;
00293 
00294   DirectionType       m_PointToIndexMatrix;
00295   SpatialJacobianType m_PointToIndexMatrix2;
00296   DirectionType       m_PointToIndexMatrixTransposed;
00297   SpatialJacobianType m_PointToIndexMatrixTransposed2;
00298   DirectionType       m_IndexToPoint;
00299 
00300   RegionType          m_ValidRegion;
00301 
00303   unsigned long       m_Offset;
00304   SizeType            m_SupportSize;
00305   ContinuousIndexType m_ValidRegionBegin;
00306   ContinuousIndexType m_ValidRegionEnd;
00307 
00309   bool m_SplineOrderOdd;
00310 
00312   const ParametersType *  m_InputParametersPointer;
00313 
00315   typedef typename JacobianType::ValueType      JacobianPixelType;
00316   typedef Image< JacobianPixelType,
00317     itkGetStaticConstMacro( SpaceDimension ) >  JacobianImageType;
00318 
00319   typename JacobianImageType::Pointer m_JacobianImage[ NDimensions ];
00320 
00324   mutable IndexType m_LastJacobianIndex;
00325 
00327   ImagePointer      m_WrappedImage[ NDimensions ];
00328 
00330   ParametersType    m_InternalParametersBuffer;
00331 
00332   void UpdateGridOffsetTable( void );
00333 
00334 private:
00335   AdvancedBSplineDeformableTransformBase(const Self&); //purposely not implemented
00336   void operator=(const Self&); //purposely not implemented
00337 
00338 }; //class AdvancedBSplineDeformableTransformBase
00339 
00340 
00341 }  // namespace itk
00342 
00343 // Define instantiation macro for this template.
00344 #define ITK_TEMPLATE_AdvancedBSplineDeformableTransformBase(_, EXPORT, x, y) namespace itk { \
00345   _(3(class EXPORT AdvancedBSplineDeformableTransformBase< ITK_TEMPLATE_3 x >)) \
00346   namespace Templates { typedef AdvancedBSplineDeformableTransformBase< ITK_TEMPLATE_3 x > \
00347                                                    AdvancedBSplineDeformableTransformBase##y; } \
00348   }
00349 
00350 #if ITK_TEMPLATE_EXPLICIT
00351 # include "Templates/itkAdvancedBSplineDeformableTransformBase+-.h"
00352 #endif
00353 
00354 #if ITK_TEMPLATE_TXX
00355 # include "itkAdvancedBSplineDeformableTransformBase.txx"
00356 #endif
00357 
00358 #endif /* __itkAdvancedBSplineDeformableTransformBase_h */


Generated on 24-05-2012 for elastix by doxygen 1.7.6.1 elastix logo