ITK  4.4.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;
78  typedef typename Superclass::TransformType TransformType;
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);
146 
147 protected:
149  virtual ~GradientDifferenceImageToImageMetric() {}
150  void PrintSelf(std::ostream & os, Indent indent) const;
151 
153  void ComputeMovedGradientRange(void) const;
154 
156  void ComputeVariance(void) const;
157 
159  MeasureType ComputeMeasure(const TransformParametersType & parameters,
160  const double *subtractionFactor) const;
161 
164 
167 
168 private:
169  GradientDifferenceImageToImageMetric(const Self &); //purposely not
170  // implemented
171  void operator=(const Self &); //purposely not
172 
173  // implemented
174 
176  mutable MovedGradientPixelType m_Variance[FixedImageDimension];
177 
179  mutable MovedGradientPixelType m_MinMovedGradient[MovedImageDimension];
180  mutable MovedGradientPixelType m_MaxMovedGradient[MovedImageDimension];
181 
183  mutable FixedGradientPixelType m_MinFixedGradient[FixedImageDimension];
184  mutable FixedGradientPixelType m_MaxFixedGradient[FixedImageDimension];
185 
188 
191 
193  itkGetStaticConstMacro(FixedImageDimension) >
194  m_FixedSobelOperators[FixedImageDimension];
195 
196  typename FixedSobelFilter::Pointer m_FixedSobelFilters[itkGetStaticConstMacro(FixedImageDimension)];
197 
200 
203 
205  itkGetStaticConstMacro(MovedImageDimension) >
206  m_MovedSobelOperators[MovedImageDimension];
207 
208  typename MovedSobelFilter::Pointer m_MovedSobelFilters[itkGetStaticConstMacro(MovedImageDimension)];
209 
211 };
212 } // end namespace itk
213 
214 #ifndef ITK_MANUAL_INSTANTIATION
215 #include "itkGradientDifferenceImageToImageMetric.hxx"
216 #endif
217 
218 #endif
219