00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
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&);
00184 void operator=(const Self&);
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 }
00228
00229 #ifndef ITK_MANUAL_INSTANTIATION
00230 #include "itkFastSymmetricForcesDemonsRegistrationFunction.txx"
00231 #endif
00232
00233 #endif