ITK  5.2.0
Insight Toolkit
itkGradientDifferenceImageToImageMetric.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright NumFOCUS
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 <typename TFixedImage, typename TMovingImage>
58 class ITK_TEMPLATE_EXPORT GradientDifferenceImageToImageMetric : public ImageToImageMetric<TFixedImage, TMovingImage>
59 {
60 public:
61  ITK_DISALLOW_COPY_AND_MOVE(GradientDifferenceImageToImageMetric);
62 
66 
69 
71  itkNewMacro(Self);
72 
75 
77  using RealType = typename Superclass::RealType;
78  using TransformType = typename Superclass::TransformType;
79  using TransformPointer = typename Superclass::TransformPointer;
80  using TransformParametersType = typename Superclass::TransformParametersType;
81  using TransformJacobianType = typename Superclass::TransformJacobianType;
82 
83  using MeasureType = typename Superclass::MeasureType;
84  using DerivativeType = typename Superclass::DerivativeType;
85  using FixedImageType = typename Superclass::FixedImageType;
86  using MovingImageType = typename Superclass::MovingImageType;
87  using FixedImageConstPointer = typename Superclass::FixedImageConstPointer;
88  using MovingImageConstPointer = typename Superclass::MovingImageConstPointer;
89 
90  using FixedImagePixelType = typename TFixedImage::PixelType;
91  using MovedImagePixelType = typename TMovingImage::PixelType;
92 
93  static constexpr unsigned int FixedImageDimension = TFixedImage::ImageDimension;
96 
98 
102 
105 
107 
110  static constexpr unsigned int MovedImageDimension = MovingImageType::ImageDimension;
111 
113 
116 
118 
120  void
121  GetDerivative(const TransformParametersType & parameters, DerivativeType & derivative) const override;
122 
125  GetValue(const TransformParametersType & parameters) const override;
126 
128  void
129  GetValueAndDerivative(const TransformParametersType & parameters,
130  MeasureType & Value,
131  DerivativeType & Derivative) const override;
132 
135  void
136  Initialize() override;
137 
139  void
140  WriteGradientImagesToFiles() const;
141 
144  itkSetMacro(DerivativeDelta, double);
145  itkGetConstReferenceMacro(DerivativeDelta, double);
147 
148 protected:
150  ~GradientDifferenceImageToImageMetric() override = default;
151  void
152  PrintSelf(std::ostream & os, Indent indent) const override;
153 
155  void
156  ComputeMovedGradientRange() const;
157 
159  void
160  ComputeVariance() const;
161 
164  ComputeMeasure(const TransformParametersType & parameters, const double * subtractionFactor) const;
165 
167 
169 
170 private:
172  mutable MovedGradientPixelType m_Variance[FixedImageDimension];
173 
175  mutable MovedGradientPixelType m_MinMovedGradient[MovedImageDimension];
176  mutable MovedGradientPixelType m_MaxMovedGradient[MovedImageDimension];
177 
179  mutable FixedGradientPixelType m_MinFixedGradient[FixedImageDimension];
180  mutable FixedGradientPixelType m_MaxFixedGradient[FixedImageDimension];
181 
184 
187 
188  SobelOperator<FixedGradientPixelType, Self::FixedImageDimension> m_FixedSobelOperators[FixedImageDimension];
189 
190  typename FixedSobelFilter::Pointer m_FixedSobelFilters[Self::FixedImageDimension];
191 
194 
197 
198  SobelOperator<MovedGradientPixelType, Self::MovedImageDimension> m_MovedSobelOperators[MovedImageDimension];
199 
200  typename MovedSobelFilter::Pointer m_MovedSobelFilters[Self::MovedImageDimension];
201 
203 };
204 } // end namespace itk
205 
206 #ifndef ITK_MANUAL_INSTANTIATION
207 # include "itkGradientDifferenceImageToImageMetric.hxx"
208 #endif
209 
210 #endif
itk::ImageToImageMetric
Computes similarity between regions of two images.
Definition: itkImageToImageMetric.h:52
itk::SobelOperator< FixedGradientPixelType, Self::FixedImageDimension >
itk::CastImageFilter
Casts input pixels to output pixel type.
Definition: itkCastImageFilter.h:104
itk::SingleValuedCostFunction::MeasureType
double MeasureType
Definition: itkSingleValuedCostFunction.h:50
itk::GradientDifferenceImageToImageMetric::TransformParametersType
typename Superclass::TransformParametersType TransformParametersType
Definition: itkGradientDifferenceImageToImageMetric.h:80
itk::GradientDifferenceImageToImageMetric::MovingImageType
typename Superclass::MovingImageType MovingImageType
Definition: itkGradientDifferenceImageToImageMetric.h:86
itk::GradientDifferenceImageToImageMetric::m_FixedBoundCond
ZeroFluxNeumannBoundaryCondition< FixedGradientImageType > m_FixedBoundCond
Definition: itkGradientDifferenceImageToImageMetric.h:193
itkPoint.h
itk::GradientDifferenceImageToImageMetric::MovingImageConstPointer
typename Superclass::MovingImageConstPointer MovingImageConstPointer
Definition: itkGradientDifferenceImageToImageMetric.h:88
itk::GradientDifferenceImageToImageMetric::FixedGradientPixelType
typename FixedGradientImageType::PixelType FixedGradientPixelType
Definition: itkGradientDifferenceImageToImageMetric.h:106
itk::GradientDifferenceImageToImageMetric
Computes similarity between two objects to be registered.
Definition: itkGradientDifferenceImageToImageMetric.h:58
itk::GradientDifferenceImageToImageMetric::FixedImagePixelType
typename TFixedImage::PixelType FixedImagePixelType
Definition: itkGradientDifferenceImageToImageMetric.h:90
itk::SmartPointer< Self >
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itkCastImageFilter.h
itk::GradientDifferenceImageToImageMetric::m_CastFixedImageFilter
CastFixedImageFilterPointer m_CastFixedImageFilter
Definition: itkGradientDifferenceImageToImageMetric.h:186
itk::GradientDifferenceImageToImageMetric::CastMovedImageFilterPointer
typename CastMovedImageFilterType::Pointer CastMovedImageFilterPointer
Definition: itkGradientDifferenceImageToImageMetric.h:115
itk::GradientDifferenceImageToImageMetric::CastFixedImageFilterPointer
typename CastFixedImageFilterType::Pointer CastFixedImageFilterPointer
Definition: itkGradientDifferenceImageToImageMetric.h:104
itk::LightObject
Light weight base class for most itk classes.
Definition: itkLightObject.h:59
itk::GradientDifferenceImageToImageMetric::FixedImageConstPointer
typename Superclass::FixedImageConstPointer FixedImageConstPointer
Definition: itkGradientDifferenceImageToImageMetric.h:87
itkImageToImageMetric.h
itk::GradientDifferenceImageToImageMetric::m_MovedBoundCond
ZeroFluxNeumannBoundaryCondition< MovedGradientImageType > m_MovedBoundCond
Definition: itkGradientDifferenceImageToImageMetric.h:192
itk::GradientDifferenceImageToImageMetric::m_TransformMovingImageFilter
TransformMovingImageFilterType::Pointer m_TransformMovingImageFilter
Definition: itkGradientDifferenceImageToImageMetric.h:183
itkSobelOperator.h
itk::GradientDifferenceImageToImageMetric::TransformPointer
typename Superclass::TransformPointer TransformPointer
Definition: itkGradientDifferenceImageToImageMetric.h:79
itkNeighborhoodOperatorImageFilter.h
itk::Image::PixelType
TPixel PixelType
Definition: itkImage.h:106
itk::GradientDifferenceImageToImageMetric::TransformJacobianType
typename Superclass::TransformJacobianType TransformJacobianType
Definition: itkGradientDifferenceImageToImageMetric.h:81
itk::GradientDifferenceImageToImageMetric::FixedImageType
typename Superclass::FixedImageType FixedImageType
Definition: itkGradientDifferenceImageToImageMetric.h:85
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itk::GradientDifferenceImageToImageMetric::RealType
typename Superclass::RealType RealType
Definition: itkGradientDifferenceImageToImageMetric.h:77
itk::Array
Array class with size defined at construction time.
Definition: itkArray.h:47
itk::ResampleImageFilter
Resample an image via a coordinate transform.
Definition: itkResampleImageFilter.h:90
itk::GradientDifferenceImageToImageMetric::MovedImagePixelType
typename TMovingImage::PixelType MovedImagePixelType
Definition: itkGradientDifferenceImageToImageMetric.h:91
itk::GradientDifferenceImageToImageMetric::m_CastMovedImageFilter
CastMovedImageFilterPointer m_CastMovedImageFilter
Definition: itkGradientDifferenceImageToImageMetric.h:196
itk::GradientDifferenceImageToImageMetric::m_DerivativeDelta
double m_DerivativeDelta
Definition: itkGradientDifferenceImageToImageMetric.h:202
itk::Image
Templated n-dimensional image class.
Definition: itkImage.h:86
itk::ZeroFluxNeumannBoundaryCondition
A function object that determines a neighborhood of values at an image boundary according to a Neuman...
Definition: itkZeroFluxNeumannBoundaryCondition.h:58
itk::NeighborhoodOperatorImageFilter
Applies a single NeighborhoodOperator to an image region.
Definition: itkNeighborhoodOperatorImageFilter.h:51
itk::GradientDifferenceImageToImageMetric::MovedGradientPixelType
typename MovedGradientImageType::PixelType MovedGradientPixelType
Definition: itkGradientDifferenceImageToImageMetric.h:117
itkResampleImageFilter.h
itk::GradientDifferenceImageToImageMetric::TransformType
typename Superclass::TransformType TransformType
Definition: itkGradientDifferenceImageToImageMetric.h:78