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: 2006/08/02 11:56:03 $
00007   Version:   $Revision: 1.40 $
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 );
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 
00187   void ReinitializeSeed();
00188   void ReinitializeSeed(int);
00190 
00191 protected:
00192   MutualInformationImageToImageMetric();
00193   virtual ~MutualInformationImageToImageMetric() {};
00194   void PrintSelf(std::ostream& os, Indent indent) const;
00195 
00196 private:
00197   MutualInformationImageToImageMetric(const Self&); //purposely not implemented
00198   void operator=(const Self&); //purposely not implemented
00199   
00202   class SpatialSample
00203   {
00204   public:
00205     SpatialSample():FixedImageValue(0.0),MovingImageValue(0.0)
00206     { FixedImagePointValue.Fill( 0.0 ); }
00207     ~SpatialSample(){};
00209 
00210     FixedImagePointType              FixedImagePointValue;
00211     double                           FixedImageValue;
00212     double                           MovingImageValue;
00213   };
00214 
00216   typedef std::vector<SpatialSample>  SpatialSampleContainer;
00217 
00220   mutable SpatialSampleContainer      m_SampleA;
00221 
00224   mutable SpatialSampleContainer      m_SampleB;
00225 
00226   unsigned int                        m_NumberOfSpatialSamples;
00227   double                              m_MovingImageStandardDeviation;
00228   double                              m_FixedImageStandardDeviation;
00229   typename KernelFunction::Pointer    m_KernelFunction;
00230   double                              m_MinProbability;
00231 
00233   void SampleFixedImageDomain( SpatialSampleContainer& samples ) const;
00234 
00238   void CalculateDerivatives( const FixedImagePointType& , DerivativeType& ) const;
00239 
00240   typedef typename Superclass::CoordinateRepresentationType  
00241   CoordinateRepresentationType;
00242   typedef CentralDifferenceImageFunction< MovingImageType, 
00243                                           CoordinateRepresentationType > DerivativeFunctionType;
00244 
00245   typename DerivativeFunctionType::Pointer  m_DerivativeCalculator;
00246 
00247   bool             m_ReseedIterator;
00248   int              m_RandomSeed;
00249   
00250 
00251 };
00252 
00253 } // end namespace itk
00254 
00255 #ifndef ITK_MANUAL_INSTANTIATION
00256 #include "itkMutualInformationImageToImageMetric.txx"
00257 #endif
00258 
00259 #endif
00260 
00261 

Generated at Sun Sep 23 13:37:30 2007 for ITK by doxygen 1.5.1 written by Dimitri van Heesch, © 1997-2000