go home Home | Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Namespace Members | Data Fields | Globals | Related Pages
itkGradientDifferenceImageToImageMetric2.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 /*=========================================================================
15 
16  Program: Insight Segmentation & Registration Toolkit
17  Module: $RCSfile: itkGradientDifferenceImageToImageMetric2.h,v $
18  Language: C++
19  Date: $Date: 2011-29-04 14:33 $
20  Version: $Revision: 2.0 $
21 
22  Copyright (c) Insight Software Consortium. All rights reserved.
23  See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
24 
25  This software is distributed WITHOUT ANY WARRANTY; without even
26  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
27  PURPOSE. See the above copyright notices for more information.
28 
29 =========================================================================*/
30 #ifndef __itkGradientDifferenceImageToImageMetric2_h
31 #define __itkGradientDifferenceImageToImageMetric2_h
32 
34 
35 #include "itkSobelOperator.h"
36 #include "itkNeighborhoodOperatorImageFilter.h"
37 #include "itkPoint.h"
38 #include "itkCastImageFilter.h"
39 #include "itkResampleImageFilter.h"
40 #include "itkOptimizer.h"
43 
44 namespace itk
45 {
70 template < class TFixedImage, class TMovingImage >
72 public AdvancedImageToImageMetric< TFixedImage, TMovingImage>
73 {
74 public:
75 
79 
80  typedef SmartPointer<Self> Pointer;
81  typedef SmartPointer<const Self> ConstPointer;
82 
84  itkNewMacro(Self);
85 
88 
91  #if defined(_MSC_VER) && (_MSC_VER == 1300)
92  typedef double RealType;
93  #else
94  typedef typename Superclass::RealType RealType;
95  #endif
96 
97  typedef typename Superclass::TransformType TransformType;
98  typedef typename TransformType::ScalarType ScalarType;
99  typedef typename Superclass::TransformPointer TransformPointer;
100  typedef typename Superclass::TransformParametersType TransformParametersType;
101  typedef typename Superclass::TransformJacobianType TransformJacobianType;
102  typedef typename Superclass::InterpolatorType InterpolatorType;
103  typedef typename InterpolatorType::Pointer InterpolatorPointer;
104  typedef typename Superclass::MeasureType MeasureType;
105  typedef typename Superclass::DerivativeType DerivativeType;
106  typedef typename Superclass::FixedImageType FixedImageType;
107  typedef typename Superclass::MovingImageType MovingImageType;
108  typedef typename Superclass::FixedImageConstPointer FixedImageConstPointer;
109  typedef typename Superclass::MovingImageConstPointer MovingImageConstPointer;
110  typedef typename TFixedImage::PixelType FixedImagePixelType;
111  typedef typename TMovingImage::PixelType MovedImagePixelType;
112  typedef typename MovingImageType::RegionType MovingImageRegionType;
113  typedef typename itk::Optimizer OptimizerType;
114  typedef typename OptimizerType::ScalesType ScalesType;
115 
116  itkStaticConstMacro( FixedImageDimension, unsigned int,
117  FixedImageType::ImageDimension );
118  itkStaticConstMacro( MovedImageDimension, unsigned int,
119  MovingImageType::ImageDimension );
120 
123  typedef typename CombinationTransformType::Pointer CombinationTransformPointer;
124  typedef itk::Image< FixedImagePixelType, itkGetStaticConstMacro( FixedImageDimension ) >
126  typedef itk::ResampleImageFilter< MovingImageType, TransformedMovingImageType >
131  typedef itk::Image< RealType, itkGetStaticConstMacro( FixedImageDimension ) >
133  typedef itk::CastImageFilter< FixedImageType, FixedGradientImageType >
135  typedef typename CastFixedImageFilterType::Pointer CastFixedImageFilterPointer;
136  typedef typename FixedGradientImageType::PixelType FixedGradientPixelType;
137  typedef itk::Image< RealType, itkGetStaticConstMacro( MovedImageDimension ) >
139  typedef itk::CastImageFilter< TransformedMovingImageType, MovedGradientImageType >
141  typedef typename CastMovedImageFilterType::Pointer CastMovedImageFilterPointer;
142  typedef typename MovedGradientImageType::PixelType MovedGradientPixelType;
143 
145  void GetDerivative( const TransformParametersType & parameters,
146  DerivativeType & derivative ) const;
147 
149  MeasureType GetValue( const TransformParametersType & parameters ) const;
150 
152  void GetValueAndDerivative( const TransformParametersType & parameters,
153  MeasureType& Value, DerivativeType& derivative ) const;
154 
155  virtual void Initialize(void) throw ( ExceptionObject );
156 
158  void WriteGradientImagesToFiles(void) const;
159 
161  itkSetMacro( Scales , ScalesType );
162  itkGetConstReferenceMacro( Scales, ScalesType );
163 
166  itkSetMacro( DerivativeDelta, double );
167  itkGetConstReferenceMacro( DerivativeDelta, double );
168 
169 protected:
171  virtual ~GradientDifferenceImageToImageMetric() {};
172  void PrintSelf(std::ostream& os, Indent indent) const;
173 
175  void ComputeMovedGradientRange( void ) const;
176 
178  void ComputeVariance( void ) const;
179 
181  MeasureType ComputeMeasure( const TransformParametersType &parameters,
182  const double *subtractionFactor ) const;
183 
184  typedef NeighborhoodOperatorImageFilter<
186 
187  typedef NeighborhoodOperatorImageFilter<
189 
190 private:
191  GradientDifferenceImageToImageMetric(const Self&); //purposely not implemented
192  void operator=(const Self&); //purposely not implemented
193 
195  mutable MovedGradientPixelType m_Variance[FixedImageDimension];
196 
198  mutable MovedGradientPixelType m_MinMovedGradient[MovedImageDimension];
199  mutable MovedGradientPixelType m_MaxMovedGradient[MovedImageDimension];
200 
202  mutable FixedGradientPixelType m_MinFixedGradient[FixedImageDimension];
203  mutable FixedGradientPixelType m_MaxFixedGradient[FixedImageDimension];
204 
206  typename TransformMovingImageFilterType::Pointer m_TransformMovingImageFilter;
207 
210 
211  SobelOperator< FixedGradientPixelType,
212  itkGetStaticConstMacro(FixedImageDimension) >
213  m_FixedSobelOperators[FixedImageDimension];
214 
215  typename FixedSobelFilter::Pointer m_FixedSobelFilters[itkGetStaticConstMacro
216  ( FixedImageDimension )];
217 
220 
223 
224  SobelOperator< MovedGradientPixelType,
225  itkGetStaticConstMacro(MovedImageDimension) >
226  m_MovedSobelOperators[MovedImageDimension];
227 
228  typename MovedSobelFilter::Pointer m_MovedSobelFilters[itkGetStaticConstMacro
229  ( MovedImageDimension )];
230 
235 
236  };
237 
238 
239 } // end namespace itk
240 
241 
242 #ifndef ITK_MANUAL_INSTANTIATION
243 #include "itkGradientDifferenceImageToImageMetric2.hxx"
244 #endif
245 
246 
247 #endif


Generated on 21-03-2014 for elastix by doxygen 1.8.1.2 elastix logo