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

itkImageToImageMetric.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkImageToImageMetric.h,v $
00005   Language:  C++
00006   Date:      $Date: 2002/09/11 19:39:01 $
00007   Version:   $Revision: 1.14 $
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 __itkImageToImageMetric_h
00018 #define __itkImageToImageMetric_h
00019 
00020 #include "itkImageBase.h"
00021 #include "itkTransform.h"
00022 #include "itkInterpolateImageFunction.h"
00023 #include "itkSingleValuedCostFunction.h"
00024 #include "itkExceptionObject.h"
00025 #include "itkGradientRecursiveGaussianImageFilter.h"
00026 
00027 namespace itk
00028 {
00029   
00049 template <class TFixedImage,  class TMovingImage> 
00050 class ITK_EXPORT ImageToImageMetric : public SingleValuedCostFunction 
00051 {
00052 public:
00054   typedef ImageToImageMetric              Self;
00055   typedef SingleValuedCostFunction        Superclass;
00056   typedef SmartPointer<Self>              Pointer;
00057   typedef SmartPointer<const Self>        ConstPointer;
00058 
00060   typedef Superclass::ParametersValueType CoordinateRepresentationType;
00061 
00063   itkTypeMacro(ImageToImageMetric, SingleValuedCostFunction);
00064 
00066   typedef TMovingImage                               MovingImageType;
00067   typedef typename TMovingImage::PixelType           MovingImagePixelType;
00068   typedef typename MovingImageType::ConstPointer     MovingImageConstPointer;
00069 
00071   typedef TFixedImage                                FixedImageType;
00072   typedef typename FixedImageType::ConstPointer      FixedImageConstPointer;
00073   typedef typename FixedImageType::RegionType        FixedImageRegionType;
00074 
00076   itkStaticConstMacro(MovingImageDimension, unsigned int,
00077                       TMovingImage::ImageDimension);
00078   itkStaticConstMacro(FixedImageDimension, unsigned int,
00079                       TFixedImage::ImageDimension);
00080   
00082   typedef Transform<CoordinateRepresentationType, 
00083                     itkGetStaticConstMacro(MovingImageDimension),
00084                     itkGetStaticConstMacro(FixedImageDimension)> TransformType;
00085 
00086   typedef typename TransformType::Pointer            TransformPointer;
00087   typedef typename TransformType::InputPointType     InputPointType;
00088   typedef typename TransformType::OutputPointType    OutputPointType;
00089   typedef typename TransformType::ParametersType     TransformParametersType;
00090   typedef typename TransformType::JacobianType       TransformJacobianType;
00091 
00093   typedef InterpolateImageFunction<
00094                       MovingImageType,
00095                       CoordinateRepresentationType > InterpolatorType;
00096 
00097 
00099   typedef typename NumericTraits<MovingImagePixelType>::RealType RealType;
00100   typedef CovariantVector<RealType,
00101           itkGetStaticConstMacro(MovingImageDimension)> GradientPixelType;
00102   typedef Image<GradientPixelType,
00103                itkGetStaticConstMacro(MovingImageDimension)> GradientImageType;
00104   typedef SmartPointer<GradientImageType>     GradientImagePointer;
00105   typedef GradientRecursiveGaussianImageFilter< MovingImageType,
00106                                                 GradientImageType >
00107           GradientImageFilterType;  
00108   typedef typename GradientImageFilterType::Pointer GradientImageFilterPointer;
00109 
00110 
00111   typedef typename InterpolatorType::Pointer         InterpolatorPointer;
00112 
00114   typedef Superclass::MeasureType                    MeasureType;
00115 
00117   typedef Superclass::DerivativeType                 DerivativeType;
00118 
00120   typedef Superclass::ParametersType                 ParametersType;
00121 
00123   itkSetConstObjectMacro( FixedImage, FixedImageType );
00124 
00126   itkGetConstObjectMacro( FixedImage, FixedImageType );
00127 
00129   itkSetConstObjectMacro( MovingImage, MovingImageType );
00130 
00132   itkGetConstObjectMacro( MovingImage, MovingImageType );
00133 
00135   itkSetObjectMacro( Transform, TransformType );
00136 
00138   itkGetObjectMacro( Transform, TransformType );
00139  
00141   itkSetObjectMacro( Interpolator, InterpolatorType );
00142 
00144   itkGetObjectMacro( Interpolator, InterpolatorType );
00145 
00147   itkGetConstMacro( NumberOfPixelsCounted, unsigned long );
00148 
00150   itkSetMacro( FixedImageRegion, FixedImageRegionType );
00151 
00153   itkGetConstMacro( FixedImageRegion, FixedImageRegionType );
00154 
00156   void SetTransformParameters( const ParametersType & parameters ) const;
00157 
00159   unsigned int GetNumberOfParameters(void) const 
00160     { return m_Transform->GetNumberOfParameters(); }
00161 
00164   virtual void Initialize(void) throw ( ExceptionObject );
00165 
00168   itkSetMacro( ScaleGradient, RealType );
00169   itkGetMacro( ScaleGradient, RealType );
00170 
00171 protected:
00172   ImageToImageMetric();
00173   virtual ~ImageToImageMetric() {};
00174   void PrintSelf(std::ostream& os, Indent indent) const;
00175 
00176   mutable unsigned long       m_NumberOfPixelsCounted;
00177 
00178   FixedImageConstPointer      m_FixedImage;
00179   MovingImageConstPointer     m_MovingImage;
00180 
00181   mutable TransformPointer    m_Transform;
00182   InterpolatorPointer         m_Interpolator;
00183 
00184   bool                        m_ComputeGradient;
00185   GradientImagePointer        m_GradientImage;
00186 
00187 private:
00188   ImageToImageMetric(const Self&); //purposely not implemented
00189   void operator=(const Self&); //purposely not implemented
00190   
00191   FixedImageRegionType        m_FixedImageRegion;  
00192 
00193 
00194   // This is the Sigma value to be used by the Gradient Filter
00195   RealType                    m_ScaleGradient;
00196 };
00197 
00198 } // end namespace itk
00199 
00200 #ifndef ITK_MANUAL_INSTANTIATION
00201 #include "itkImageToImageMetric.txx"
00202 #endif
00203 
00204 #endif
00205 
00206 
00207 

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