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

itkESMDemonsRegistrationFunction.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003 Program:   Insight Segmentation & Registration Toolkit
00004 Module:    $RCSfile: itkESMDemonsRegistrationFunction.h,v $
00005 Language:  C++
00006 Date:      $Date: 2008-11-12 13:59:47 $
00007 Version:   $Revision: 1.6 $
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 __itkESMDemonsRegistrationFunction_h
00019 #define __itkESMDemonsRegistrationFunction_h
00020 
00021 #include "itkPDEDeformableRegistrationFunction.h"
00022 #include "itkPoint.h"
00023 #include "itkCovariantVector.h"
00024 #include "itkInterpolateImageFunction.h"
00025 #include "itkLinearInterpolateImageFunction.h"
00026 #include "itkCentralDifferenceImageFunction.h"
00027 #include "itkWarpImageFilter.h"
00028 
00029 namespace itk {
00061 template<class TFixedImage, class TMovingImage, class TDeformationField>
00062 class ITK_EXPORT ESMDemonsRegistrationFunction :
00063       public PDEDeformableRegistrationFunction< TFixedImage,
00064                                                 TMovingImage, TDeformationField>
00065 {
00066 public:
00067 
00069   typedef ESMDemonsRegistrationFunction               Self;
00070   typedef PDEDeformableRegistrationFunction<
00071     TFixedImage, TMovingImage, TDeformationField >    Superclass;
00072   typedef SmartPointer<Self>                          Pointer;
00073   typedef SmartPointer<const Self>                    ConstPointer;
00074 
00076   itkNewMacro(Self);
00077 
00079   itkTypeMacro( ESMDemonsRegistrationFunction,
00080     PDEDeformableRegistrationFunction );
00081 
00083   typedef typename Superclass::MovingImageType      MovingImageType;
00084   typedef typename Superclass::MovingImagePointer   MovingImagePointer;
00085   typedef typename MovingImageType::PixelType       MovingPixelType;
00086 
00088   typedef typename Superclass::FixedImageType       FixedImageType;
00089   typedef typename Superclass::FixedImagePointer    FixedImagePointer;
00090   typedef typename FixedImageType::IndexType        IndexType;
00091   typedef typename FixedImageType::SizeType         SizeType;
00092   typedef typename FixedImageType::SpacingType      SpacingType;
00093   typedef typename FixedImageType::DirectionType    DirectionType;
00094 
00096   typedef typename Superclass::DeformationFieldType    DeformationFieldType;
00097   typedef typename Superclass::DeformationFieldTypePointer
00098     DeformationFieldTypePointer;
00099 
00101   itkStaticConstMacro(ImageDimension, unsigned int,Superclass::ImageDimension);
00102 
00104   typedef typename Superclass::PixelType            PixelType;
00105   typedef typename Superclass::RadiusType           RadiusType;
00106   typedef typename Superclass::NeighborhoodType     NeighborhoodType;
00107   typedef typename Superclass::FloatOffsetType      FloatOffsetType;
00108   typedef typename Superclass::TimeStepType         TimeStepType;
00109 
00111   typedef double                                    CoordRepType;
00112   typedef InterpolateImageFunction<
00113     MovingImageType,CoordRepType>                   InterpolatorType;
00114   typedef typename InterpolatorType::Pointer        InterpolatorPointer;
00115   typedef typename InterpolatorType::PointType      PointType;
00116   typedef LinearInterpolateImageFunction<
00117     MovingImageType,CoordRepType>                   DefaultInterpolatorType;
00118 
00120   typedef WarpImageFilter<
00121     MovingImageType,
00122     MovingImageType,DeformationFieldType>           WarperType;
00123   typedef typename WarperType::Pointer              WarperPointer;
00124 
00126   typedef CovariantVector<double,itkGetStaticConstMacro(ImageDimension)> CovariantVectorType;
00127 
00129   typedef CentralDifferenceImageFunction<FixedImageType> GradientCalculatorType;
00130   typedef typename GradientCalculatorType::Pointer   GradientCalculatorPointer;
00131 
00133   typedef CentralDifferenceImageFunction<MovingImageType,CoordRepType>
00134     MovingImageGradientCalculatorType;
00135   typedef typename MovingImageGradientCalculatorType::Pointer
00136     MovingImageGradientCalculatorPointer;
00137 
00139   void SetMovingImageInterpolator( InterpolatorType * ptr )
00140     { m_MovingImageInterpolator = ptr; m_MovingImageWarper->SetInterpolator( ptr ); }
00141 
00143   InterpolatorType * GetMovingImageInterpolator(void)
00144     { return m_MovingImageInterpolator; }
00145 
00147   virtual TimeStepType ComputeGlobalTimeStep(void * itkNotUsed(GlobalData)) const
00148     { return m_TimeStep; }
00149 
00152   virtual void *GetGlobalDataPointer() const
00153     {
00154     GlobalDataStruct *global = new GlobalDataStruct();
00155     global->m_SumOfSquaredDifference  = 0.0;
00156     global->m_NumberOfPixelsProcessed = 0L;
00157     global->m_SumOfSquaredChange      = 0;
00158     return global;
00159     }
00161 
00163   virtual void ReleaseGlobalDataPointer( void *GlobalData ) const;
00164 
00166   virtual void InitializeIteration();
00167 
00170   virtual PixelType  ComputeUpdate(const NeighborhoodType &neighborhood,
00171     void *globalData,
00172     const FloatOffsetType &offset = FloatOffsetType(0.0));
00173 
00177   virtual double GetMetric() const
00178     { return m_Metric; }
00179 
00181   virtual const double &GetRMSChange() const
00182     { return m_RMSChange; }
00183 
00188   virtual void SetIntensityDifferenceThreshold(double);
00189   virtual double GetIntensityDifferenceThreshold() const;
00191 
00195   virtual void SetMaximumUpdateStepLength(double sm)
00196     {
00197     this->m_MaximumUpdateStepLength =sm;
00198     }
00199   virtual double GetMaximumUpdateStepLength() const
00200     {
00201     return this->m_MaximumUpdateStepLength;
00202     }
00204 
00206   enum GradientType {
00207     Symmetric=0,
00208     Fixed=1,
00209     WarpedMoving=2,
00210     MappedMoving=3
00211   };
00212 
00214   virtual void SetUseGradientType( GradientType gtype )
00215     { m_UseGradientType = gtype; }
00216   virtual GradientType GetUseGradientType() const
00217     { return m_UseGradientType; }
00219 
00220 protected:
00221   ESMDemonsRegistrationFunction();
00222   ~ESMDemonsRegistrationFunction() {}
00223   void PrintSelf(std::ostream& os, Indent indent) const;
00224 
00226   typedef ConstNeighborhoodIterator<FixedImageType> FixedImageNeighborhoodIteratorType;
00227 
00230   struct GlobalDataStruct
00231     {
00232     double          m_SumOfSquaredDifference;
00233     unsigned long   m_NumberOfPixelsProcessed;
00234     double          m_SumOfSquaredChange;
00235     };
00236 
00237 private:
00238   ESMDemonsRegistrationFunction(const Self&); //purposely not implemented
00239   void operator=(const Self&); //purposely not implemented
00240 
00242   PointType                       m_FixedImageOrigin;
00243   SpacingType                     m_FixedImageSpacing;
00244   DirectionType                   m_FixedImageDirection;
00245   double                          m_Normalizer;
00246 
00248   GradientCalculatorPointer       m_FixedImageGradientCalculator;
00249 
00251   MovingImageGradientCalculatorPointer m_MappedMovingImageGradientCalculator;
00252 
00253   GradientType                    m_UseGradientType;
00254 
00256   InterpolatorPointer             m_MovingImageInterpolator;
00257 
00259   WarperPointer                   m_MovingImageWarper;
00260 
00262   TimeStepType                    m_TimeStep;
00263 
00265   double                          m_DenominatorThreshold;
00266 
00268   double                          m_IntensityDifferenceThreshold;
00269 
00271   double                          m_MaximumUpdateStepLength;
00272 
00276   mutable double                  m_Metric;
00277   mutable double                  m_SumOfSquaredDifference;
00278   mutable unsigned long           m_NumberOfPixelsProcessed;
00279   mutable double                  m_RMSChange;
00280   mutable double                  m_SumOfSquaredChange;
00281 
00283   mutable SimpleFastMutexLock     m_MetricCalculationLock;
00284 };
00285 
00286 } // end namespace itk
00287 
00288 #ifndef ITK_MANUAL_INSTANTIATION
00289 #include "itkESMDemonsRegistrationFunction.txx"
00290 #endif
00291 
00292 #endif
00293 

Generated at Fri Apr 16 18:16:25 2010 for ITK by doxygen 1.6.1 written by Dimitri van Heesch, © 1997-2000