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: 2007/11/12 20:00:37 $
00007   Version:   $Revision: 1.25 $
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 __itkImageToImageMetric_h
00018 #define __itkImageToImageMetric_h
00019 
00020 // First make sure that the configuration is available.
00021 // This line can be removed once the optimized versions
00022 // gets integrated into the main directories.
00023 #include "itkConfigure.h"
00024 
00025 #ifdef ITK_USE_OPTIMIZED_REGISTRATION_METHODS
00026 #include "itkOptImageToImageMetric.h"
00027 #else
00028 
00029 #include "itkImageBase.h"
00030 #include "itkTransform.h"
00031 #include "itkInterpolateImageFunction.h"
00032 #include "itkSingleValuedCostFunction.h"
00033 #include "itkExceptionObject.h"
00034 #include "itkGradientRecursiveGaussianImageFilter.h"
00035 #include "itkSpatialObject.h"
00036 
00037 namespace itk
00038 {
00039   
00059 template <class TFixedImage,  class TMovingImage> 
00060 class ITK_EXPORT ImageToImageMetric : public SingleValuedCostFunction 
00061 {
00062 public:
00064   typedef ImageToImageMetric           Self;
00065   typedef SingleValuedCostFunction     Superclass;
00066   typedef SmartPointer<Self>           Pointer;
00067   typedef SmartPointer<const Self>     ConstPointer;
00068 
00070   typedef typename Superclass::ParametersValueType CoordinateRepresentationType;
00071 
00073   itkTypeMacro(ImageToImageMetric, SingleValuedCostFunction);
00074 
00076   typedef TMovingImage                               MovingImageType;
00077   typedef typename TMovingImage::PixelType           MovingImagePixelType;
00078   typedef typename MovingImageType::ConstPointer     MovingImageConstPointer;
00079 
00081   typedef TFixedImage                                FixedImageType;
00082   typedef typename FixedImageType::ConstPointer      FixedImageConstPointer;
00083   typedef typename FixedImageType::RegionType        FixedImageRegionType;
00084 
00086   itkStaticConstMacro(MovingImageDimension, 
00087                       unsigned int,
00088                       TMovingImage::ImageDimension);
00089   itkStaticConstMacro(FixedImageDimension, 
00090                       unsigned int,
00091                       TFixedImage::ImageDimension);
00093 
00095   typedef Transform<CoordinateRepresentationType, 
00096                     itkGetStaticConstMacro(MovingImageDimension),
00097                     itkGetStaticConstMacro(FixedImageDimension)> 
00098                                                      TransformType;
00099 
00100   typedef typename TransformType::Pointer            TransformPointer;
00101   typedef typename TransformType::InputPointType     InputPointType;
00102   typedef typename TransformType::OutputPointType    OutputPointType;
00103   typedef typename TransformType::ParametersType     TransformParametersType;
00104   typedef typename TransformType::JacobianType       TransformJacobianType;
00105 
00107   typedef InterpolateImageFunction<
00108     MovingImageType,
00109     CoordinateRepresentationType > InterpolatorType;
00110 
00111 
00113   typedef typename NumericTraits<MovingImagePixelType>::RealType 
00114                                                      RealType;
00115   typedef CovariantVector<RealType,
00116                           itkGetStaticConstMacro(MovingImageDimension)>
00117                                                      GradientPixelType;
00118   typedef Image<GradientPixelType,
00119                 itkGetStaticConstMacro(MovingImageDimension)> 
00120                                                      GradientImageType;
00121   typedef SmartPointer<GradientImageType>            GradientImagePointer;
00122   typedef GradientRecursiveGaussianImageFilter< MovingImageType,
00123                                                 GradientImageType >
00124                                                      GradientImageFilterType;  
00125   typedef typename GradientImageFilterType::Pointer  GradientImageFilterPointer;
00127 
00128 
00129   typedef typename InterpolatorType::Pointer         InterpolatorPointer;
00130 
00131 
00134   typedef SpatialObject< itkGetStaticConstMacro(FixedImageDimension) >
00135                                                      FixedImageMaskType;
00136   typedef typename  FixedImageMaskType::Pointer      FixedImageMaskPointer;
00137 
00140   typedef SpatialObject< itkGetStaticConstMacro(MovingImageDimension) >
00141                                                      MovingImageMaskType;
00142   typedef typename  MovingImageMaskType::Pointer     MovingImageMaskPointer;
00143 
00144 
00146   typedef typename Superclass::MeasureType                    MeasureType;
00147 
00149   typedef typename Superclass::DerivativeType                 DerivativeType;
00150 
00152   typedef typename Superclass::ParametersType                 ParametersType;
00153 
00155   itkSetConstObjectMacro( FixedImage, FixedImageType );
00156 
00158   itkGetConstObjectMacro( FixedImage, FixedImageType );
00159 
00161   itkSetConstObjectMacro( MovingImage, MovingImageType );
00162 
00164   itkGetConstObjectMacro( MovingImage, MovingImageType );
00165 
00167   itkSetObjectMacro( Transform, TransformType );
00168 
00170   itkGetConstObjectMacro( Transform, TransformType );
00171 
00173   itkSetObjectMacro( Interpolator, InterpolatorType );
00174 
00176   itkGetConstObjectMacro( Interpolator, InterpolatorType );
00177 
00179   itkGetConstReferenceMacro( NumberOfPixelsCounted, unsigned long );
00180 
00182   itkSetMacro( FixedImageRegion, FixedImageRegionType );
00183 
00185   itkGetConstReferenceMacro( FixedImageRegion, FixedImageRegionType );
00186 
00188   itkSetObjectMacro( MovingImageMask, MovingImageMaskType );
00189   itkGetConstObjectMacro( MovingImageMask, MovingImageMaskType );
00191 
00193   itkSetObjectMacro( FixedImageMask, FixedImageMaskType );
00194   itkGetConstObjectMacro( FixedImageMask, FixedImageMaskType );
00196 
00198   itkSetMacro( ComputeGradient, bool);
00199   itkGetConstReferenceMacro( ComputeGradient, bool);
00200   itkBooleanMacro(ComputeGradient);
00202 
00204   virtual void ComputeGradient();
00205 
00207   itkGetConstObjectMacro( GradientImage, GradientImageType );
00208 
00210   void SetTransformParameters( const ParametersType & parameters ) const;
00211 
00213   unsigned int GetNumberOfParameters(void) const 
00214     { return m_Transform->GetNumberOfParameters(); }
00215 
00218   virtual void Initialize(void) throw ( ExceptionObject );
00219 
00220 protected:
00221   ImageToImageMetric();
00222   virtual ~ImageToImageMetric();
00223   void PrintSelf(std::ostream& os, Indent indent) const;
00224 
00225   mutable unsigned long       m_NumberOfPixelsCounted;
00226 
00227   FixedImageConstPointer      m_FixedImage;
00228   MovingImageConstPointer     m_MovingImage;
00229 
00230   mutable TransformPointer    m_Transform;
00231   InterpolatorPointer         m_Interpolator;
00232 
00233   bool                        m_ComputeGradient;
00234   GradientImagePointer        m_GradientImage;
00235 
00236   mutable FixedImageMaskPointer   m_FixedImageMask;
00237   mutable MovingImageMaskPointer  m_MovingImageMask;
00238 
00239 private:
00240   ImageToImageMetric(const Self&); //purposely not implemented
00241   void operator=(const Self&); //purposely not implemented
00242   
00243   FixedImageRegionType        m_FixedImageRegion;  
00244 
00245 };
00246 
00247 } // end namespace itk
00248 
00249 #ifndef ITK_MANUAL_INSTANTIATION
00250 #include "itkImageToImageMetric.txx"
00251 #endif
00252 
00253 #endif
00254 
00255 #endif
00256 

Generated at Wed Nov 5 22:19:43 2008 for ITK by doxygen 1.5.1 written by Dimitri van Heesch, © 1997-2000