ITK  4.2.0
Insight Segmentation and Registration Toolkit
itkGradientDifferenceImageToImageMetric.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
18 #ifndef __itkGradientDifferenceImageToImageMetric_h
19 #define __itkGradientDifferenceImageToImageMetric_h
20 
21 #include "itkImageToImageMetric.h"
22 
23 #include "itkSobelOperator.h"
25 #include "itkPoint.h"
26 #include "itkCastImageFilter.h"
27 #include "itkResampleImageFilter.h"
28 
29 namespace itk
30 {
57 template< class TFixedImage, class TMovingImage >
59  public ImageToImageMetric< TFixedImage, TMovingImage >
60 {
61 public:
62 
66 
69 
71  itkNewMacro(Self);
72 
75 
77  typedef typename Superclass::RealType RealType;
79  typedef typename Superclass::TransformPointer TransformPointer;
80  typedef typename Superclass::TransformParametersType TransformParametersType;
81  typedef typename Superclass::TransformJacobianType TransformJacobianType;
82 
83  typedef typename Superclass::MeasureType MeasureType;
84  typedef typename Superclass::DerivativeType DerivativeType;
85  typedef typename Superclass::FixedImageType FixedImageType;
86  typedef typename Superclass::MovingImageType MovingImageType;
87  typedef typename Superclass::FixedImageConstPointer FixedImageConstPointer;
88  typedef typename Superclass::MovingImageConstPointer MovingImageConstPointer;
89 
90  typedef typename TFixedImage::PixelType FixedImagePixelType;
91  typedef typename TMovingImage::PixelType MovedImagePixelType;
92 
93  itkStaticConstMacro(FixedImageDimension, unsigned int, TFixedImage::ImageDimension);
96  itkGetStaticConstMacro(FixedImageDimension) >
98 
101 
105 
108 
110 
113  itkStaticConstMacro(MovedImageDimension, unsigned int, MovingImageType::ImageDimension);
114 
116 
119 
121 
123  void GetDerivative(const TransformParametersType & parameters,
124  DerivativeType & derivative) const;
125 
127  MeasureType GetValue(const TransformParametersType & parameters) const;
128 
130  void GetValueAndDerivative(const TransformParametersType & parameters,
131  MeasureType & Value, DerivativeType & derivative) const;
132 
135  virtual void Initialize(void)
136  throw ( ExceptionObject );
137 
139  void WriteGradientImagesToFiles(void) const;
140 
143  itkSetMacro(DerivativeDelta, double);
144  itkGetConstReferenceMacro(DerivativeDelta, double);
145 protected:
147  virtual ~GradientDifferenceImageToImageMetric() {}
148  void PrintSelf(std::ostream & os, Indent indent) const;
150 
152  void ComputeMovedGradientRange(void) const;
153 
155  void ComputeVariance(void) const;
156 
158  MeasureType ComputeMeasure(const TransformParametersType & parameters,
159  const double *subtractionFactor) const;
160 
163 
166 private:
167  GradientDifferenceImageToImageMetric(const Self &); //purposely not
168  // implemented
169  void operator=(const Self &); //purposely not
170 
171  // implemented
172 
174  mutable MovedGradientPixelType m_Variance[FixedImageDimension];
175 
177  mutable MovedGradientPixelType m_MinMovedGradient[MovedImageDimension];
178  mutable MovedGradientPixelType m_MaxMovedGradient[MovedImageDimension];
179 
181  mutable FixedGradientPixelType m_MinFixedGradient[FixedImageDimension];
182  mutable FixedGradientPixelType m_MaxFixedGradient[FixedImageDimension];
183 
186 
189 
191  itkGetStaticConstMacro(FixedImageDimension) >
192  m_FixedSobelOperators[FixedImageDimension];
193 
194  typename FixedSobelFilter::Pointer m_FixedSobelFilters[itkGetStaticConstMacro(FixedImageDimension)];
195 
198 
201 
203  itkGetStaticConstMacro(MovedImageDimension) >
204  m_MovedSobelOperators[MovedImageDimension];
205 
206  typename MovedSobelFilter::Pointer m_MovedSobelFilters[itkGetStaticConstMacro(MovedImageDimension)];
207 
209 };
210 } // end namespace itk
211 
212 #ifndef ITK_MANUAL_INSTANTIATION
213 #include "itkGradientDifferenceImageToImageMetric.hxx"
214 #endif
215 
216 #endif
217