Main Page   Groups   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Concepts

itkFastSymmetricForcesDemonsRegistrationFunction.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkFastSymmetricForcesDemonsRegistrationFunction.h,v $
00005   Language:  C++
00006   Date:      $Date: 2005/05/03 23:05:49 $
00007   Version:   $Revision: 1.1 $
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 #ifndef _itkFastSymmetricForcesDemonsRegistrationFunction_h_
00018 #define _itkFastSymmetricForcesDemonsRegistrationFunction_h_
00019 
00020 #include "itkPDEDeformableRegistrationFunction.h"
00021 #include "itkPoint.h"
00022 #include "itkCovariantVector.h"
00023 #include "itkInterpolateImageFunction.h"
00024 #include "itkLinearInterpolateImageFunction.h"
00025 #include "itkCentralDifferenceImageFunction.h"
00026 #include "itkWarpImageFilter.h"
00027 
00028 namespace itk {
00029 
00045 template<class TFixedImage, class TMovingImage, class TDeformationField>
00046 class ITK_EXPORT FastSymmetricForcesDemonsRegistrationFunction : 
00047     public PDEDeformableRegistrationFunction< TFixedImage,
00048                                               TMovingImage, TDeformationField>
00049 {
00050 public:
00052   typedef FastSymmetricForcesDemonsRegistrationFunction    Self;
00053   typedef PDEDeformableRegistrationFunction< TFixedImage,
00054                                              TMovingImage, TDeformationField >    Superclass;
00055   typedef SmartPointer<Self> Pointer;
00056   typedef SmartPointer<const Self> ConstPointer;
00057 
00059   itkNewMacro(Self);
00060 
00062   itkTypeMacro( FastSymmetricForcesDemonsRegistrationFunction, 
00063                 PDEDeformableRegistrationFunction );
00064 
00066   typedef typename Superclass::MovingImageType     MovingImageType;
00067   typedef typename Superclass::MovingImagePointer  MovingImagePointer;
00068 
00070   typedef typename Superclass::FixedImageType     FixedImageType;
00071   typedef typename Superclass::FixedImagePointer  FixedImagePointer;
00072   typedef typename FixedImageType::IndexType      IndexType;
00073   typedef typename FixedImageType::SizeType       SizeType;
00074   typedef typename FixedImageType::SpacingType    SpacingType;
00075   
00077   typedef typename Superclass::DeformationFieldType    DeformationFieldType;
00078   typedef typename Superclass::DeformationFieldTypePointer   
00079   DeformationFieldTypePointer;
00080 
00082   itkStaticConstMacro(ImageDimension, unsigned int,Superclass::ImageDimension);
00083 
00085   typedef typename Superclass::PixelType     PixelType;
00086   typedef typename Superclass::RadiusType    RadiusType;
00087   typedef typename Superclass::NeighborhoodType    NeighborhoodType;
00088   typedef typename Superclass::FloatOffsetType  FloatOffsetType;
00089   typedef typename Superclass::TimeStepType TimeStepType;
00090 
00092   typedef double CoordRepType;
00093   typedef InterpolateImageFunction<MovingImageType,CoordRepType> InterpolatorType;
00094   typedef typename InterpolatorType::Pointer         InterpolatorPointer;
00095   typedef typename InterpolatorType::PointType       PointType;
00096   typedef LinearInterpolateImageFunction<MovingImageType,CoordRepType>
00097   DefaultInterpolatorType;
00098 
00100   typedef WarpImageFilter<MovingImageType,MovingImageType,DeformationFieldType> WarperType;
00101   typedef typename WarperType::Pointer WarperPointer;
00102 
00104   typedef CovariantVector<double,itkGetStaticConstMacro(ImageDimension)> CovariantVectorType;
00105 
00107   typedef CentralDifferenceImageFunction<FixedImageType> GradientCalculatorType;
00108   typedef typename GradientCalculatorType::Pointer   GradientCalculatorPointer;
00109 
00110   typedef CentralDifferenceImageFunction<MovingImageType> MovingGradientCalculatorType;
00111   typedef typename MovingGradientCalculatorType::Pointer   MovingGradientCalculatorPointer;
00112 
00114   void SetMovingImageInterpolator( InterpolatorType * ptr )
00115   { m_MovingImageInterpolator = ptr; m_MovingImageWarper->SetInterpolator( ptr ); }
00116 
00118   InterpolatorType * GetMovingImageInterpolator(void)
00119   { return m_MovingImageInterpolator; }
00120 
00122   virtual TimeStepType ComputeGlobalTimeStep(void * itkNotUsed(GlobalData)) const
00123   { return m_TimeStep; }
00124 
00127   virtual void *GetGlobalDataPointer() const
00128   {
00129     GlobalDataStruct *global = new GlobalDataStruct();
00130     global->m_SumOfSquaredDifference  = 0.0;
00131     global->m_NumberOfPixelsProcessed = 0L;
00132     global->m_SumOfSquaredChange      = 0;
00133     return global;
00134   }
00135 
00137   virtual void ReleaseGlobalDataPointer( void *GlobalData ) const;
00138 
00140   virtual void InitializeIteration();
00141 
00144   virtual PixelType  ComputeUpdate(const NeighborhoodType &neighborhood,
00145                                    void *globalData,
00146                                    const FloatOffsetType &offset = FloatOffsetType(0.0));
00147 
00151   virtual double GetMetric() const
00152     { return m_Metric; }
00153 
00155   virtual const double &GetRMSChange() const
00156     { return m_RMSChange; }
00157 
00162   virtual void SetIntensityDifferenceThreshold(double);
00163   virtual double GetIntensityDifferenceThreshold() const;
00164 
00165 protected:
00166   FastSymmetricForcesDemonsRegistrationFunction();
00167   ~FastSymmetricForcesDemonsRegistrationFunction() {}
00168   void PrintSelf(std::ostream& os, Indent indent) const;
00169 
00171   typedef ConstNeighborhoodIterator<FixedImageType> FixedImageNeighborhoodIteratorType;
00172 
00175   struct GlobalDataStruct
00176   {
00177     double          m_SumOfSquaredDifference;
00178     unsigned long   m_NumberOfPixelsProcessed;
00179     double          m_SumOfSquaredChange;
00180   };
00181 
00182 private:
00183   FastSymmetricForcesDemonsRegistrationFunction(const Self&); //purposely not implemented
00184   void operator=(const Self&); //purposely not implemented
00185   
00187   SpacingType                     m_FixedImageSpacing;
00188   PointType                       m_FixedImageOrigin;
00189   double                          m_Normalizer;
00190 
00192   GradientCalculatorPointer       m_FixedImageGradientCalculator;
00193 
00195   MovingGradientCalculatorPointer m_WarpedMovingImageGradientCalculator;
00196 
00198   InterpolatorPointer             m_MovingImageInterpolator;
00199 
00201   WarperPointer                   m_MovingImageWarper;
00202 
00204   TimeStepType                    m_TimeStep;
00205 
00207   double                          m_DenominatorThreshold;
00208 
00210   double                          m_IntensityDifferenceThreshold;
00211 
00215   mutable double                  m_Metric;
00216   mutable double                  m_SumOfSquaredDifference;
00217   mutable unsigned long           m_NumberOfPixelsProcessed;
00218   mutable double                  m_RMSChange;
00219   mutable double                  m_SumOfSquaredChange;
00220 
00222   mutable SimpleFastMutexLock     m_MetricCalculationLock;
00223 
00224 };
00225 
00226 
00227 } // end namespace itk
00228 
00229 #ifndef ITK_MANUAL_INSTANTIATION
00230 #include "itkFastSymmetricForcesDemonsRegistrationFunction.txx"
00231 #endif
00232 
00233 #endif

Generated at Wed May 24 23:06:41 2006 for ITK by doxygen 1.3.5 written by Dimitri van Heesch, © 1997-2000