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: 2003/01/04 04:40:38 $
00007   Version:   $Revision: 1.33 $
00008 
00009   Copyright (c) 2002 Insight 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   itkGetConstMacro( NumberOfSpatialSamples, unsigned int );
00151 
00157   itkSetClampMacro( MovingImageStandardDeviation, double, 
00158     NumericTraits<double>::NonpositiveMin(), NumericTraits<double>::max() );
00159   itkGetConstMacro( 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 protected:
00176   MutualInformationImageToImageMetric();
00177   virtual ~MutualInformationImageToImageMetric() {};
00178   void PrintSelf(std::ostream& os, Indent indent) const;
00179 
00180 private:
00181   MutualInformationImageToImageMetric(const Self&); //purposely not implemented
00182   void operator=(const Self&); //purposely not implemented
00183   
00186   class SpatialSample
00187   {
00188   public:
00189     SpatialSample():FixedImageValue(0.0),MovingImageValue(0.0)
00190       { FixedImagePointValue.Fill( 0.0 ); }
00191     ~SpatialSample(){};
00192 
00193     FixedImagePointType              FixedImagePointValue;
00194     double                           FixedImageValue;
00195     double                           MovingImageValue;
00196   };
00197 
00199   typedef std::vector<SpatialSample>  SpatialSampleContainer;
00200 
00203   mutable SpatialSampleContainer      m_SampleA;
00204 
00207   mutable SpatialSampleContainer      m_SampleB;
00208 
00209   unsigned int                        m_NumberOfSpatialSamples;
00210   double                              m_MovingImageStandardDeviation;
00211   double                              m_FixedImageStandardDeviation;
00212   typename KernelFunction::Pointer    m_KernelFunction;
00213   double                              m_MinProbability;
00214 
00216   void SampleFixedImageDomain( SpatialSampleContainer& samples ) const;
00217 
00221   void CalculateDerivatives( const FixedImagePointType& , DerivativeType& ) const;
00222 
00224   static void ReinitializeSeed();
00225 
00226   typedef typename Superclass::CoordinateRepresentationType  
00227     CoordinateRepresentationType;
00228   typedef CentralDifferenceImageFunction< MovingImageType, 
00229     CoordinateRepresentationType > DerivativeFunctionType;
00230 
00231   typename DerivativeFunctionType::Pointer  m_DerivativeCalculator;
00232 
00233 };
00234 
00235 } // end namespace itk
00236 
00237 #ifndef ITK_MANUAL_INSTANTIATION
00238 #include "itkMutualInformationImageToImageMetric.txx"
00239 #endif
00240 
00241 #endif
00242 

Generated at Fri May 21 01:15:06 2004 for ITK by doxygen 1.2.15 written by Dimitri van Heesch, © 1997-2000