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

itkDemonsRegistrationFunction.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkDemonsRegistrationFunction.h,v $
00005   Language:  C++
00006   Date:      $Date: 2008-12-08 16:00:52 $
00007   Version:   $Revision: 1.29 $
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 __itkDemonsRegistrationFunction_h
00018 #define __itkDemonsRegistrationFunction_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 
00027 namespace itk {
00028 
00052 template<class TFixedImage, class TMovingImage, class TDeformationField>
00053 class ITK_EXPORT DemonsRegistrationFunction :
00054     public PDEDeformableRegistrationFunction< TFixedImage,
00055                                               TMovingImage, 
00056 TDeformationField>
00057 {
00058 public:
00059 
00061   typedef DemonsRegistrationFunction    Self;
00062   typedef PDEDeformableRegistrationFunction< TFixedImage,
00063                                              TMovingImage, TDeformationField 
00064  >                                      Superclass;
00065   typedef SmartPointer<Self>            Pointer;
00066   typedef SmartPointer<const Self>      ConstPointer;
00067 
00069   itkNewMacro(Self);
00070 
00072   itkTypeMacro( DemonsRegistrationFunction,
00073                 PDEDeformableRegistrationFunction );
00074 
00076   typedef typename Superclass::MovingImageType     MovingImageType;
00077   typedef typename Superclass::MovingImagePointer  MovingImagePointer;
00078 
00080   typedef typename Superclass::FixedImageType     FixedImageType;
00081   typedef typename Superclass::FixedImagePointer  FixedImagePointer;
00082   typedef typename FixedImageType::IndexType      IndexType;
00083   typedef typename FixedImageType::SizeType       SizeType;
00084   typedef typename FixedImageType::SpacingType    SpacingType;
00085 
00087   typedef typename Superclass::DeformationFieldType  DeformationFieldType;
00088   typedef typename Superclass::DeformationFieldTypePointer
00089                                                      DeformationFieldTypePointer;
00090 
00092   itkStaticConstMacro(ImageDimension, unsigned 
00093 int,Superclass::ImageDimension);
00094 
00096   typedef typename Superclass::PixelType         PixelType;
00097   typedef typename Superclass::RadiusType        RadiusType;
00098   typedef typename Superclass::NeighborhoodType  NeighborhoodType;
00099   typedef typename Superclass::FloatOffsetType   FloatOffsetType;
00100   typedef typename Superclass::TimeStepType      TimeStepType;
00101 
00103   typedef double                                     CoordRepType;
00104   typedef InterpolateImageFunction<MovingImageType,CoordRepType> 
00105                                                      InterpolatorType;
00106   typedef typename InterpolatorType::Pointer         InterpolatorPointer;
00107   typedef typename InterpolatorType::PointType       PointType;
00108   typedef LinearInterpolateImageFunction<MovingImageType,CoordRepType>
00109                                                      DefaultInterpolatorType;
00110 
00112   typedef CovariantVector<double,itkGetStaticConstMacro(ImageDimension)> 
00113 CovariantVectorType;
00114 
00116   typedef CentralDifferenceImageFunction<FixedImageType> 
00117                                                     GradientCalculatorType;
00118   typedef typename GradientCalculatorType::Pointer   
00119                                                     GradientCalculatorPointer;
00120 
00122   typedef CentralDifferenceImageFunction<MovingImageType,CoordRepType>
00123                                           MovingImageGradientCalculatorType;
00124   typedef typename MovingImageGradientCalculatorType::Pointer
00125                                           MovingImageGradientCalculatorPointer;
00126 
00128   void SetMovingImageInterpolator( InterpolatorType * ptr )
00129   { m_MovingImageInterpolator = ptr; }
00130 
00132   InterpolatorType * GetMovingImageInterpolator(void)
00133   { return m_MovingImageInterpolator; }
00134 
00136   virtual TimeStepType ComputeGlobalTimeStep(void * itkNotUsed(GlobalData)) 
00137 const
00138     { return m_TimeStep; }
00139 
00142   virtual void *GetGlobalDataPointer() const
00143     {
00144     GlobalDataStruct *global = new GlobalDataStruct();
00145     global->m_SumOfSquaredDifference  = 0.0;
00146     global->m_NumberOfPixelsProcessed = 0L;
00147     global->m_SumOfSquaredChange      = 0;
00148     return global;
00149     }
00151 
00153   virtual void ReleaseGlobalDataPointer( void *GlobalData ) const;
00154 
00156   virtual void InitializeIteration();
00157 
00160   virtual PixelType  ComputeUpdate(const NeighborhoodType &neighborhood,
00161                                    void *globalData,
00162                                    const FloatOffsetType &offset = 
00163 FloatOffsetType(0.0));
00164 
00168   virtual double GetMetric() const
00169     { return m_Metric; }
00170 
00172   virtual double GetRMSChange() const
00173     { return m_RMSChange; }
00174 
00178   virtual void SetUseMovingImageGradient( bool flag )
00179     { m_UseMovingImageGradient = flag; }
00180   virtual bool GetUseMovingImageGradient() const
00181     { return m_UseMovingImageGradient; }
00183 
00188   virtual void SetIntensityDifferenceThreshold(double);
00189   virtual double GetIntensityDifferenceThreshold() const;
00191 
00192 protected:
00193   DemonsRegistrationFunction();
00194   ~DemonsRegistrationFunction() {}
00195   void PrintSelf(std::ostream& os, Indent indent) const;
00196 
00198   typedef ConstNeighborhoodIterator<FixedImageType> 
00199 FixedImageNeighborhoodIteratorType;
00200 
00203   struct GlobalDataStruct
00204     {
00205     double          m_SumOfSquaredDifference;
00206     unsigned long   m_NumberOfPixelsProcessed;
00207     double          m_SumOfSquaredChange;
00208     };
00209 
00210 private:
00211   DemonsRegistrationFunction(const Self&); //purposely not implemented
00212   void operator=(const Self&); //purposely not implemented
00213 
00215   //SpacingType                  m_FixedImageSpacing;
00216   //PointType                    m_FixedImageOrigin;
00217   PixelType                       m_ZeroUpdateReturn;
00218   double                          m_Normalizer;
00219 
00221   GradientCalculatorPointer       m_FixedImageGradientCalculator;
00222 
00224   MovingImageGradientCalculatorPointer       m_MovingImageGradientCalculator;
00225   bool                                       m_UseMovingImageGradient;
00226 
00228   InterpolatorPointer             m_MovingImageInterpolator;
00229 
00231   TimeStepType                    m_TimeStep;
00232 
00234   double                          m_DenominatorThreshold;
00235 
00237   double                          m_IntensityDifferenceThreshold;
00238 
00242   mutable double                  m_Metric;
00243   mutable double                  m_SumOfSquaredDifference;
00244   mutable unsigned long           m_NumberOfPixelsProcessed;
00245   mutable double                  m_RMSChange;
00246   mutable double                  m_SumOfSquaredChange;
00247 
00249   mutable SimpleFastMutexLock     m_MetricCalculationLock;
00250 
00251 };
00252 
00253 
00254 } // end namespace itk
00255 
00256 #ifndef ITK_MANUAL_INSTANTIATION
00257 #include "itkDemonsRegistrationFunction.txx"
00258 #endif
00259 
00260 #endif
00261 

Generated at Tue Sep 15 02:46:53 2009 for ITK by doxygen 1.5.8 written by Dimitri van Heesch, © 1997-2000