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.
1 /*======================================================================
2 
3  This file is part of the elastix software.
4 
5  Copyright (c) University Medical Center Utrecht. All rights reserved.
6  See src/CopyrightElastix.txt or http://elastix.isi.uu.nl/legal.php for
7  details.
8 
9  This software is distributed WITHOUT ANY WARRANTY; without even
10  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11  PURPOSE. See the above copyright notices for more information.
12 
13 ======================================================================*/
14 #ifndef __itkNormalizedGradientCorrelationImageToImageMetric_h
15 #define __itkNormalizedGradientCorrelationImageToImageMetric_h
16 
18 #include "itkSobelOperator.h"
19 #include "itkNeighborhoodOperatorImageFilter.h"
20 #include "itkPoint.h"
21 #include "itkCastImageFilter.h"
22 #include "itkResampleImageFilter.h"
23 #include "itkOptimizer.h"
26 
27 namespace itk
28 {
29 
39 template < class TFixedImage, class TMovingImage >
41  public AdvancedImageToImageMetric< TFixedImage, TMovingImage>
42 {
43 public:
44 
48  typedef SmartPointer<Self> Pointer;
49  typedef SmartPointer<const Self> ConstPointer;
50 
52  itkNewMacro( Self );
53 
56 
59  #if defined(_MSC_VER) && (_MSC_VER == 1300)
60  typedef double RealType;
61  #else
62  typedef typename Superclass::RealType RealType;
63  #endif
64 
65  typedef typename Superclass::TransformType TransformType;
66  typedef typename TransformType::ScalarType ScalarType;
67  typedef typename Superclass::TransformPointer TransformPointer;
68  typedef typename TransformType::ConstPointer TransformConstPointer;
69  typedef typename Superclass::TransformParametersType TransformParametersType;
70  typedef typename Superclass::TransformJacobianType TransformJacobianType;
71  typedef typename Superclass::InterpolatorType InterpolatorType;
72  typedef typename InterpolatorType::Pointer InterpolatorPointer;
73  typedef typename Superclass::MeasureType MeasureType;
74  typedef typename Superclass::DerivativeType DerivativeType;
75  typedef typename Superclass::FixedImageType FixedImageType;
76  typedef typename Superclass::FixedImageRegionType FixedImageRegionType;
77  typedef typename Superclass::MovingImageType MovingImageType;
78  typedef typename Superclass::MovingImageRegionType MovingImageRegionType;
79  typedef typename Superclass::FixedImageConstPointer FixedImageConstPointer;
80  typedef typename Superclass::MovingImageConstPointer MovingImageConstPointer;
81  typedef typename Superclass::MovingImagePointer MovingImagePointer;
82  typedef typename TFixedImage::PixelType FixedImagePixelType;
83  typedef typename TMovingImage::PixelType MovedImagePixelType;
84  typedef typename itk::Optimizer OptimizerType;
85  typedef typename OptimizerType::ScalesType ScalesType;
86 
87  itkStaticConstMacro( FixedImageDimension, unsigned int, TFixedImage::ImageDimension );
88 
90  typedef typename itk::AdvancedCombinationTransform<
91  ScalarType, FixedImageDimension> CombinationTransformType;
92  typedef typename CombinationTransformType::Pointer CombinationTransformPointer;
93  typedef itk::Image< FixedImagePixelType,
94  itkGetStaticConstMacro( FixedImageDimension ) > TransformedMovingImageType;
95  typedef itk::Image< unsigned char,
96  itkGetStaticConstMacro( FixedImageDimension ) > MaskImageType;
97  typedef typename MaskImageType::Pointer MaskImageTypePointer;
98  typedef itk::ResampleImageFilter<
100  typedef typename TransformMovingImageFilterType::Pointer TransformMovingImageFilterPointer;
104 
106  typedef itk::Image< RealType,
107  itkGetStaticConstMacro( FixedImageDimension ) > FixedGradientImageType;
108  typedef itk::CastImageFilter< FixedImageType,
110  typedef typename CastFixedImageFilterType::Pointer CastFixedImageFilterPointer;
111  typedef typename FixedGradientImageType::PixelType FixedGradientPixelType;
112 
114  itkStaticConstMacro( MovedImageDimension, unsigned int, MovingImageType::ImageDimension );
115  typedef itk::Image< RealType,
116  itkGetStaticConstMacro( MovedImageDimension ) > MovedGradientImageType;
117  typedef itk::CastImageFilter< TransformedMovingImageType,
119  typedef typename CastMovedImageFilterType::Pointer CastMovedImageFilterPointer;
120  typedef typename MovedGradientImageType::PixelType MovedGradientPixelType;
121 
123  virtual void GetDerivative( const TransformParametersType & parameters,
124  DerivativeType & derivative ) const;
125 
127  virtual MeasureType GetValue( const TransformParametersType & parameters ) const;
128 
130  virtual void GetValueAndDerivative( const TransformParametersType & parameters,
131  MeasureType& Value, DerivativeType& derivative ) const;
132 
136  virtual void Initialize( void ) throw ( ExceptionObject );
137 
139  void WriteGradientImagesToFiles( void ) const;
140 
142  itkSetMacro( Scales , ScalesType );
143  itkGetConstReferenceMacro( Scales, ScalesType );
144 
148  itkSetMacro( DerivativeDelta, double );
149  itkGetConstReferenceMacro( DerivativeDelta, double );
150 
152  void SetTransformParameters( const TransformParametersType & parameters ) const;
153 
154  protected:
156  virtual ~NormalizedGradientCorrelationImageToImageMetric() {};
157  virtual void PrintSelf( std::ostream& os, Indent indent ) const;
158 
160  void ComputeMeanMovedGradient( void ) const;
161  void ComputeMeanFixedGradient( void ) const;
162 
164  MeasureType ComputeMeasure( const TransformParametersType & parameters ) const;
165  typedef NeighborhoodOperatorImageFilter<
167  typedef NeighborhoodOperatorImageFilter<
169 
170 private:
171  NormalizedGradientCorrelationImageToImageMetric(const Self&); //purposely not implemented
172  void operator=(const Self&); //purposely not implemented
173 
177 
179  mutable MovedGradientPixelType m_MeanMovedGradient[ MovedImageDimension ];
180 
182  mutable FixedGradientPixelType m_MeanFixedGradient[ FixedImageDimension ];
183 
186 
189 
190  SobelOperator< FixedGradientPixelType,
191  itkGetStaticConstMacro(FixedImageDimension) >
192  m_FixedSobelOperators[FixedImageDimension];
193 
194  typename FixedSobelFilter::Pointer m_FixedSobelFilters
195  [itkGetStaticConstMacro( FixedImageDimension )];
196 
199 
202  SobelOperator< MovedGradientPixelType,
203  itkGetStaticConstMacro(MovedImageDimension) >
204  m_MovedSobelOperators[MovedImageDimension];
205 
206  typename MovedSobelFilter::Pointer m_MovedSobelFilters[
207  itkGetStaticConstMacro( MovedImageDimension ) ];
208 
209 };
210 
211 
212 } // end namespace itk
213 
214 #ifndef ITK_MANUAL_INSTANTIATION
215 #include "itkNormalizedGradientCorrelationImageToImageMetric.hxx"
216 #endif
217 
218 #endif


Generated on 27-06-2013 for elastix by doxygen 1.8.3.1 elastix logo