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: 2003/09/10 14:29:01 $
00007   Version:   $Revision: 1.18 $
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   
00183   void SetParameters(const ParametersType & parameters);
00184 
00186   virtual const ParametersType& GetParameters(void) const;
00187 
00189   typedef typename ParametersType::ValueType PixelType;
00190   typedef Image<PixelType,itkGetStaticConstMacro(SpaceDimension)> ImageType;
00191   typedef typename ImageType::Pointer ImagePointer;
00192 
00194   virtual ImagePointer * GetCoefficientImage()
00195     { return m_CoefficientImage; }
00196 
00209   virtual void SetCoefficientImage( ImagePointer images[] );  
00210 
00212   typedef ImageRegion<itkGetStaticConstMacro(SpaceDimension)>    RegionType;
00213   typedef typename RegionType::IndexType IndexType;
00214   typedef typename RegionType::SizeType  SizeType;
00215   typedef FixedArray<double,itkGetStaticConstMacro(SpaceDimension)> SpacingType;
00216   typedef FixedArray<double,itkGetStaticConstMacro(SpaceDimension)> OriginType;
00217 
00219   virtual void SetGridRegion( const RegionType& region );
00220   itkGetMacro( GridRegion, RegionType );
00221 
00223   virtual void SetGridSpacing( const SpacingType& spacing );
00224   itkGetMacro( GridSpacing, SpacingType );
00225 
00227   virtual void SetGridOrigin( const OriginType& origin );
00228   itkGetMacro( GridOrigin, OriginType );
00229 
00231   typedef Transform<ScalarType,itkGetStaticConstMacro(SpaceDimension),
00232                     itkGetStaticConstMacro(SpaceDimension)> BulkTransformType;
00233   typedef typename BulkTransformType::ConstPointer  BulkTransformPointer;
00234 
00238   itkSetConstObjectMacro( BulkTransform, BulkTransformType );
00239   itkGetConstObjectMacro( BulkTransform, BulkTransformType );
00240 
00242   OutputPointType  TransformPoint(const InputPointType  &point ) const;
00243 
00245   typedef BSplineInterpolationWeightFunction<ScalarType,
00246                                              itkGetStaticConstMacro(SpaceDimension),
00247                                              itkGetStaticConstMacro(SplineOrder)> WeightsFunctionType;
00248   typedef typename WeightsFunctionType::WeightsType WeightsType;
00249   typedef typename WeightsFunctionType::ContinuousIndexType ContinuousIndexType;
00250 
00252   typedef Array<unsigned long> ParameterIndexArrayType;
00253 
00261   void TransformPoint( const InputPointType & inputPoint,
00262                        OutputPointType & outputPoint,
00263                        WeightsType & weights,
00264                        ParameterIndexArrayType & indices, 
00265                        bool & inside ) const;
00266 
00268   unsigned long GetNumberOfWeights() const
00269     { return m_WeightsFunction->GetNumberOfWeights(); }
00270 
00272   virtual OutputVectorType TransformVector(const InputVectorType &) const
00273     { 
00274       itkExceptionMacro(<< "Method not applicable for deformable transform." );
00275       return OutputVectorType(); 
00276     }
00277 
00279   virtual OutputVnlVectorType TransformVector(const InputVnlVectorType &) const
00280     { 
00281       itkExceptionMacro(<< "Method not applicable for deformable transform. ");
00282       return OutputVnlVectorType(); 
00283     }
00284 
00286   virtual OutputCovariantVectorType TransformCovariantVector(
00287     const InputCovariantVectorType &) const
00288     { 
00289       itkExceptionMacro(<< "Method not applicable for deformable transfrom. ");
00290       return OutputCovariantVectorType(); 
00291     } 
00292     
00294   virtual const JacobianType& GetJacobian(const InputPointType  &point ) const;
00295 
00297   virtual unsigned int GetNumberOfParameters(void) const;
00298 
00300   unsigned int GetNumberOfParametersPerDimension(void) const;
00301 
00303   itkGetConstMacro( ValidRegion, RegionType );
00304 
00305 protected:
00307   void PrintSelf(std::ostream &os, Indent indent) const;
00308 
00309 
00310   BSplineDeformableTransform();
00311   ~BSplineDeformableTransform();
00312 
00313 private:
00314   BSplineDeformableTransform(const Self&); //purposely not implemented
00315   void operator=(const Self&); //purposely not implemented
00316 
00318   BulkTransformPointer  m_BulkTransform;
00319 
00321   RegionType    m_GridRegion;
00322   SpacingType   m_GridSpacing;
00323   OriginType    m_GridOrigin;
00324   
00325   RegionType    m_ValidRegion;
00326 
00328   unsigned long m_Offset;
00329   bool          m_SplineOrderOdd;
00330   SizeType      m_SupportSize;
00331   IndexType     m_ValidRegionLast;
00332   
00334   ImagePointer   m_WrappedImage[NDimensions];
00335 
00337   ImagePointer   m_CoefficientImage[NDimensions];
00338 
00340   typedef typename JacobianType::ValueType JacobianPixelType;
00341   typedef Image<JacobianPixelType,
00342                 itkGetStaticConstMacro(SpaceDimension)> JacobianImageType;
00343  
00344   typename JacobianImageType::Pointer m_JacobianImage[NDimensions];
00345 
00349   mutable IndexType m_LastJacobianIndex;
00350 
00352   const ParametersType *  m_InputParametersPointer;
00353 
00355   typename WeightsFunctionType::Pointer  m_WeightsFunction;
00356 
00358   bool InsideValidRegion( const ContinuousIndexType& index ) const;
00359 
00360 
00361 }; //class BSplineDeformableTransform
00362 
00363 
00364 }  // namespace itk
00365 
00366 
00367 #ifndef ITK_MANUAL_INSTANTIATION
00368 #include "itkBSplineDeformableTransform.txx"
00369 #endif
00370 
00371 #endif /* __itkBSplineDeformableTransform_h */

Generated at Sun Jan 25 13:19:29 2004 for ITK by doxygen 1.3.3 written by Dimitri van Heesch, © 1997-2000