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: 2008-12-21 19:13:11 $
00007   Version:   $Revision: 1.3 $
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:
00051 
00053   typedef FastSymmetricForcesDemonsRegistrationFunction  Self;
00054   typedef PDEDeformableRegistrationFunction< TFixedImage,
00055                                              TMovingImage, TDeformationField >
00056                                                          Superclass;
00057   typedef SmartPointer<Self>                             Pointer;
00058   typedef SmartPointer<const Self>                       ConstPointer;
00059 
00061   itkNewMacro(Self);
00062 
00064   itkTypeMacro( FastSymmetricForcesDemonsRegistrationFunction, 
00065                 PDEDeformableRegistrationFunction );
00066 
00068   typedef typename Superclass::MovingImageType     MovingImageType;
00069   typedef typename Superclass::MovingImagePointer  MovingImagePointer;
00070 
00072   typedef typename Superclass::FixedImageType     FixedImageType;
00073   typedef typename Superclass::FixedImagePointer  FixedImagePointer;
00074   typedef typename FixedImageType::IndexType      IndexType;
00075   typedef typename FixedImageType::SizeType       SizeType;
00076   typedef typename FixedImageType::SpacingType    SpacingType;
00077 
00079   typedef typename Superclass::DeformationFieldType  DeformationFieldType;
00080   typedef typename Superclass::DeformationFieldTypePointer   
00081                                                      DeformationFieldTypePointer;
00082 
00084   itkStaticConstMacro(ImageDimension, unsigned int,Superclass::ImageDimension);
00085 
00087   typedef typename Superclass::PixelType           PixelType;
00088   typedef typename Superclass::RadiusType          RadiusType;
00089   typedef typename Superclass::NeighborhoodType    NeighborhoodType;
00090   typedef typename Superclass::FloatOffsetType     FloatOffsetType;
00091   typedef typename Superclass::TimeStepType        TimeStepType;
00092 
00094   typedef double                                   CoordRepType;
00095   typedef InterpolateImageFunction<MovingImageType,CoordRepType>
00096                                                    InterpolatorType;
00097   typedef typename InterpolatorType::Pointer       InterpolatorPointer;
00098   typedef typename InterpolatorType::PointType     PointType;
00099   typedef LinearInterpolateImageFunction<MovingImageType,CoordRepType>
00100                                                    DefaultInterpolatorType;
00101 
00103   typedef WarpImageFilter<MovingImageType,MovingImageType,DeformationFieldType>
00104                                        WarperType;
00105   typedef typename WarperType::Pointer WarperPointer;
00106 
00108   typedef CovariantVector<double,itkGetStaticConstMacro(ImageDimension)>
00109                                        CovariantVectorType;
00110 
00112   typedef CentralDifferenceImageFunction<FixedImageType>  GradientCalculatorType;
00113   typedef typename GradientCalculatorType::Pointer        GradientCalculatorPointer;
00114 
00115   typedef CentralDifferenceImageFunction<MovingImageType> MovingGradientCalculatorType;
00116   typedef typename MovingGradientCalculatorType::Pointer   MovingGradientCalculatorPointer;
00117 
00119   void SetMovingImageInterpolator( InterpolatorType * ptr )
00120     {
00121     m_MovingImageInterpolator = ptr; m_MovingImageWarper->SetInterpolator( ptr );
00122     }
00123 
00125   InterpolatorType * GetMovingImageInterpolator(void)
00126     {
00127     return m_MovingImageInterpolator;
00128     }
00129 
00131   virtual TimeStepType ComputeGlobalTimeStep(void * itkNotUsed(GlobalData)) const
00132     {
00133     return m_TimeStep;
00134     }
00135 
00138   virtual void *GetGlobalDataPointer() const
00139     {
00140     GlobalDataStruct *global = new GlobalDataStruct();
00141     global->m_SumOfSquaredDifference  = 0.0;
00142     global->m_NumberOfPixelsProcessed = 0L;
00143     global->m_SumOfSquaredChange      = 0;
00144     return global;
00145     }
00147 
00149   virtual void ReleaseGlobalDataPointer( void *GlobalData ) const;
00150 
00152   virtual void InitializeIteration();
00153 
00156   virtual PixelType  ComputeUpdate(const NeighborhoodType &neighborhood,
00157                                    void *globalData,
00158                                    const FloatOffsetType &offset = FloatOffsetType(0.0));
00159 
00163   virtual double GetMetric() const
00164     {
00165     return m_Metric;
00166     }
00167 
00169   virtual const double &GetRMSChange() const
00170     {
00171     return m_RMSChange;
00172     }
00173 
00178   virtual void SetIntensityDifferenceThreshold(double);
00179   virtual double GetIntensityDifferenceThreshold() const;
00181 
00182 protected:
00183   FastSymmetricForcesDemonsRegistrationFunction();
00184   ~FastSymmetricForcesDemonsRegistrationFunction() {}
00185   void PrintSelf(std::ostream& os, Indent indent) const;
00186 
00188   typedef ConstNeighborhoodIterator<FixedImageType> FixedImageNeighborhoodIteratorType;
00189 
00192   struct GlobalDataStruct
00193     {
00194     double          m_SumOfSquaredDifference;
00195     unsigned long   m_NumberOfPixelsProcessed;
00196     double          m_SumOfSquaredChange;
00197     };
00198 
00199 private:
00200   FastSymmetricForcesDemonsRegistrationFunction(const Self&); //purposely not implemented
00201   void operator=(const Self&); //purposely not implemented
00202 
00204   double                          m_Normalizer;
00205 
00207   GradientCalculatorPointer       m_FixedImageGradientCalculator;
00208 
00210   MovingGradientCalculatorPointer m_WarpedMovingImageGradientCalculator;
00211 
00213   InterpolatorPointer             m_MovingImageInterpolator;
00214 
00216   WarperPointer                   m_MovingImageWarper;
00217 
00219   TimeStepType                    m_TimeStep;
00220 
00222   double                          m_DenominatorThreshold;
00223 
00225   double                          m_IntensityDifferenceThreshold;
00226 
00230   mutable double                  m_Metric;
00231   mutable double                  m_SumOfSquaredDifference;
00232   mutable unsigned long           m_NumberOfPixelsProcessed;
00233   mutable double                  m_RMSChange;
00234   mutable double                  m_SumOfSquaredChange;
00235 
00237   mutable SimpleFastMutexLock     m_MetricCalculationLock;
00238 
00239 };
00240 
00241 
00242 } // end namespace itk
00243 
00244 #ifndef ITK_MANUAL_INSTANTIATION
00245 #include "itkFastSymmetricForcesDemonsRegistrationFunction.txx"
00246 #endif
00247 
00248 #endif
00249 

Generated at Thu May 28 09:54:35 2009 for ITK by doxygen 1.5.5 written by Dimitri van Heesch, © 1997-2000