00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
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, TDeformationField>
00056 {
00057 public:
00059 typedef DemonsRegistrationFunction Self;
00060 typedef PDEDeformableRegistrationFunction< TFixedImage,
00061 TMovingImage, TDeformationField > Superclass;
00062 typedef SmartPointer<Self> Pointer;
00063 typedef SmartPointer<const Self> ConstPointer;
00064
00066 itkNewMacro(Self);
00067
00069 itkTypeMacro( DemonsRegistrationFunction,
00070 PDEDeformableRegistrationFunction );
00071
00073 typedef typename Superclass::MovingImageType MovingImageType;
00074 typedef typename Superclass::MovingImagePointer MovingImagePointer;
00075
00077 typedef typename Superclass::FixedImageType FixedImageType;
00078 typedef typename Superclass::FixedImagePointer FixedImagePointer;
00079 typedef typename FixedImageType::IndexType IndexType;
00080 typedef typename FixedImageType::SizeType SizeType;
00081
00083 typedef typename Superclass::DeformationFieldType DeformationFieldType;
00084 typedef typename Superclass::DeformationFieldTypePointer
00085 DeformationFieldTypePointer;
00086
00088 itkStaticConstMacro(ImageDimension, unsigned int,Superclass::ImageDimension);
00089
00091 typedef typename Superclass::PixelType PixelType;
00092 typedef typename Superclass::RadiusType RadiusType;
00093 typedef typename Superclass::NeighborhoodType NeighborhoodType;
00094 typedef typename Superclass::FloatOffsetType FloatOffsetType;
00095 typedef typename Superclass::TimeStepType TimeStepType;
00096
00098 typedef double CoordRepType;
00099 typedef InterpolateImageFunction<MovingImageType,CoordRepType> InterpolatorType;
00100 typedef typename InterpolatorType::Pointer InterpolatorPointer;
00101 typedef typename InterpolatorType::PointType PointType;
00102 typedef LinearInterpolateImageFunction<MovingImageType,CoordRepType>
00103 DefaultInterpolatorType;
00104
00106 typedef CovariantVector<double,itkGetStaticConstMacro(ImageDimension)> CovariantVectorType;
00107
00109 typedef CentralDifferenceImageFunction<FixedImageType> GradientCalculatorType;
00110 typedef typename GradientCalculatorType::Pointer GradientCalculatorPointer;
00111
00113 void SetMovingImageInterpolator( InterpolatorType * ptr )
00114 { m_MovingImageInterpolator = ptr; }
00115
00117 InterpolatorType * GetMovingImageInterpolator(void)
00118 { return m_MovingImageInterpolator; }
00119
00121 virtual TimeStepType ComputeGlobalTimeStep(void * itkNotUsed(GlobalData)) const
00122 { return m_TimeStep; }
00123
00126 virtual void *GetGlobalDataPointer() const
00127 {
00128 GlobalDataStruct *global = new GlobalDataStruct();
00129 return global;
00130 }
00131
00133 virtual void ReleaseGlobalDataPointer( void *GlobalData ) const
00134 { delete (GlobalDataStruct *) GlobalData; }
00135
00137 virtual void InitializeIteration();
00138
00141 virtual PixelType ComputeUpdate(const NeighborhoodType &neighborhood,
00142 void *globalData,
00143 const FloatOffsetType &offset = FloatOffsetType(0.0)) const;
00144
00147
00148
00149
00150
00151 protected:
00152 DemonsRegistrationFunction();
00153 ~DemonsRegistrationFunction() {}
00154 void PrintSelf(std::ostream& os, Indent indent) const;
00155
00157 typedef ConstNeighborhoodIterator<FixedImageType> FixedImageNeighborhoodIteratorType;
00158
00161 struct GlobalDataStruct
00162 {
00163 FixedImageNeighborhoodIteratorType m_FixedImageIterator;
00164 };
00165
00166 private:
00167 DemonsRegistrationFunction(const Self&);
00168 void operator=(const Self&);
00169
00171 const double * m_FixedImageSpacing;
00172 const double * m_FixedImageOrigin;
00173
00175 GradientCalculatorPointer m_FixedImageGradientCalculator;
00176
00178 InterpolatorPointer m_MovingImageInterpolator;
00179
00181 TimeStepType m_TimeStep;
00182
00184 double m_DenominatorThreshold;
00185
00187 double m_IntensityDifferenceThreshold;
00188
00189 };
00190
00191
00192 }
00193
00194 #ifndef ITK_MANUAL_INSTANTIATION
00195 #include "itkDemonsRegistrationFunction.txx"
00196 #endif
00197
00198 #endif