Main Page   Groups   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Concepts

itkBSplineDeformableTransform.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkBSplineDeformableTransform.h,v $
00005   Language:  C++
00006   Date:      $Date: 2007/05/24 22:39:12 $
00007   Version:   $Revision: 1.33 $
00008 
00009   Copyright (c) Insight Software Consortium. All rights reserved.
00010   See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
00011 
00012      This software is distributed WITHOUT ANY WARRANTY; without even 
00013      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
00014      PURPOSE.  See the above copyright notices for more information.
00015 
00016 =========================================================================*/
00017 
00018 #ifndef __itkBSplineDeformableTransform_h
00019 #define __itkBSplineDeformableTransform_h
00020 
00021 #include <iostream>
00022 #include "itkTransform.h"
00023 #include "itkImage.h"
00024 #include "itkImageRegion.h"
00025 #include "itkBSplineInterpolationWeightFunction.h"
00026 
00027 namespace itk
00028 {
00029 
00107 template <
00108     class TScalarType = double,          // Data type for scalars
00109     unsigned int NDimensions = 3,        // Number of dimensions
00110     unsigned int VSplineOrder = 3 >      // Spline order
00111 class ITK_EXPORT BSplineDeformableTransform : 
00112           public Transform< TScalarType, NDimensions, NDimensions >
00113 {
00114 public:
00116   typedef BSplineDeformableTransform                         Self;
00117   typedef Transform< TScalarType, NDimensions, NDimensions > Superclass;
00118   typedef SmartPointer<Self>                                 Pointer;
00119   typedef SmartPointer<const Self>                           ConstPointer;
00120 
00122   itkNewMacro( Self );
00123 
00125   itkTypeMacro( BSplineDeformableTransform, Transform );
00126 
00128   itkStaticConstMacro(SpaceDimension, unsigned int, NDimensions);
00129 
00131   itkStaticConstMacro(SplineOrder, unsigned int, VSplineOrder);
00132 
00134   typedef typename Superclass::ScalarType ScalarType;
00135 
00137   typedef typename Superclass::ParametersType ParametersType;
00138 
00140   typedef typename Superclass::JacobianType JacobianType;
00141 
00143   typedef Vector<TScalarType,
00144                  itkGetStaticConstMacro(SpaceDimension)> InputVectorType;
00145   typedef Vector<TScalarType,
00146                  itkGetStaticConstMacro(SpaceDimension)> OutputVectorType;
00148 
00150   typedef CovariantVector<TScalarType,
00151              itkGetStaticConstMacro(SpaceDimension)> InputCovariantVectorType;
00152   typedef CovariantVector<TScalarType,
00153             itkGetStaticConstMacro(SpaceDimension)> OutputCovariantVectorType;
00155 
00157   typedef vnl_vector_fixed<TScalarType,
00158                    itkGetStaticConstMacro(SpaceDimension)> InputVnlVectorType;
00159   typedef vnl_vector_fixed<TScalarType,
00160                   itkGetStaticConstMacro(SpaceDimension)> OutputVnlVectorType;
00162 
00164   typedef Point<TScalarType,
00165                 itkGetStaticConstMacro(SpaceDimension)> InputPointType;
00166   typedef Point<TScalarType,
00167                 itkGetStaticConstMacro(SpaceDimension)> OutputPointType;
00169 
00189   void SetParameters(const ParametersType & parameters);
00190 
00206   void SetFixedParameters(const ParametersType & parameters);
00208 
00226   void SetParametersByValue(const ParametersType & parameters);
00227 
00236   void SetIdentity();
00237 
00239   virtual const ParametersType& GetParameters(void) const;
00240 
00242   virtual const ParametersType& GetFixedParameters(void) const;
00243 
00245   typedef typename ParametersType::ValueType                      PixelType;
00246   typedef Image<PixelType,itkGetStaticConstMacro(SpaceDimension)> ImageType;
00247   typedef typename ImageType::Pointer                             ImagePointer;
00248 
00250   virtual ImagePointer * GetCoefficientImage()
00251     { return m_CoefficientImage; }
00252   virtual const ImagePointer * GetCoefficientImage() const
00253     { return m_CoefficientImage; }
00255 
00268   virtual void SetCoefficientImage( ImagePointer images[] );  
00269 
00271   typedef ImageRegion<itkGetStaticConstMacro(SpaceDimension)>    RegionType;
00272 
00273   typedef typename RegionType::IndexType  IndexType;
00274   typedef typename RegionType::SizeType   SizeType;
00275   typedef typename ImageType::SpacingType SpacingType;
00276   typedef typename ImageType::PointType   OriginType;
00277 
00279   virtual void SetGridRegion( const RegionType& region );
00280   itkGetMacro( GridRegion, RegionType );
00281   itkGetConstMacro( GridRegion, RegionType );
00283 
00285   virtual void SetGridSpacing( const SpacingType& spacing );
00286   itkGetMacro( GridSpacing, SpacingType );
00287   itkGetConstMacro( GridSpacing, SpacingType );
00289 
00291   virtual void SetGridOrigin( const OriginType& origin );
00292   itkGetMacro( GridOrigin, OriginType );
00293   itkGetConstMacro( GridOrigin, OriginType );
00295 
00297   typedef Transform<ScalarType,itkGetStaticConstMacro(SpaceDimension),
00298                     itkGetStaticConstMacro(SpaceDimension)> BulkTransformType;
00299   typedef typename BulkTransformType::ConstPointer       BulkTransformPointer;
00301 
00305   itkSetConstObjectMacro( BulkTransform, BulkTransformType );
00306   itkGetConstObjectMacro( BulkTransform, BulkTransformType );
00308 
00310   OutputPointType  TransformPoint(const InputPointType  &point ) const;
00311 
00313   typedef BSplineInterpolationWeightFunction<ScalarType,
00314                      itkGetStaticConstMacro(SpaceDimension),
00315                      itkGetStaticConstMacro(SplineOrder)> WeightsFunctionType;
00316   typedef typename WeightsFunctionType::WeightsType       WeightsType;
00317   typedef typename WeightsFunctionType::ContinuousIndexType 
00318                                                           ContinuousIndexType;
00320 
00322   typedef Array<unsigned long> ParameterIndexArrayType;
00323 
00331   virtual void TransformPoint( const InputPointType & inputPoint,
00332                        OutputPointType & outputPoint,
00333                        WeightsType & weights,
00334                        ParameterIndexArrayType & indices, 
00335                        bool & inside ) const;
00336 
00338   unsigned long GetNumberOfWeights() const
00339     { return m_WeightsFunction->GetNumberOfWeights(); }
00340 
00343   virtual OutputVectorType TransformVector(const InputVectorType &) const
00344     { 
00345     itkExceptionMacro(<< "Method not applicable for deformable transform." );
00346     return OutputVectorType(); 
00347     }
00349 
00352   virtual OutputVnlVectorType TransformVector(const InputVnlVectorType &) const
00353     { 
00354     itkExceptionMacro(<< "Method not applicable for deformable transform. ");
00355     return OutputVnlVectorType(); 
00356     }
00358 
00361   virtual OutputCovariantVectorType TransformCovariantVector(
00362     const InputCovariantVectorType &) const
00363     { 
00364     itkExceptionMacro(<< "Method not applicable for deformable transfrom. ");
00365     return OutputCovariantVectorType(); 
00366     } 
00368 
00370   virtual const JacobianType& GetJacobian(const InputPointType  &point ) const;
00371 
00373   virtual unsigned int GetNumberOfParameters(void) const;
00374 
00376   unsigned int GetNumberOfParametersPerDimension(void) const;
00377 
00379   itkGetConstReferenceMacro( ValidRegion, RegionType );
00380 
00386   virtual bool IsLinear() const { return false; }
00387 
00388 protected:
00390   void PrintSelf(std::ostream &os, Indent indent) const;
00391 
00392 
00393   BSplineDeformableTransform();
00394   virtual ~BSplineDeformableTransform();
00395 
00397   itkSetObjectMacro( WeightsFunction, WeightsFunctionType );
00398   itkGetObjectMacro( WeightsFunction, WeightsFunctionType );
00400 
00402   void WrapAsImages();
00403 
00404 private:
00405   BSplineDeformableTransform(const Self&); //purposely not implemented
00406   void operator=(const Self&); //purposely not implemented
00407 
00409   BulkTransformPointer  m_BulkTransform;
00410 
00412   RegionType    m_GridRegion;
00413   SpacingType   m_GridSpacing;
00414   OriginType    m_GridOrigin;
00415 
00416   RegionType    m_ValidRegion;
00417 
00419   unsigned long m_Offset;
00420   bool          m_SplineOrderOdd;
00421   SizeType      m_SupportSize;
00422   IndexType     m_ValidRegionLast;
00423 
00425   ImagePointer   m_WrappedImage[NDimensions];
00426 
00429   ImagePointer   m_CoefficientImage[NDimensions];
00430 
00432   typedef typename JacobianType::ValueType JacobianPixelType;
00433   typedef Image<JacobianPixelType,
00434                 itkGetStaticConstMacro(SpaceDimension)> JacobianImageType;
00435 
00436   typename JacobianImageType::Pointer m_JacobianImage[NDimensions];
00437 
00441   mutable IndexType m_LastJacobianIndex;
00442 
00444   const ParametersType *  m_InputParametersPointer;
00445 
00447   ParametersType          m_InternalParametersBuffer;
00448 
00450   typename WeightsFunctionType::Pointer  m_WeightsFunction;
00451 
00453   bool InsideValidRegion( const ContinuousIndexType& index ) const;
00454 
00455 
00456 }; //class BSplineDeformableTransform
00457 
00458 
00459 }  // namespace itk
00460 
00461 // Define instantiation macro for this template.
00462 #define ITK_TEMPLATE_BSplineDeformableTransform(_, EXPORT, x, y) namespace itk { \
00463   _(3(class EXPORT BSplineDeformableTransform< ITK_TEMPLATE_3 x >)) \
00464   namespace Templates { typedef BSplineDeformableTransform< ITK_TEMPLATE_3 x > \
00465                                                    BSplineDeformableTransform##y; } \
00466   }
00467 
00468 #if ITK_TEMPLATE_EXPLICIT
00469 # include "Templates/itkBSplineDeformableTransform+-.h"
00470 #endif
00471 
00472 #if ITK_TEMPLATE_TXX
00473 # include "itkBSplineDeformableTransform.txx"
00474 #endif
00475 
00476 #endif /* __itkBSplineDeformableTransform_h */
00477 

Generated at Sun Sep 23 12:04:25 2007 for ITK by doxygen 1.5.1 written by Dimitri van Heesch, © 1997-2000