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: 2009-05-13 15:26:06 $
00007   Version:   $Revision: 1.41 $
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 
00207   void SetFixedParameters(const ParametersType & parameters);
00209 
00227   void SetParametersByValue(const ParametersType & parameters);
00228 
00237   void SetIdentity();
00238 
00240   virtual const ParametersType& GetParameters(void) const;
00241 
00243   virtual const ParametersType& GetFixedParameters(void) const;
00244 
00246   typedef typename ParametersType::ValueType                      PixelType;
00247   typedef Image<PixelType,itkGetStaticConstMacro(SpaceDimension)> ImageType;
00248   typedef typename ImageType::Pointer                             ImagePointer;
00249 
00251   virtual ImagePointer * GetCoefficientImage()
00252     { return m_CoefficientImage; }
00253   virtual const ImagePointer * GetCoefficientImage() const
00254     { return m_CoefficientImage; }
00256 
00269   virtual void SetCoefficientImage( ImagePointer images[] );  
00270 
00272   typedef ImageRegion<itkGetStaticConstMacro(SpaceDimension)>    RegionType;
00273 
00274   typedef typename RegionType::IndexType    IndexType;
00275   typedef typename RegionType::SizeType     SizeType;
00276   typedef typename ImageType::SpacingType   SpacingType;
00277   typedef typename ImageType::DirectionType DirectionType;
00278   typedef typename ImageType::PointType     OriginType;
00279 
00281   virtual void SetGridRegion( const RegionType& region );
00282   itkGetConstMacro( GridRegion, RegionType );
00284 
00286   virtual void SetGridSpacing( const SpacingType& spacing );
00287   itkGetConstMacro( GridSpacing, SpacingType );
00289 
00291   virtual void SetGridDirection( const DirectionType & spacing );
00292   itkGetConstMacro( GridDirection, DirectionType );
00294 
00296   virtual void SetGridOrigin( const OriginType& origin );
00297   itkGetConstMacro( GridOrigin, OriginType );
00299 
00301   typedef Transform<ScalarType,itkGetStaticConstMacro(SpaceDimension),
00302                     itkGetStaticConstMacro(SpaceDimension)> BulkTransformType;
00303   typedef typename BulkTransformType::ConstPointer       BulkTransformPointer;
00305 
00309   itkSetConstObjectMacro( BulkTransform, BulkTransformType );
00310   itkGetConstObjectMacro( BulkTransform, BulkTransformType );
00312 
00314   OutputPointType  TransformPoint(const InputPointType  &point ) const;
00315 
00317   typedef BSplineInterpolationWeightFunction<ScalarType,
00318                      itkGetStaticConstMacro(SpaceDimension),
00319                      itkGetStaticConstMacro(SplineOrder)> WeightsFunctionType;
00320   typedef typename WeightsFunctionType::WeightsType       WeightsType;
00321   typedef typename WeightsFunctionType::ContinuousIndexType 
00322                                                           ContinuousIndexType;
00324 
00326   typedef Array<unsigned long> ParameterIndexArrayType;
00327 
00335   virtual void TransformPoint( const InputPointType & inputPoint,
00336                        OutputPointType & outputPoint,
00337                        WeightsType & weights,
00338                        ParameterIndexArrayType & indices, 
00339                        bool & inside ) const;
00340 
00341   virtual void GetJacobian( const InputPointType & inputPoint,
00342                        WeightsType & weights,
00343                        ParameterIndexArrayType & indices
00344                        ) const;
00345 
00346 
00348   unsigned long GetNumberOfWeights() const
00349     { return m_WeightsFunction->GetNumberOfWeights(); }
00350 
00353   virtual OutputVectorType TransformVector(const InputVectorType &) const
00354     { 
00355     itkExceptionMacro(<< "Method not applicable for deformable transform." );
00356     return OutputVectorType(); 
00357     }
00359 
00362   virtual OutputVnlVectorType TransformVector(const InputVnlVectorType &) const
00363     { 
00364     itkExceptionMacro(<< "Method not applicable for deformable transform. ");
00365     return OutputVnlVectorType(); 
00366     }
00368 
00371   virtual OutputCovariantVectorType TransformCovariantVector(
00372     const InputCovariantVectorType &) const
00373     { 
00374     itkExceptionMacro(<< "Method not applicable for deformable transfrom. ");
00375     return OutputCovariantVectorType(); 
00376     } 
00378 
00380   virtual const JacobianType& GetJacobian(const InputPointType  &point ) const;
00381 
00383   virtual unsigned int GetNumberOfParameters(void) const;
00384 
00386   unsigned int GetNumberOfParametersPerDimension(void) const;
00387 
00389   itkGetConstReferenceMacro( ValidRegion, RegionType );
00390 
00396   virtual bool IsLinear() const { return false; }
00397 
00398   unsigned int GetNumberOfAffectedWeights() const;
00399 
00400 protected:
00402   void PrintSelf(std::ostream &os, Indent indent) const;
00403 
00404 
00405   BSplineDeformableTransform();
00406   virtual ~BSplineDeformableTransform();
00407 
00409   itkSetObjectMacro( WeightsFunction, WeightsFunctionType );
00410   itkGetObjectMacro( WeightsFunction, WeightsFunctionType );
00412 
00414   void WrapAsImages();
00415 
00417   void TransformPointToContinuousIndex( 
00418    const InputPointType & point, ContinuousIndexType & index ) const;
00419 
00420 private:
00421   BSplineDeformableTransform(const Self&); //purposely not implemented
00422   void operator=(const Self&); //purposely not implemented
00423 
00425   BulkTransformPointer  m_BulkTransform;
00426 
00428   RegionType    m_GridRegion;
00429   SpacingType   m_GridSpacing;
00430   DirectionType m_GridDirection;
00431   OriginType    m_GridOrigin;
00432 
00433   DirectionType m_PointToIndex;
00434   DirectionType m_IndexToPoint;
00435   
00436   RegionType    m_ValidRegion;
00437 
00439   unsigned long m_Offset;
00440   bool          m_SplineOrderOdd;
00441   SizeType      m_SupportSize;
00442   IndexType     m_ValidRegionLast;
00443   IndexType     m_ValidRegionFirst;
00444 
00446   ImagePointer   m_WrappedImage[NDimensions];
00447 
00450   ImagePointer   m_CoefficientImage[NDimensions];
00451 
00453   typedef typename JacobianType::ValueType JacobianPixelType;
00454   typedef Image<JacobianPixelType,
00455                 itkGetStaticConstMacro(SpaceDimension)> JacobianImageType;
00456 
00457   typename JacobianImageType::Pointer m_JacobianImage[NDimensions];
00458 
00462   mutable IndexType m_LastJacobianIndex;
00463 
00465   const ParametersType *  m_InputParametersPointer;
00466 
00468   ParametersType          m_InternalParametersBuffer;
00469 
00471   typename WeightsFunctionType::Pointer  m_WeightsFunction;
00472 
00474   bool InsideValidRegion( const ContinuousIndexType& index ) const;
00475 
00476 
00477 }; //class BSplineDeformableTransform
00478 
00479 
00480 }  // namespace itk
00481 
00482 // Define instantiation macro for this template.
00483 #define ITK_TEMPLATE_BSplineDeformableTransform(_, EXPORT, x, y) namespace itk { \
00484   _(3(class EXPORT BSplineDeformableTransform< ITK_TEMPLATE_3 x >)) \
00485   namespace Templates { typedef BSplineDeformableTransform< ITK_TEMPLATE_3 x > \
00486                                                    BSplineDeformableTransform##y; } \
00487   }
00488 
00489 #if ITK_TEMPLATE_EXPLICIT
00490 # include "Templates/itkBSplineDeformableTransform+-.h"
00491 #endif
00492 
00493 #if ITK_TEMPLATE_TXX
00494 # include "itkBSplineDeformableTransform.txx"
00495 #endif
00496 
00497 #endif /* __itkBSplineDeformableTransform_h */
00498 

Generated at Tue Sep 15 02:27:17 2009 for ITK by doxygen 1.5.8 written by Dimitri van Heesch, © 1997-2000