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: 2006/03/19 23:21:39 $
00007   Version:   $Revision: 1.30 $
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 
00206   void SetFixedParameters(const ParametersType & parameters);
00208 
00226   void SetParametersByValue(const ParametersType & parameters);
00227 
00236   void SetIdentity();
00237 
00239   virtual const ParametersType& GetParameters(void) const;
00240 
00242   virtual const ParametersType& GetFixedParameters(void) const;
00243 
00245   typedef typename ParametersType::ValueType                      PixelType;
00246   typedef Image<PixelType,itkGetStaticConstMacro(SpaceDimension)> ImageType;
00247   typedef typename ImageType::Pointer                             ImagePointer;
00248 
00250   virtual ImagePointer * GetCoefficientImage()
00251     { return m_CoefficientImage; }
00252 
00265   virtual void SetCoefficientImage( ImagePointer images[] );  
00266 
00268   typedef ImageRegion<itkGetStaticConstMacro(SpaceDimension)>    RegionType;
00269 
00270   typedef typename RegionType::IndexType  IndexType;
00271   typedef typename RegionType::SizeType   SizeType;
00272   typedef typename ImageType::SpacingType SpacingType;
00273   typedef typename ImageType::PointType   OriginType;
00274 
00276   virtual void SetGridRegion( const RegionType& region );
00277   itkGetMacro( GridRegion, RegionType );
00278   itkGetConstMacro( GridRegion, RegionType );
00280 
00282   virtual void SetGridSpacing( const SpacingType& spacing );
00283   itkGetMacro( GridSpacing, SpacingType );
00284   itkGetConstMacro( GridSpacing, SpacingType );
00286 
00288   virtual void SetGridOrigin( const OriginType& origin );
00289   itkGetMacro( GridOrigin, OriginType );
00290   itkGetConstMacro( GridOrigin, OriginType );
00292 
00294   typedef Transform<ScalarType,itkGetStaticConstMacro(SpaceDimension),
00295                     itkGetStaticConstMacro(SpaceDimension)> BulkTransformType;
00296   typedef typename BulkTransformType::ConstPointer       BulkTransformPointer;
00298 
00302   itkSetConstObjectMacro( BulkTransform, BulkTransformType );
00303   itkGetConstObjectMacro( BulkTransform, BulkTransformType );
00305 
00307   OutputPointType  TransformPoint(const InputPointType  &point ) const;
00308 
00310   typedef BSplineInterpolationWeightFunction<ScalarType,
00311                      itkGetStaticConstMacro(SpaceDimension),
00312                      itkGetStaticConstMacro(SplineOrder)> WeightsFunctionType;
00313   typedef typename WeightsFunctionType::WeightsType       WeightsType;
00314   typedef typename WeightsFunctionType::ContinuousIndexType 
00315                                                           ContinuousIndexType;
00317 
00319   typedef Array<unsigned long> ParameterIndexArrayType;
00320 
00328   virtual void TransformPoint( const InputPointType & inputPoint,
00329                        OutputPointType & outputPoint,
00330                        WeightsType & weights,
00331                        ParameterIndexArrayType & indices, 
00332                        bool & inside ) const;
00333 
00335   unsigned long GetNumberOfWeights() const
00336     { return m_WeightsFunction->GetNumberOfWeights(); }
00337 
00340   virtual OutputVectorType TransformVector(const InputVectorType &) const
00341     { 
00342     itkExceptionMacro(<< "Method not applicable for deformable transform." );
00343     return OutputVectorType(); 
00344     }
00346 
00349   virtual OutputVnlVectorType TransformVector(const InputVnlVectorType &) const
00350     { 
00351     itkExceptionMacro(<< "Method not applicable for deformable transform. ");
00352     return OutputVnlVectorType(); 
00353     }
00355 
00358   virtual OutputCovariantVectorType TransformCovariantVector(
00359     const InputCovariantVectorType &) const
00360     { 
00361     itkExceptionMacro(<< "Method not applicable for deformable transfrom. ");
00362     return OutputCovariantVectorType(); 
00363     } 
00365 
00367   virtual const JacobianType& GetJacobian(const InputPointType  &point ) const;
00368 
00370   virtual unsigned int GetNumberOfParameters(void) const;
00371 
00373   unsigned int GetNumberOfParametersPerDimension(void) const;
00374 
00376   itkGetConstReferenceMacro( ValidRegion, RegionType );
00377 
00378 protected:
00380   void PrintSelf(std::ostream &os, Indent indent) const;
00381 
00382 
00383   BSplineDeformableTransform();
00384   virtual ~BSplineDeformableTransform();
00385 
00387   itkSetObjectMacro( WeightsFunction, WeightsFunctionType );
00388   itkGetObjectMacro( WeightsFunction, WeightsFunctionType );
00390 
00392   void WrapAsImages();
00393 
00394 private:
00395   BSplineDeformableTransform(const Self&); //purposely not implemented
00396   void operator=(const Self&); //purposely not implemented
00397 
00399   BulkTransformPointer  m_BulkTransform;
00400 
00402   RegionType    m_GridRegion;
00403   SpacingType   m_GridSpacing;
00404   OriginType    m_GridOrigin;
00405 
00406   RegionType    m_ValidRegion;
00407 
00409   unsigned long m_Offset;
00410   bool          m_SplineOrderOdd;
00411   SizeType      m_SupportSize;
00412   IndexType     m_ValidRegionLast;
00413 
00415   ImagePointer   m_WrappedImage[NDimensions];
00416 
00419   ImagePointer   m_CoefficientImage[NDimensions];
00420 
00422   typedef typename JacobianType::ValueType JacobianPixelType;
00423   typedef Image<JacobianPixelType,
00424                 itkGetStaticConstMacro(SpaceDimension)> JacobianImageType;
00425 
00426   typename JacobianImageType::Pointer m_JacobianImage[NDimensions];
00427 
00431   mutable IndexType m_LastJacobianIndex;
00432 
00434   const ParametersType *  m_InputParametersPointer;
00435 
00437   ParametersType          m_InternalParametersBuffer;
00438 
00440   typename WeightsFunctionType::Pointer  m_WeightsFunction;
00441 
00443   bool InsideValidRegion( const ContinuousIndexType& index ) const;
00444 
00445 
00446 }; //class BSplineDeformableTransform
00447 
00448 
00449 }  // namespace itk
00450 
00451 
00452 #ifndef ITK_MANUAL_INSTANTIATION
00453 #include "itkBSplineDeformableTransform.txx"
00454 #endif
00455 
00456 #endif /* __itkBSplineDeformableTransform_h */
00457 

Generated at Sat Sep 2 20:12:42 2006 for ITK by doxygen 1.4.7 written by Dimitri van Heesch, © 1997-2000