Main Page   Groups   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Concepts

itkOptMattesMutualInformationImageToImageMetric.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkOptMattesMutualInformationImageToImageMetric.h,v $
00005   Language:  C++
00006   Date:      $Date: 2009-11-02 15:37:04 $
00007   Version:   $Revision: 1.9 $
00008 
00009   Copyright (c) Insight Software Consortium. All rights reserved.
00010   See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
00011 
00012      This software is distributed WITHOUT ANY WARRANTY; without even 
00013      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
00014      PURPOSE.  See the above copyright notices for more information.
00015 
00016 =========================================================================*/
00017 #ifndef __itkOptMattesMutualInformationImageToImageMetric_h
00018 #define __itkOptMattesMutualInformationImageToImageMetric_h
00019 
00020 #include "itkOptImageToImageMetric.h"
00021 #include "itkCovariantVector.h"
00022 #include "itkPoint.h"
00023 #include "itkIndex.h"
00024 #include "itkBSplineKernelFunction.h"
00025 #include "itkBSplineDerivativeKernelFunction.h"
00026 #include "itkCentralDifferenceImageFunction.h"
00027 #include "itkBSplineInterpolateImageFunction.h"
00028 #include "itkBSplineDeformableTransform.h"
00029 #include "itkArray2D.h"
00030 
00031 #include "itkMultiThreader.h"
00032 
00033 namespace itk
00034 {
00035 
00116 template <class TFixedImage,class TMovingImage >
00117 class ITK_EXPORT MattesMutualInformationImageToImageMetric :
00118     public ImageToImageMetric< TFixedImage, TMovingImage >
00119 {
00120 public:
00121 
00123   typedef MattesMutualInformationImageToImageMetric           Self;
00124   typedef ImageToImageMetric< TFixedImage, TMovingImage >     Superclass;
00125   typedef SmartPointer<Self>                                  Pointer;
00126   typedef SmartPointer<const Self>                            ConstPointer;
00127 
00129   itkNewMacro(Self);
00130 
00132   itkTypeMacro(MattesMutualInformationImageToImageMetric,
00133                ImageToImageMetric);
00134 
00136   typedef typename Superclass::TransformType            TransformType;
00137   typedef typename Superclass::TransformPointer         TransformPointer;
00138   typedef typename Superclass::TransformJacobianType    TransformJacobianType;
00139   typedef typename Superclass::InterpolatorType         InterpolatorType;
00140   typedef typename Superclass::MeasureType              MeasureType;
00141   typedef typename Superclass::DerivativeType           DerivativeType;
00142   typedef typename Superclass::ParametersType           ParametersType;
00143   typedef typename Superclass::FixedImageType           FixedImageType;
00144   typedef typename Superclass::MovingImageType          MovingImageType;
00145   typedef typename Superclass::MovingImagePointType     MovingImagePointType;
00146   typedef typename Superclass::FixedImageConstPointer   FixedImageConstPointer;
00147   typedef typename Superclass::MovingImageConstPointer  MovingImageConstPointer;
00148   typedef typename Superclass::BSplineTransformWeightsType
00149                                                         BSplineTransformWeightsType;
00150   typedef typename Superclass::BSplineTransformIndexArrayType
00151                                                         BSplineTransformIndexArrayType;
00152 
00153   typedef typename Superclass::CoordinateRepresentationType
00154                                                    CoordinateRepresentationType;
00155   typedef typename Superclass::FixedImageSampleContainer   
00156                                                       FixedImageSampleContainer;
00157   typedef typename Superclass::ImageDerivativesType     ImageDerivativesType;
00158   typedef typename Superclass::WeightsValueType         WeightsValueType;
00159   typedef typename Superclass::IndexValueType           IndexValueType;
00160 
00161   typedef typename FixedImageType::OffsetValueType      OffsetValueType;
00162 
00164   itkStaticConstMacro( MovingImageDimension, unsigned int,
00165                        MovingImageType::ImageDimension );
00166 
00174   virtual void Initialize(void) throw ( ExceptionObject );
00175 
00177   MeasureType GetValue( const ParametersType & parameters ) const;
00178 
00180   void GetDerivative( const ParametersType & parameters,
00181                       DerivativeType & Derivative ) const;
00182 
00184   void GetValueAndDerivative( const ParametersType & parameters, 
00185                               MeasureType & Value,
00186                               DerivativeType & Derivative ) const;
00187 
00193   itkSetClampMacro( NumberOfHistogramBins, unsigned long,
00194                     5, NumericTraits<unsigned long>::max() );
00195   itkGetConstReferenceMacro( NumberOfHistogramBins, unsigned long);   
00197 
00222   itkSetMacro(UseExplicitPDFDerivatives,bool);
00223   itkGetConstReferenceMacro(UseExplicitPDFDerivatives,bool);
00224   itkBooleanMacro(UseExplicitPDFDerivatives);
00226 
00227 protected:
00228 
00229   MattesMutualInformationImageToImageMetric();
00230   virtual ~MattesMutualInformationImageToImageMetric();
00231   void PrintSelf(std::ostream& os, Indent indent) const;
00232 
00233 private:
00234 
00235   //purposely not implemented
00236   MattesMutualInformationImageToImageMetric(const Self &); 
00237   //purposely not implemented
00238   void operator=(const Self &); 
00239 
00240 
00242   typedef float                       PDFValueType;
00243   typedef float *                     MarginalPDFType;
00244 
00245   mutable MarginalPDFType             m_FixedImageMarginalPDF;
00246 
00248   mutable MarginalPDFType             m_MovingImageMarginalPDF;
00249 
00251   typedef double                      PRatioType;
00252   typedef Array2D< PRatioType >       PRatioArrayType;
00253   mutable PRatioArrayType             m_PRatioArray;
00254 
00256   mutable DerivativeType              m_MetricDerivative;
00257   mutable DerivativeType            * m_ThreaderMetricDerivative;
00258 
00260   typedef Image<PDFValueType,2>                 JointPDFType;
00261   typedef Image<PDFValueType,3>                 JointPDFDerivativesType;
00262   typedef JointPDFType::IndexType               JointPDFIndexType;
00263   typedef JointPDFType::PixelType               JointPDFValueType;
00264   typedef JointPDFType::RegionType              JointPDFRegionType;
00265   typedef JointPDFType::SizeType                JointPDFSizeType;
00266   typedef JointPDFDerivativesType::IndexType    JointPDFDerivativesIndexType;
00267   typedef JointPDFDerivativesType::PixelType    JointPDFDerivativesValueType;
00268   typedef JointPDFDerivativesType::RegionType   JointPDFDerivativesRegionType;
00269   typedef JointPDFDerivativesType::SizeType     JointPDFDerivativesSizeType;
00270 
00272   typename JointPDFType::Pointer                m_JointPDF;
00273   unsigned long                                 m_JointPDFBufferSize;
00274   typename JointPDFDerivativesType::Pointer     m_JointPDFDerivatives;
00275   unsigned long                                 m_JointPDFDerivativesBufferSize;
00276 
00278   unsigned long  m_NumberOfHistogramBins;
00279   double         m_MovingImageNormalizedMin;
00280   double         m_FixedImageNormalizedMin;
00281   double         m_FixedImageTrueMin;
00282   double         m_FixedImageTrueMax;
00283   double         m_MovingImageTrueMin;
00284   double         m_MovingImageTrueMax;
00285   double         m_FixedImageBinSize;
00286   double         m_MovingImageBinSize;
00287 
00289   typedef BSplineKernelFunction<3>           CubicBSplineFunctionType;
00290   typedef BSplineDerivativeKernelFunction<3> CubicBSplineDerivativeFunctionType;
00291 
00293   typename CubicBSplineFunctionType::Pointer   m_CubicBSplineKernel;
00294   typename CubicBSplineDerivativeFunctionType::Pointer   
00295                                                m_CubicBSplineDerivativeKernel;
00296 
00298   virtual void ComputeFixedImageParzenWindowIndices( 
00299                                          FixedImageSampleContainer & samples );
00300 
00302   virtual void ComputePDFDerivatives( unsigned int threadID,
00303                                       unsigned int sampleNumber,
00304                                       int movingImageParzenWindowIndex,
00305                                       const ImageDerivativesType
00306                                               &  movingImageGradientValue,
00307                                       double cubicBSplineDerivativeValue 
00308                                       ) const;
00309 
00310   PDFValueType                                * m_ThreaderFixedImageMarginalPDF;
00311   typename JointPDFType::Pointer              * m_ThreaderJointPDF;
00312   typename JointPDFDerivativesType::Pointer   * m_ThreaderJointPDFDerivatives;
00313   int                                         * m_ThreaderJointPDFStartBin;
00314   int                                         * m_ThreaderJointPDFEndBin;
00315   mutable double                              * m_ThreaderJointPDFSum;
00316   mutable double                                m_JointPDFSum;
00317 
00318   bool                                          m_UseExplicitPDFDerivatives;
00319   mutable bool                                  m_ImplicitDerivativesSecondPass;
00320 
00321 
00322   virtual inline void GetValueThreadPreProcess( unsigned int threadID,
00323                                         bool withinSampleThread ) const;
00324   virtual inline bool GetValueThreadProcessSample( unsigned int threadID,
00325                                        unsigned long fixedImageSample,
00326                                        const MovingImagePointType & mappedPoint,
00327                                        double movingImageValue ) const;
00328   virtual inline void GetValueThreadPostProcess( unsigned int threadID,
00329                                         bool withinSampleThread ) const;
00330 
00331   virtual inline void GetValueAndDerivativeThreadPreProcess( 
00332                                        unsigned int threadID,
00333                                        bool withinSampleThread ) const;
00334   virtual inline bool GetValueAndDerivativeThreadProcessSample( unsigned int threadID,
00335                                        unsigned long fixedImageSample,
00336                                        const MovingImagePointType & mappedPoint,
00337                                        double movingImageValue,
00338                                        const ImageDerivativesType &
00339                                                movingImageGradientValue ) const;
00340   virtual inline void GetValueAndDerivativeThreadPostProcess( 
00341                                        unsigned int threadID,
00342                                        bool withinSampleThread ) const;
00343 
00344 };
00345 
00346 } // end namespace itk
00347 
00348 #ifndef ITK_MANUAL_INSTANTIATION
00349 #include "itkOptMattesMutualInformationImageToImageMetric.txx"
00350 #endif
00351 
00352 #endif
00353 

Generated at Fri Apr 16 19:13:21 2010 for ITK by doxygen 1.6.1 written by Dimitri van Heesch, © 1997-2000