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: 2005/09/20 23:43:14 $
00007   Version:   $Revision: 1.28 $
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 
00106 template <
00107     class TScalarType = double,          // Data type for scalars (float or double)
00108     unsigned int NDimensions = 3,        // Number of dimensions
00109     unsigned int VSplineOrder = 3 >      // Spline order
00110 class ITK_EXPORT BSplineDeformableTransform : 
00111           public Transform< TScalarType, NDimensions, NDimensions >
00112 {
00113 public:
00115   typedef BSplineDeformableTransform Self;
00116   typedef Transform< TScalarType, NDimensions, NDimensions > Superclass;
00117   typedef SmartPointer<Self>        Pointer;
00118   typedef SmartPointer<const Self>  ConstPointer;
00119       
00121   itkNewMacro( Self );
00122 
00124   itkTypeMacro( BSplineDeformableTransform, Transform );
00125 
00127   itkStaticConstMacro(SpaceDimension, unsigned int, NDimensions);
00128 
00130   itkStaticConstMacro(SplineOrder, unsigned int, VSplineOrder);
00131 
00133   typedef typename Superclass::ScalarType ScalarType;
00134 
00136   typedef typename Superclass::ParametersType ParametersType;
00137 
00139   typedef typename Superclass::JacobianType JacobianType;
00140 
00142   typedef Vector<TScalarType,
00143                  itkGetStaticConstMacro(SpaceDimension)> InputVectorType;
00144   typedef Vector<TScalarType,
00145                  itkGetStaticConstMacro(SpaceDimension)> OutputVectorType;
00146 
00148   typedef CovariantVector<TScalarType,
00149                           itkGetStaticConstMacro(SpaceDimension)> InputCovariantVectorType;
00150   typedef CovariantVector<TScalarType,
00151                           itkGetStaticConstMacro(SpaceDimension)> OutputCovariantVectorType;
00152   
00154   typedef vnl_vector_fixed<TScalarType,
00155                            itkGetStaticConstMacro(SpaceDimension)> InputVnlVectorType;
00156   typedef vnl_vector_fixed<TScalarType,
00157                            itkGetStaticConstMacro(SpaceDimension)> OutputVnlVectorType;
00158   
00160   typedef Point<TScalarType,
00161                 itkGetStaticConstMacro(SpaceDimension)> InputPointType;
00162   typedef Point<TScalarType,
00163                 itkGetStaticConstMacro(SpaceDimension)> OutputPointType;
00164   
00184   void SetParameters(const ParametersType & parameters);
00185   
00200   void SetFixedParameters(const ParametersType & parameters);
00201 
00219   void SetParametersByValue(const ParametersType & parameters);
00220 
00229   void SetIdentity();
00230 
00232   virtual const ParametersType& GetParameters(void) const;
00233 
00235   virtual const ParametersType& GetFixedParameters(void) const;
00236   
00238   typedef typename ParametersType::ValueType PixelType;
00239   typedef Image<PixelType,itkGetStaticConstMacro(SpaceDimension)> ImageType;
00240   typedef typename ImageType::Pointer ImagePointer;
00241 
00243   virtual ImagePointer * GetCoefficientImage()
00244     { return m_CoefficientImage; }
00245 
00258   virtual void SetCoefficientImage( ImagePointer images[] );  
00259 
00261   typedef ImageRegion<itkGetStaticConstMacro(SpaceDimension)>    RegionType;
00262   typedef typename RegionType::IndexType IndexType;
00263   typedef typename RegionType::SizeType  SizeType;
00264   typedef typename ImageType::SpacingType SpacingType;
00265   typedef typename ImageType::PointType OriginType;
00266 
00268   virtual void SetGridRegion( const RegionType& region );
00269   itkGetMacro( GridRegion, RegionType );
00270   itkGetConstMacro( GridRegion, RegionType );
00271 
00273   virtual void SetGridSpacing( const SpacingType& spacing );
00274   itkGetMacro( GridSpacing, SpacingType );
00275   itkGetConstMacro( GridSpacing, SpacingType );
00276 
00278   virtual void SetGridOrigin( const OriginType& origin );
00279   itkGetMacro( GridOrigin, OriginType );
00280   itkGetConstMacro( GridOrigin, OriginType );
00281 
00283   typedef Transform<ScalarType,itkGetStaticConstMacro(SpaceDimension),
00284                     itkGetStaticConstMacro(SpaceDimension)> BulkTransformType;
00285   typedef typename BulkTransformType::ConstPointer  BulkTransformPointer;
00286 
00290   itkSetConstObjectMacro( BulkTransform, BulkTransformType );
00291   itkGetConstObjectMacro( BulkTransform, BulkTransformType );
00292 
00294   OutputPointType  TransformPoint(const InputPointType  &point ) const;
00295 
00297   typedef BSplineInterpolationWeightFunction<ScalarType,
00298                                              itkGetStaticConstMacro(SpaceDimension),
00299                                              itkGetStaticConstMacro(SplineOrder)> WeightsFunctionType;
00300   typedef typename WeightsFunctionType::WeightsType WeightsType;
00301   typedef typename WeightsFunctionType::ContinuousIndexType ContinuousIndexType;
00302 
00304   typedef Array<unsigned long> ParameterIndexArrayType;
00305 
00313   virtual void TransformPoint( const InputPointType & inputPoint,
00314                        OutputPointType & outputPoint,
00315                        WeightsType & weights,
00316                        ParameterIndexArrayType & indices, 
00317                        bool & inside ) const;
00318 
00320   unsigned long GetNumberOfWeights() const
00321     { return m_WeightsFunction->GetNumberOfWeights(); }
00322 
00324   virtual OutputVectorType TransformVector(const InputVectorType &) const
00325     { 
00326       itkExceptionMacro(<< "Method not applicable for deformable transform." );
00327       return OutputVectorType(); 
00328     }
00329 
00331   virtual OutputVnlVectorType TransformVector(const InputVnlVectorType &) const
00332     { 
00333       itkExceptionMacro(<< "Method not applicable for deformable transform. ");
00334       return OutputVnlVectorType(); 
00335     }
00336 
00338   virtual OutputCovariantVectorType TransformCovariantVector(
00339     const InputCovariantVectorType &) const
00340     { 
00341       itkExceptionMacro(<< "Method not applicable for deformable transfrom. ");
00342       return OutputCovariantVectorType(); 
00343     } 
00344     
00346   virtual const JacobianType& GetJacobian(const InputPointType  &point ) const;
00347 
00349   virtual unsigned int GetNumberOfParameters(void) const;
00350 
00352   unsigned int GetNumberOfParametersPerDimension(void) const;
00353 
00355   itkGetConstReferenceMacro( ValidRegion, RegionType );
00356 
00357 protected:
00359   void PrintSelf(std::ostream &os, Indent indent) const;
00360 
00361 
00362   BSplineDeformableTransform();
00363   virtual ~BSplineDeformableTransform();
00364 
00366   itkSetObjectMacro( WeightsFunction, WeightsFunctionType );
00367   itkGetObjectMacro( WeightsFunction, WeightsFunctionType );
00368 
00370   void WrapAsImages();
00371 
00372 private:
00373   BSplineDeformableTransform(const Self&); //purposely not implemented
00374   void operator=(const Self&); //purposely not implemented
00375 
00377   BulkTransformPointer  m_BulkTransform;
00378 
00380   RegionType    m_GridRegion;
00381   SpacingType   m_GridSpacing;
00382   OriginType    m_GridOrigin;
00383   
00384   RegionType    m_ValidRegion;
00385 
00387   unsigned long m_Offset;
00388   bool          m_SplineOrderOdd;
00389   SizeType      m_SupportSize;
00390   IndexType     m_ValidRegionLast;
00391   
00393   ImagePointer   m_WrappedImage[NDimensions];
00394 
00396   ImagePointer   m_CoefficientImage[NDimensions];
00397 
00399   typedef typename JacobianType::ValueType JacobianPixelType;
00400   typedef Image<JacobianPixelType,
00401                 itkGetStaticConstMacro(SpaceDimension)> JacobianImageType;
00402  
00403   typename JacobianImageType::Pointer m_JacobianImage[NDimensions];
00404 
00408   mutable IndexType m_LastJacobianIndex;
00409 
00411   const ParametersType *  m_InputParametersPointer;
00412 
00414   ParametersType          m_InternalParametersBuffer;
00415 
00417   typename WeightsFunctionType::Pointer  m_WeightsFunction;
00418 
00420   bool InsideValidRegion( const ContinuousIndexType& index ) const;
00421 
00422 
00423 }; //class BSplineDeformableTransform
00424 
00425 
00426 }  // namespace itk
00427 
00428 
00429 #ifndef ITK_MANUAL_INSTANTIATION
00430 #include "itkBSplineDeformableTransform.txx"
00431 #endif
00432 
00433 #endif /* __itkBSplineDeformableTransform_h */

Generated at Wed May 24 22:53:03 2006 for ITK by doxygen 1.3.5 written by Dimitri van Heesch, © 1997-2000