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

itkMutualInformationImageToImageMetric.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkMutualInformationImageToImageMetric.h,v $
00005   Language:  C++
00006   Date:      $Date: 2005/10/03 15:18:45 $
00007   Version:   $Revision: 1.39 $
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 __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 );
00160 
00166   itkSetClampMacro( FixedImageStandardDeviation, double,
00167                     NumericTraits<double>::NonpositiveMin(), NumericTraits<double>::max() );
00168   itkGetMacro( FixedImageStandardDeviation, double );
00169 
00172   itkSetObjectMacro( KernelFunction, KernelFunction );
00173   itkGetObjectMacro( KernelFunction, KernelFunction );
00174 
00175   void ReinitializeSeed();
00176   void ReinitializeSeed(int);
00177 
00178 protected:
00179   MutualInformationImageToImageMetric();
00180   virtual ~MutualInformationImageToImageMetric() {};
00181   void PrintSelf(std::ostream& os, Indent indent) const;
00182 
00183 private:
00184   MutualInformationImageToImageMetric(const Self&); //purposely not implemented
00185   void operator=(const Self&); //purposely not implemented
00186   
00189   class SpatialSample
00190   {
00191   public:
00192     SpatialSample():FixedImageValue(0.0),MovingImageValue(0.0)
00193     { FixedImagePointValue.Fill( 0.0 ); }
00194     ~SpatialSample(){};
00195 
00196     FixedImagePointType              FixedImagePointValue;
00197     double                           FixedImageValue;
00198     double                           MovingImageValue;
00199   };
00200 
00202   typedef std::vector<SpatialSample>  SpatialSampleContainer;
00203 
00206   mutable SpatialSampleContainer      m_SampleA;
00207 
00210   mutable SpatialSampleContainer      m_SampleB;
00211 
00212   unsigned int                        m_NumberOfSpatialSamples;
00213   double                              m_MovingImageStandardDeviation;
00214   double                              m_FixedImageStandardDeviation;
00215   typename KernelFunction::Pointer    m_KernelFunction;
00216   double                              m_MinProbability;
00217 
00219   void SampleFixedImageDomain( SpatialSampleContainer& samples ) const;
00220 
00224   void CalculateDerivatives( const FixedImagePointType& , DerivativeType& ) const;
00225 
00226   typedef typename Superclass::CoordinateRepresentationType  
00227   CoordinateRepresentationType;
00228   typedef CentralDifferenceImageFunction< MovingImageType, 
00229                                           CoordinateRepresentationType > DerivativeFunctionType;
00230 
00231   typename DerivativeFunctionType::Pointer  m_DerivativeCalculator;
00232 
00233   bool             m_ReseedIterator;
00234   int              m_RandomSeed;
00235   
00236 
00237 };
00238 
00239 } // end namespace itk
00240 
00241 #ifndef ITK_MANUAL_INSTANTIATION
00242 #include "itkMutualInformationImageToImageMetric.txx"
00243 #endif
00244 
00245 #endif
00246 

Generated at Wed May 24 23:42:29 2006 for ITK by doxygen 1.3.5 written by Dimitri van Heesch, © 1997-2000