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/02/26 23:20:32 $
00007   Version:   $Revision: 1.12 $
00008 
00009   Copyright (c) 2002 Insight 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 
00067 template <
00068     class TScalarType = double,          // Data type for scalars (float or double)
00069     unsigned int NDimensions = 3,        // Number of dimensions
00070     unsigned int VSplineOrder = 3 >      // Spline order
00071 class BSplineDeformableTransform : 
00072           public Transform< TScalarType, NDimensions, NDimensions >
00073 {
00074 public:
00076   typedef BSplineDeformableTransform Self;
00077   typedef Transform< TScalarType, NDimensions, NDimensions > Superclass;
00078   typedef SmartPointer<Self>        Pointer;
00079   typedef SmartPointer<const Self>  ConstPointer;
00080       
00082   itkNewMacro( Self );
00083 
00085   itkTypeMacro( BSplineDeformableTransform, Transform );
00086 
00088   itkStaticConstMacro(SpaceDimension, unsigned int, NDimensions);
00089 
00091   itkStaticConstMacro(SplineOrder, unsigned int, VSplineOrder);
00092 
00094   typedef typename Superclass::ScalarType ScalarType;
00095 
00097   typedef typename Superclass::ParametersType ParametersType;
00098 
00100   typedef typename Superclass::JacobianType JacobianType;
00101 
00103   typedef Vector<TScalarType,
00104                  itkGetStaticConstMacro(SpaceDimension)> InputVectorType;
00105   typedef Vector<TScalarType,
00106                  itkGetStaticConstMacro(SpaceDimension)> OutputVectorType;
00107 
00109   typedef CovariantVector<TScalarType,
00110                           itkGetStaticConstMacro(SpaceDimension)> InputCovariantVectorType;
00111   typedef CovariantVector<TScalarType,
00112                           itkGetStaticConstMacro(SpaceDimension)> OutputCovariantVectorType;
00113   
00115   typedef vnl_vector_fixed<TScalarType,
00116                            itkGetStaticConstMacro(SpaceDimension)> InputVnlVectorType;
00117   typedef vnl_vector_fixed<TScalarType,
00118                            itkGetStaticConstMacro(SpaceDimension)> OutputVnlVectorType;
00119   
00121   typedef Point<TScalarType,
00122                 itkGetStaticConstMacro(SpaceDimension)> InputPointType;
00123   typedef Point<TScalarType,
00124                 itkGetStaticConstMacro(SpaceDimension)> OutputPointType;
00125   
00144   void SetParameters(const ParametersType & parameters);
00145 
00147   virtual const ParametersType& GetParameters(void) const;
00148 
00150   typedef ImageRegion<itkGetStaticConstMacro(SpaceDimension)>    RegionType;
00151   typedef typename RegionType::IndexType IndexType;
00152   typedef typename RegionType::SizeType  SizeType;
00153   typedef FixedArray<double,itkGetStaticConstMacro(SpaceDimension)> SpacingType;
00154   typedef FixedArray<double,itkGetStaticConstMacro(SpaceDimension)> OriginType;
00155 
00157   virtual void SetGridRegion( const RegionType& region );
00158   itkGetMacro( GridRegion, RegionType );
00159 
00161   virtual void SetGridSpacing( const SpacingType& spacing );
00162   itkGetMacro( GridSpacing, SpacingType );
00163 
00165   virtual void SetGridOrigin( const OriginType& origin );
00166   itkGetMacro( GridOrigin, OriginType );
00167 
00169   typedef Transform<ScalarType,itkGetStaticConstMacro(SpaceDimension),
00170                     itkGetStaticConstMacro(SpaceDimension)> BulkTransformType;
00171   typedef typename BulkTransformType::ConstPointer  BulkTransformPointer;
00172 
00176   itkSetConstObjectMacro( BulkTransform, BulkTransformType );
00177   itkGetConstObjectMacro( BulkTransform, BulkTransformType );
00178 
00180   OutputPointType  TransformPoint(const InputPointType  &point ) const;
00181 
00183   typedef BSplineInterpolationWeightFunction<ScalarType,
00184                                              itkGetStaticConstMacro(SpaceDimension),
00185                                              itkGetStaticConstMacro(SplineOrder)> WeightsFunctionType;
00186   typedef typename WeightsFunctionType::WeightsType WeightsType;
00187   typedef typename WeightsFunctionType::ContinuousIndexType ContinuousIndexType;
00188 
00190   typedef Array<unsigned long> ParameterIndexArrayType;
00191 
00199   void TransformPoint( const InputPointType & inputPoint,
00200                        OutputPointType & outputPoint,
00201                        WeightsType & weights,
00202                        ParameterIndexArrayType & indices, 
00203                        bool & inside ) const;
00204 
00206   unsigned long GetNumberOfWeights() const
00207     { return m_WeightsFunction->GetNumberOfWeights(); }
00208 
00210   virtual OutputVectorType TransformVector(const InputVectorType &) const
00211     { 
00212       itkExceptionMacro(<< "Method not applicable for deformable transform." );
00213       return OutputVectorType(); 
00214     }
00215 
00217   virtual OutputVnlVectorType TransformVector(const InputVnlVectorType &) const
00218     { 
00219       itkExceptionMacro(<< "Method not applicable for deformable transform. ");
00220       return OutputVnlVectorType(); 
00221     }
00222 
00224   virtual OutputCovariantVectorType TransformCovariantVector(
00225     const InputCovariantVectorType &) const
00226     { 
00227       itkExceptionMacro(<< "Method not applicable for deformable transfrom. ");
00228       return OutputCovariantVectorType(); 
00229     } 
00230     
00232   void PrintSelf(std::ostream &os, Indent indent) const;
00233 
00235   virtual const JacobianType& GetJacobian(const InputPointType  &point ) const;
00236 
00238   virtual unsigned int GetNumberOfParameters(void) const;
00239 
00241   unsigned int GetNumberOfParametersPerDimension(void) const;
00242 
00244   itkGetConstMacro( ValidRegion, RegionType );
00245 
00246 protected:
00247   BSplineDeformableTransform();
00248   ~BSplineDeformableTransform();
00249 
00250 private:
00251   BSplineDeformableTransform(const Self&); //purposely not implemented
00252   void operator=(const Self&); //purposely not implemented
00253 
00255   BulkTransformPointer  m_BulkTransform;
00256 
00258   RegionType    m_GridRegion;
00259   SpacingType   m_GridSpacing;
00260   OriginType    m_GridOrigin;
00261   
00262   RegionType    m_ValidRegion;
00263 
00265   unsigned long m_Offset;
00266   SizeType      m_SupportSize;
00267 
00269   typedef typename ParametersType::ValueType PixelType;
00270   typedef Image<PixelType,itkGetStaticConstMacro(SpaceDimension)> ImageType;
00271   
00272   typename ImageType::Pointer   m_CoefficientImage[NDimensions];
00273 
00275   typedef typename JacobianType::ValueType JacobianPixelType;
00276   typedef Image<JacobianPixelType,
00277                 itkGetStaticConstMacro(SpaceDimension)> JacobianImageType;
00278  
00279   typename JacobianImageType::Pointer m_JacobianImage[NDimensions];
00280 
00284   mutable IndexType m_LastJacobianIndex;
00285 
00287   const ParametersType *  m_InputParametersPointer;
00288 
00290   typename WeightsFunctionType::Pointer  m_WeightsFunction;
00291 
00292 
00293 }; //class BSplineDeformableTransform
00294 
00295 
00296 }  // namespace itk
00297 
00298 
00299 #ifndef ITK_MANUAL_INSTANTIATION
00300 #include "itkBSplineDeformableTransform.txx"
00301 #endif
00302 
00303 #endif /* __itkBSplineDeformableTransform_h */

Generated at Fri May 21 01:14:29 2004 for ITK by doxygen 1.2.15 written by Dimitri van Heesch, © 1997-2000