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/04/26 20:24:30 $
00007   Version:   $Revision: 1.27 $
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 
00203   void SetParametersByValue(const ParametersType & parameters);
00204 
00213   void SetIdentity();
00214 
00216   virtual const ParametersType& GetParameters(void) const;
00217 
00219   typedef typename ParametersType::ValueType PixelType;
00220   typedef Image<PixelType,itkGetStaticConstMacro(SpaceDimension)> ImageType;
00221   typedef typename ImageType::Pointer ImagePointer;
00222 
00224   virtual ImagePointer * GetCoefficientImage()
00225     { return m_CoefficientImage; }
00226 
00239   virtual void SetCoefficientImage( ImagePointer images[] );  
00240 
00242   typedef ImageRegion<itkGetStaticConstMacro(SpaceDimension)>    RegionType;
00243   typedef typename RegionType::IndexType IndexType;
00244   typedef typename RegionType::SizeType  SizeType;
00245   typedef typename ImageType::SpacingType SpacingType;
00246   typedef typename ImageType::PointType OriginType;
00247 
00249   virtual void SetGridRegion( const RegionType& region );
00250   itkGetMacro( GridRegion, RegionType );
00251   itkGetConstMacro( GridRegion, RegionType );
00252 
00254   virtual void SetGridSpacing( const SpacingType& spacing );
00255   itkGetMacro( GridSpacing, SpacingType );
00256   itkGetConstMacro( GridSpacing, SpacingType );
00257 
00259   virtual void SetGridOrigin( const OriginType& origin );
00260   itkGetMacro( GridOrigin, OriginType );
00261   itkGetConstMacro( GridOrigin, OriginType );
00262 
00264   typedef Transform<ScalarType,itkGetStaticConstMacro(SpaceDimension),
00265                     itkGetStaticConstMacro(SpaceDimension)> BulkTransformType;
00266   typedef typename BulkTransformType::ConstPointer  BulkTransformPointer;
00267 
00271   itkSetConstObjectMacro( BulkTransform, BulkTransformType );
00272   itkGetConstObjectMacro( BulkTransform, BulkTransformType );
00273 
00275   OutputPointType  TransformPoint(const InputPointType  &point ) const;
00276 
00278   typedef BSplineInterpolationWeightFunction<ScalarType,
00279                                              itkGetStaticConstMacro(SpaceDimension),
00280                                              itkGetStaticConstMacro(SplineOrder)> WeightsFunctionType;
00281   typedef typename WeightsFunctionType::WeightsType WeightsType;
00282   typedef typename WeightsFunctionType::ContinuousIndexType ContinuousIndexType;
00283 
00285   typedef Array<unsigned long> ParameterIndexArrayType;
00286 
00294   virtual void TransformPoint( const InputPointType & inputPoint,
00295                        OutputPointType & outputPoint,
00296                        WeightsType & weights,
00297                        ParameterIndexArrayType & indices, 
00298                        bool & inside ) const;
00299 
00301   unsigned long GetNumberOfWeights() const
00302     { return m_WeightsFunction->GetNumberOfWeights(); }
00303 
00305   virtual OutputVectorType TransformVector(const InputVectorType &) const
00306     { 
00307       itkExceptionMacro(<< "Method not applicable for deformable transform." );
00308       return OutputVectorType(); 
00309     }
00310 
00312   virtual OutputVnlVectorType TransformVector(const InputVnlVectorType &) const
00313     { 
00314       itkExceptionMacro(<< "Method not applicable for deformable transform. ");
00315       return OutputVnlVectorType(); 
00316     }
00317 
00319   virtual OutputCovariantVectorType TransformCovariantVector(
00320     const InputCovariantVectorType &) const
00321     { 
00322       itkExceptionMacro(<< "Method not applicable for deformable transfrom. ");
00323       return OutputCovariantVectorType(); 
00324     } 
00325     
00327   virtual const JacobianType& GetJacobian(const InputPointType  &point ) const;
00328 
00330   virtual unsigned int GetNumberOfParameters(void) const;
00331 
00333   unsigned int GetNumberOfParametersPerDimension(void) const;
00334 
00336   itkGetConstReferenceMacro( ValidRegion, RegionType );
00337 
00338 protected:
00340   void PrintSelf(std::ostream &os, Indent indent) const;
00341 
00342 
00343   BSplineDeformableTransform();
00344   virtual ~BSplineDeformableTransform();
00345 
00347   itkSetObjectMacro( WeightsFunction, WeightsFunctionType );
00348   itkGetObjectMacro( WeightsFunction, WeightsFunctionType );
00349 
00351   void WrapAsImages();
00352 
00353 private:
00354   BSplineDeformableTransform(const Self&); //purposely not implemented
00355   void operator=(const Self&); //purposely not implemented
00356 
00358   BulkTransformPointer  m_BulkTransform;
00359 
00361   RegionType    m_GridRegion;
00362   SpacingType   m_GridSpacing;
00363   OriginType    m_GridOrigin;
00364   
00365   RegionType    m_ValidRegion;
00366 
00368   unsigned long m_Offset;
00369   bool          m_SplineOrderOdd;
00370   SizeType      m_SupportSize;
00371   IndexType     m_ValidRegionLast;
00372   
00374   ImagePointer   m_WrappedImage[NDimensions];
00375 
00377   ImagePointer   m_CoefficientImage[NDimensions];
00378 
00380   typedef typename JacobianType::ValueType JacobianPixelType;
00381   typedef Image<JacobianPixelType,
00382                 itkGetStaticConstMacro(SpaceDimension)> JacobianImageType;
00383  
00384   typename JacobianImageType::Pointer m_JacobianImage[NDimensions];
00385 
00389   mutable IndexType m_LastJacobianIndex;
00390 
00392   const ParametersType *  m_InputParametersPointer;
00393 
00395   ParametersType          m_InternalParametersBuffer;
00396 
00398   typename WeightsFunctionType::Pointer  m_WeightsFunction;
00399 
00401   bool InsideValidRegion( const ContinuousIndexType& index ) const;
00402 
00403 
00404 }; //class BSplineDeformableTransform
00405 
00406 
00407 }  // namespace itk
00408 
00409 
00410 #ifndef ITK_MANUAL_INSTANTIATION
00411 #include "itkBSplineDeformableTransform.txx"
00412 #endif
00413 
00414 #endif /* __itkBSplineDeformableTransform_h */

Generated at Tue Aug 30 16:43:11 2005 for ITK by doxygen 1.4.1 written by Dimitri van Heesch, © 1997-2000