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:
00058
00060 typedef MIRegistrationFunction Self;
00061 typedef PDEDeformableRegistrationFunction< TFixedImage,
00062 TMovingImage, TDeformationField > Superclass;
00063 typedef SmartPointer<Self> Pointer;
00064 typedef SmartPointer<const Self> ConstPointer;
00065
00067 itkNewMacro(Self);
00068
00070 itkTypeMacro( MIRegistrationFunction,
00071 PDEDeformableRegistrationFunction );
00072
00074 typedef typename Superclass::MovingImageType MovingImageType;
00075 typedef typename Superclass::MovingImagePointer MovingImagePointer;
00076
00078 typedef typename Superclass::FixedImageType FixedImageType;
00079 typedef typename Superclass::FixedImagePointer FixedImagePointer;
00080 typedef typename FixedImageType::IndexType IndexType;
00081 typedef typename FixedImageType::SizeType SizeType;
00082 typedef typename FixedImageType::SpacingType SpacingType;
00083
00085 typedef typename Superclass::DeformationFieldType DeformationFieldType;
00086 typedef typename Superclass::DeformationFieldTypePointer
00087 DeformationFieldTypePointer;
00088
00090 itkStaticConstMacro(ImageDimension, unsigned int,Superclass::ImageDimension);
00091
00093 typedef typename Superclass::PixelType PixelType;
00094 typedef typename Superclass::RadiusType RadiusType;
00095 typedef typename Superclass::NeighborhoodType NeighborhoodType;
00096
00097 typedef typename Superclass::FloatOffsetType FloatOffsetType;
00098 typedef typename Superclass::TimeStepType TimeStepType;
00099
00101 typedef double CoordRepType;
00102 typedef InterpolateImageFunction<MovingImageType,CoordRepType> InterpolatorType;
00103 typedef typename InterpolatorType::Pointer InterpolatorPointer;
00104 typedef typename InterpolatorType::PointType PointType;
00105 typedef LinearInterpolateImageFunction<MovingImageType,CoordRepType>
00106 DefaultInterpolatorType;
00107
00109 typedef CovariantVector<double,itkGetStaticConstMacro(ImageDimension)> CovariantVectorType;
00110
00112 typedef CentralDifferenceImageFunction<FixedImageType> GradientCalculatorType;
00113 typedef typename GradientCalculatorType::Pointer GradientCalculatorPointer;
00114
00116 void SetMovingImageInterpolator( InterpolatorType * ptr )
00117 { m_MovingImageInterpolator = ptr; }
00118
00120 InterpolatorType * GetMovingImageInterpolator(void)
00121 { return m_MovingImageInterpolator; }
00122
00124 virtual TimeStepType ComputeGlobalTimeStep(void * itkNotUsed(GlobalData)) const
00125 { return m_TimeStep; }
00126
00129 virtual void *GetGlobalDataPointer() const
00130 {
00131 GlobalDataStruct *global = new GlobalDataStruct();
00132 return global;
00133 }
00135
00137 virtual void ReleaseGlobalDataPointer( void *GlobalData ) const
00138 { delete (GlobalDataStruct *) GlobalData; }
00139
00141 virtual void InitializeIteration();
00142
00145 virtual PixelType ComputeUpdate(const NeighborhoodType &neighborhood,
00146 void *globalData,
00147 const FloatOffsetType &offset = FloatOffsetType(0.0));
00148
00149
00150
00151 void SetMinNorm(float ts=1.0) { m_minnorm=ts;}
00152
00153
00154 void SetDoInverse(bool b = false) { m_DoInverse=b;}
00155
00156
00157 protected:
00158 MIRegistrationFunction();
00159 ~MIRegistrationFunction() {}
00160 void PrintSelf(std::ostream& os, Indent indent) const;
00161
00163 typedef ConstNeighborhoodIterator<FixedImageType> FixedImageNeighborhoodIteratorType;
00164
00167 struct GlobalDataStruct
00168 {
00169 FixedImageNeighborhoodIteratorType m_FixedImageIterator;
00170 };
00171
00173 TimeStepType m_TimeStep;
00174
00175
00176 private:
00177 MIRegistrationFunction(const Self&);
00178 void operator=(const Self&);
00179
00181 SpacingType m_FixedImageSpacing;
00182 PointType m_FixedImageOrigin;
00183
00185 GradientCalculatorPointer m_FixedImageGradientCalculator;
00186
00188 GradientCalculatorPointer m_MovingImageGradientCalculator;
00189
00191 InterpolatorPointer m_MovingImageInterpolator;
00192
00193
00195 double m_DenominatorThreshold;
00196
00198 double m_IntensityDifferenceThreshold;
00199
00200 mutable double m_MetricTotal;
00201
00202 unsigned int m_NumberOfSamples;
00203 unsigned int m_NumberOfBins;
00204 float m_minnorm;
00205
00206 bool m_DoInverse;
00207 };
00208
00209
00210 }
00211
00212 #ifndef ITK_MANUAL_INSTANTIATION
00213 #include "itkMIRegistrationFunction.txx"
00214 #endif
00215
00216 #endif
00217