00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef _itkMIRegistrationFunction_h_
00018 #define _itkMIRegistrationFunction_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 MIRegistrationFunction :
00054 public PDEDeformableRegistrationFunction< TFixedImage,
00055 TMovingImage, TDeformationField>
00056 {
00057 public:
00059 typedef MIRegistrationFunction 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( MIRegistrationFunction,
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 typedef typename FixedImageType::SpacingType SpacingType;
00082
00084 typedef typename Superclass::DeformationFieldType DeformationFieldType;
00085 typedef typename Superclass::DeformationFieldTypePointer
00086 DeformationFieldTypePointer;
00087
00089 itkStaticConstMacro(ImageDimension, unsigned int,Superclass::ImageDimension);
00090
00092 typedef typename Superclass::PixelType PixelType;
00093 typedef typename Superclass::RadiusType RadiusType;
00094 typedef typename Superclass::NeighborhoodType NeighborhoodType;
00095
00096 typedef typename Superclass::FloatOffsetType FloatOffsetType;
00097 typedef typename Superclass::TimeStepType TimeStepType;
00098
00100 typedef double CoordRepType;
00101 typedef InterpolateImageFunction<MovingImageType,CoordRepType> InterpolatorType;
00102 typedef typename InterpolatorType::Pointer InterpolatorPointer;
00103 typedef typename InterpolatorType::PointType PointType;
00104 typedef LinearInterpolateImageFunction<MovingImageType,CoordRepType>
00105 DefaultInterpolatorType;
00106
00108 typedef CovariantVector<double,itkGetStaticConstMacro(ImageDimension)> CovariantVectorType;
00109
00111 typedef CentralDifferenceImageFunction<FixedImageType> GradientCalculatorType;
00112 typedef typename GradientCalculatorType::Pointer GradientCalculatorPointer;
00113
00115 void SetMovingImageInterpolator( InterpolatorType * ptr )
00116 { m_MovingImageInterpolator = ptr; }
00117
00119 InterpolatorType * GetMovingImageInterpolator(void)
00120 { return m_MovingImageInterpolator; }
00121
00123 virtual TimeStepType ComputeGlobalTimeStep(void * itkNotUsed(GlobalData)) const
00124 { return m_TimeStep; }
00125
00128 virtual void *GetGlobalDataPointer() const
00129 {
00130 GlobalDataStruct *global = new GlobalDataStruct();
00131 return global;
00132 }
00133
00135 virtual void ReleaseGlobalDataPointer( void *GlobalData ) const
00136 { delete (GlobalDataStruct *) GlobalData; }
00137
00139 virtual void InitializeIteration();
00140
00143 virtual PixelType ComputeUpdate(const NeighborhoodType &neighborhood,
00144 void *globalData,
00145 const FloatOffsetType &offset = FloatOffsetType(0.0));
00146
00147
00148
00149 void SetMinNorm(float ts=1.0) { m_minnorm=ts;}
00150
00151
00152 void SetDoInverse(bool b = false) { m_DoInverse=b;}
00153
00154
00155 protected:
00156 MIRegistrationFunction();
00157 ~MIRegistrationFunction() {}
00158 void PrintSelf(std::ostream& os, Indent indent) const;
00159
00161 typedef ConstNeighborhoodIterator<FixedImageType> FixedImageNeighborhoodIteratorType;
00162
00165 struct GlobalDataStruct
00166 {
00167 FixedImageNeighborhoodIteratorType m_FixedImageIterator;
00168 };
00169
00171 TimeStepType m_TimeStep;
00172
00173
00174 private:
00175 MIRegistrationFunction(const Self&);
00176 void operator=(const Self&);
00177
00179 SpacingType m_FixedImageSpacing;
00180 PointType m_FixedImageOrigin;
00181
00183 GradientCalculatorPointer m_FixedImageGradientCalculator;
00184
00186 GradientCalculatorPointer m_MovingImageGradientCalculator;
00187
00189 InterpolatorPointer m_MovingImageInterpolator;
00190
00191
00193 double m_DenominatorThreshold;
00194
00196 double m_IntensityDifferenceThreshold;
00197
00198 mutable double m_MetricTotal;
00199
00200 unsigned int m_NumberOfSamples;
00201 unsigned int m_NumberOfBins;
00202 float m_minnorm;
00203
00204 bool m_DoInverse;
00205 };
00206
00207
00208 }
00209
00210 #ifndef ITK_MANUAL_INSTANTIATION
00211 #include "itkMIRegistrationFunction.txx"
00212 #endif
00213
00214 #endif