go home Home | Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Namespace Members | Data Fields | Globals | Related Pages
itkNormalizedGradientCorrelationImageToImageMetric.h
Go to the documentation of this file.
00001 /*======================================================================
00002 
00003   This file is part of the elastix software.
00004 
00005   Copyright (c) University Medical Center Utrecht. All rights reserved.
00006   See src/CopyrightElastix.txt or http://elastix.isi.uu.nl/legal.php for
00007   details.
00008 
00009      This software is distributed WITHOUT ANY WARRANTY; without even
00010      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00011      PURPOSE. See the above copyright notices for more information.
00012 
00013 ======================================================================*/
00014 #ifndef __itkNormalizedGradientCorrelationImageToImageMetric_h
00015 #define __itkNormalizedGradientCorrelationImageToImageMetric_h
00016 
00017 #include "itkAdvancedImageToImageMetric.h"
00018 #include "itkSobelOperator.h"
00019 #include "itkNeighborhoodOperatorImageFilter.h"
00020 #include "itkPoint.h"
00021 #include "itkCastImageFilter.h"
00022 #include "itkResampleImageFilter.h"
00023 #include "itkOptimizer.h"
00024 #include "itkAdvancedCombinationTransform.h"
00025 #include "itkAdvancedRayCastInterpolateImageFunction.h"
00026 
00027 namespace itk
00028 {
00029 
00039 template < class TFixedImage, class TMovingImage >
00040 class ITK_EXPORT NormalizedGradientCorrelationImageToImageMetric :
00041   public AdvancedImageToImageMetric< TFixedImage, TMovingImage>
00042 {
00043 public:
00044 
00046   typedef NormalizedGradientCorrelationImageToImageMetric         Self;
00047   typedef AdvancedImageToImageMetric<TFixedImage, TMovingImage >  Superclass;
00048   typedef SmartPointer<Self>                                      Pointer;
00049   typedef SmartPointer<const Self>                                ConstPointer;
00050 
00052   itkNewMacro( Self );
00053 
00055   itkTypeMacro( NormalizedGradientCorrelationImageToImageMetric, AdvancedImageToImageMetric );
00056 
00059   #if defined(_MSC_VER) && (_MSC_VER == 1300)
00060     typedef double RealType;
00061   #else
00062     typedef typename Superclass::RealType                 RealType;
00063   #endif
00064 
00065   typedef typename Superclass::TransformType            TransformType;
00066   typedef typename TransformType::ScalarType            ScalarType;
00067   typedef typename Superclass::TransformPointer         TransformPointer;
00068   typedef typename TransformType::ConstPointer          TransformConstPointer;
00069   typedef typename Superclass::TransformParametersType  TransformParametersType;
00070   typedef typename Superclass::TransformJacobianType    TransformJacobianType;
00071   typedef typename Superclass::InterpolatorType         InterpolatorType;
00072   typedef typename InterpolatorType::Pointer            InterpolatorPointer;
00073   typedef typename Superclass::MeasureType              MeasureType;
00074   typedef typename Superclass::DerivativeType           DerivativeType;
00075   typedef typename Superclass::FixedImageType           FixedImageType;
00076   typedef typename Superclass::FixedImageRegionType     FixedImageRegionType;
00077   typedef typename Superclass::MovingImageType          MovingImageType;
00078   typedef typename Superclass::MovingImageRegionType    MovingImageRegionType;
00079   typedef typename Superclass::FixedImageConstPointer   FixedImageConstPointer;
00080   typedef typename Superclass::MovingImageConstPointer  MovingImageConstPointer;
00081   typedef typename Superclass::MovingImagePointer       MovingImagePointer;
00082   typedef typename TFixedImage::PixelType               FixedImagePixelType;
00083   typedef typename TMovingImage::PixelType              MovedImagePixelType;
00084   typedef typename itk::Optimizer                       OptimizerType;
00085   typedef typename OptimizerType::ScalesType            ScalesType;
00086 
00087   itkStaticConstMacro( FixedImageDimension, unsigned int, TFixedImage::ImageDimension );
00088 
00090   typedef typename itk::AdvancedCombinationTransform<
00091     ScalarType, FixedImageDimension>                    CombinationTransformType;
00092   typedef typename CombinationTransformType::Pointer    CombinationTransformPointer;
00093   typedef itk::Image< FixedImagePixelType,
00094       itkGetStaticConstMacro( FixedImageDimension ) >   TransformedMovingImageType;
00095   typedef itk::Image< unsigned char,
00096       itkGetStaticConstMacro( FixedImageDimension ) >   MaskImageType;
00097   typedef typename MaskImageType::Pointer               MaskImageTypePointer;
00098   typedef itk::ResampleImageFilter<
00099     MovingImageType, TransformedMovingImageType >       TransformMovingImageFilterType;
00100   typedef typename TransformMovingImageFilterType::Pointer TransformMovingImageFilterPointer;
00101   typedef typename itk::AdvancedRayCastInterpolateImageFunction
00102     < MovingImageType, ScalarType >                     RayCastInterpolatorType;
00103   typedef typename RayCastInterpolatorType::Pointer     RayCastInterpolatorPointer;
00104 
00106   typedef itk::Image< RealType,
00107     itkGetStaticConstMacro( FixedImageDimension ) >       FixedGradientImageType;
00108   typedef itk::CastImageFilter< FixedImageType,
00109     FixedGradientImageType >                              CastFixedImageFilterType;
00110   typedef typename CastFixedImageFilterType::Pointer      CastFixedImageFilterPointer;
00111   typedef typename FixedGradientImageType::PixelType      FixedGradientPixelType;
00112 
00114   itkStaticConstMacro( MovedImageDimension, unsigned int, MovingImageType::ImageDimension );
00115   typedef itk::Image< RealType,
00116     itkGetStaticConstMacro( MovedImageDimension ) >       MovedGradientImageType;
00117   typedef itk::CastImageFilter< TransformedMovingImageType,
00118     MovedGradientImageType >                              CastMovedImageFilterType;
00119   typedef typename CastMovedImageFilterType::Pointer      CastMovedImageFilterPointer;
00120   typedef typename MovedGradientImageType::PixelType      MovedGradientPixelType;
00121 
00123   virtual void GetDerivative( const TransformParametersType & parameters,
00124     DerivativeType  & derivative ) const;
00125 
00127   virtual MeasureType GetValue( const TransformParametersType & parameters ) const;
00128 
00130   virtual void GetValueAndDerivative( const TransformParametersType & parameters,
00131     MeasureType& Value, DerivativeType& derivative ) const;
00132 
00136   virtual void Initialize( void ) throw ( ExceptionObject );
00137 
00139   void WriteGradientImagesToFiles( void ) const;
00140 
00142   itkSetMacro( Scales , ScalesType );
00143   itkGetConstReferenceMacro( Scales, ScalesType );
00144 
00148   itkSetMacro( DerivativeDelta, double );
00149   itkGetConstReferenceMacro( DerivativeDelta, double );
00150 
00152   void SetTransformParameters( const TransformParametersType & parameters ) const;
00153 
00154   protected:
00155   NormalizedGradientCorrelationImageToImageMetric();
00156   virtual ~NormalizedGradientCorrelationImageToImageMetric() {};
00157   virtual void PrintSelf( std::ostream& os, Indent indent ) const;
00158 
00160   void ComputeMeanMovedGradient( void ) const;
00161   void ComputeMeanFixedGradient( void ) const;
00162 
00164   MeasureType ComputeMeasure( const TransformParametersType & parameters ) const;
00165   typedef NeighborhoodOperatorImageFilter<
00166       FixedGradientImageType, FixedGradientImageType >        FixedSobelFilter;
00167   typedef NeighborhoodOperatorImageFilter<
00168       MovedGradientImageType, MovedGradientImageType >        MovedSobelFilter;
00169 
00170 private:
00171   NormalizedGradientCorrelationImageToImageMetric(const Self&); //purposely not implemented
00172   void operator=(const Self&); //purposely not implemented
00173 
00174   ScalesType                    m_Scales;
00175   double                        m_DerivativeDelta;
00176   CombinationTransformPointer   m_CombinationTransform;
00177 
00179   mutable MovedGradientPixelType m_MeanMovedGradient[ MovedImageDimension ];
00180 
00182   mutable FixedGradientPixelType m_MeanFixedGradient[ FixedImageDimension ];
00183 
00185   TransformMovingImageFilterPointer m_TransformMovingImageFilter;
00186 
00188   CastFixedImageFilterPointer m_CastFixedImageFilter;
00189 
00190   SobelOperator< FixedGradientPixelType,
00191     itkGetStaticConstMacro(FixedImageDimension) >
00192     m_FixedSobelOperators[FixedImageDimension];
00193 
00194   typename FixedSobelFilter::Pointer m_FixedSobelFilters
00195     [itkGetStaticConstMacro( FixedImageDimension )];
00196 
00197   ZeroFluxNeumannBoundaryCondition< MovedGradientImageType > m_MovedBoundCond;
00198   ZeroFluxNeumannBoundaryCondition< FixedGradientImageType > m_FixedBoundCond;
00199 
00201   CastMovedImageFilterPointer m_CastMovedImageFilter;
00202   SobelOperator< MovedGradientPixelType,
00203     itkGetStaticConstMacro(MovedImageDimension) >
00204     m_MovedSobelOperators[MovedImageDimension];
00205 
00206   typename MovedSobelFilter::Pointer m_MovedSobelFilters[
00207     itkGetStaticConstMacro( MovedImageDimension ) ];
00208 
00209 };
00210 
00211 
00212 } // end namespace itk
00213 
00214 #ifndef ITK_MANUAL_INSTANTIATION
00215 #include "itkNormalizedGradientCorrelationImageToImageMetric.hxx"
00216 #endif
00217 
00218 #endif


Generated on 24-10-2011 for elastix by doxygen 1.7.4 elastix logo