00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef __itkMutualInformationImageToImageMetric_h
00018 #define __itkMutualInformationImageToImageMetric_h
00019
00020 #include "itkImageToImageMetric.h"
00021 #include "itkCovariantVector.h"
00022 #include "itkPoint.h"
00023
00024 #include "itkIndex.h"
00025 #include "itkKernelFunction.h"
00026 #include "itkCentralDifferenceImageFunction.h"
00027
00028 namespace itk
00029 {
00030
00089 template <class TFixedImage,class TMovingImage >
00090 class ITK_EXPORT MutualInformationImageToImageMetric :
00091 public ImageToImageMetric< TFixedImage, TMovingImage >
00092 {
00093 public:
00094
00096 typedef MutualInformationImageToImageMetric Self;
00097 typedef ImageToImageMetric< TFixedImage, TMovingImage > Superclass;
00098 typedef SmartPointer<Self> Pointer;
00099 typedef SmartPointer<const Self> ConstPointer;
00100
00102 itkNewMacro(Self);
00103
00105 itkTypeMacro(MutualInformationImageToImageMetric, ImageToImageMetric);
00106
00108 typedef typename Superclass::TransformType TransformType;
00109 typedef typename Superclass::TransformPointer TransformPointer;
00110 typedef typename Superclass::TransformJacobianType TransformJacobianType;
00111 typedef typename Superclass::InterpolatorType InterpolatorType;
00112 typedef typename Superclass::MeasureType MeasureType;
00113 typedef typename Superclass::DerivativeType DerivativeType;
00114 typedef typename Superclass::ParametersType ParametersType;
00115 typedef typename Superclass::FixedImageType FixedImageType;
00116 typedef typename Superclass::MovingImageType MovingImageType;
00117 typedef typename Superclass::FixedImageConstPointer FixedImageConstPointer;
00118 typedef typename Superclass::MovingImageConstPointer MovingImageCosntPointer;
00119
00121 typedef typename FixedImageType::IndexType FixedImageIndexType;
00122 typedef typename FixedImageIndexType::IndexValueType FixedImageIndexValueType;
00123 typedef typename MovingImageType::IndexType MovingImageIndexType;
00124 typedef typename TransformType::InputPointType FixedImagePointType;
00125 typedef typename TransformType::OutputPointType MovingImagePointType;
00126
00128 itkStaticConstMacro(MovingImageDimension, unsigned int,
00129 MovingImageType::ImageDimension);
00130
00132 void GetDerivative(
00133 const ParametersType& parameters,
00134 DerivativeType & Derivative ) const;
00135
00137 MeasureType GetValue( const ParametersType& parameters ) const;
00138
00140 void GetValueAndDerivative( const ParametersType& parameters,
00141 MeasureType& Value, DerivativeType& Derivative ) const;
00142
00147 void SetNumberOfSpatialSamples( unsigned int num );
00148
00150 itkGetConstReferenceMacro( NumberOfSpatialSamples, unsigned int );
00151
00157 itkSetClampMacro( MovingImageStandardDeviation, double,
00158 NumericTraits<double>::NonpositiveMin(), NumericTraits<double>::max() );
00159 itkGetConstReferenceMacro( MovingImageStandardDeviation, double );
00161
00167 itkSetClampMacro( FixedImageStandardDeviation, double,
00168 NumericTraits<double>::NonpositiveMin(), NumericTraits<double>::max() );
00169 itkGetMacro( FixedImageStandardDeviation, double );
00171
00174 itkSetObjectMacro( KernelFunction, KernelFunction );
00175 itkGetObjectMacro( KernelFunction, KernelFunction );
00177
00178 void ReinitializeSeed();
00179 void ReinitializeSeed(int);
00180
00181 protected:
00182 MutualInformationImageToImageMetric();
00183 virtual ~MutualInformationImageToImageMetric() {};
00184 void PrintSelf(std::ostream& os, Indent indent) const;
00185
00186 private:
00187 MutualInformationImageToImageMetric(const Self&);
00188 void operator=(const Self&);
00189
00192 class SpatialSample
00193 {
00194 public:
00195 SpatialSample():FixedImageValue(0.0),MovingImageValue(0.0)
00196 { FixedImagePointValue.Fill( 0.0 ); }
00197 ~SpatialSample(){};
00199
00200 FixedImagePointType FixedImagePointValue;
00201 double FixedImageValue;
00202 double MovingImageValue;
00203 };
00204
00206 typedef std::vector<SpatialSample> SpatialSampleContainer;
00207
00210 mutable SpatialSampleContainer m_SampleA;
00211
00214 mutable SpatialSampleContainer m_SampleB;
00215
00216 unsigned int m_NumberOfSpatialSamples;
00217 double m_MovingImageStandardDeviation;
00218 double m_FixedImageStandardDeviation;
00219 typename KernelFunction::Pointer m_KernelFunction;
00220 double m_MinProbability;
00221
00223 void SampleFixedImageDomain( SpatialSampleContainer& samples ) const;
00224
00228 void CalculateDerivatives( const FixedImagePointType& , DerivativeType& ) const;
00229
00230 typedef typename Superclass::CoordinateRepresentationType
00231 CoordinateRepresentationType;
00232 typedef CentralDifferenceImageFunction< MovingImageType,
00233 CoordinateRepresentationType > DerivativeFunctionType;
00234
00235 typename DerivativeFunctionType::Pointer m_DerivativeCalculator;
00236
00237 bool m_ReseedIterator;
00238 int m_RandomSeed;
00239
00240
00241 };
00242
00243 }
00244
00245 #ifndef ITK_MANUAL_INSTANTIATION
00246 #include "itkMutualInformationImageToImageMetric.txx"
00247 #endif
00248
00249 #endif
00250
00251