ITK  6.0.0
Insight Toolkit
itkMeanSquaresImageToImageMetric.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  * https://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 itkMeanSquaresImageToImageMetric_h
19 #define itkMeanSquaresImageToImageMetric_h
20 
21 #include "itkImageToImageMetric.h"
22 #include "itkPoint.h"
23 #include "itkIndex.h"
24 
25 #include <memory> // For unique_ptr.
26 
27 
28 namespace itk
29 {
30 
40 template <typename TFixedImage, typename TMovingImage>
41 class ITK_TEMPLATE_EXPORT MeanSquaresImageToImageMetric : public ImageToImageMetric<TFixedImage, TMovingImage>
42 {
43 public:
44  ITK_DISALLOW_COPY_AND_MOVE(MeanSquaresImageToImageMetric);
45 
51 
53  itkNewMacro(Self);
54 
56  itkOverrideGetNameOfClassMacro(MeanSquaresImageToImageMetric);
57 
59  using typename Superclass::TransformType;
60  using typename Superclass::TransformPointer;
61  using typename Superclass::TransformJacobianType;
62  using typename Superclass::InterpolatorType;
63  using typename Superclass::MeasureType;
64  using typename Superclass::DerivativeType;
65  using typename Superclass::ParametersType;
66  using typename Superclass::FixedImageType;
67  using typename Superclass::MovingImageType;
68  using typename Superclass::MovingImagePointType;
69  using typename Superclass::FixedImageConstPointer;
70  using typename Superclass::MovingImageConstPointer;
71  using typename Superclass::CoordinateRepresentationType;
72  using typename Superclass::FixedImageSampleContainer;
73  using typename Superclass::ImageDerivativesType;
74  using typename Superclass::WeightsValueType;
75  using typename Superclass::IndexValueType;
76 
77  // Needed for evaluation of Jacobian.
78  using typename Superclass::FixedImagePointType;
79 
81  static constexpr unsigned int MovingImageDimension = MovingImageType::ImageDimension;
82 
90  void
91  Initialize() override;
92 
95  GetValue(const ParametersType & parameters) const override;
96 
98  void
99  GetDerivative(const ParametersType & parameters, DerivativeType & derivative) const override;
100 
102  void
103  GetValueAndDerivative(const ParametersType & parameters,
104  MeasureType & value,
105  DerivativeType & derivative) const override;
106 
107 protected:
109  ~MeanSquaresImageToImageMetric() override = default;
110  void
111  PrintSelf(std::ostream & os, Indent indent) const override;
112 
113 private:
114  bool
115  GetValueThreadProcessSample(ThreadIdType threadId,
116  SizeValueType fixedImageSample,
117  const MovingImagePointType & mappedPoint,
118  double movingImageValue) const override;
119 
120  bool
121  GetValueAndDerivativeThreadProcessSample(ThreadIdType threadId,
122  SizeValueType fixedImageSample,
123  const MovingImagePointType & mappedPoint,
124  double movingImageValue,
125  const ImageDerivativesType & movingImageGradientValue) const override;
126 
127  struct PerThreadS
128  {
129  TransformJacobianType m_Jacobian;
131  DerivativeType m_MSEDerivative;
132  };
133 
134  itkAlignedTypedef(64, PerThreadS, AlignedPerThreadType);
135  std::unique_ptr<AlignedPerThreadType[]> m_PerThread;
136 };
137 } // end namespace itk
138 
139 #ifndef ITK_MANUAL_INSTANTIATION
140 # include "itkMeanSquaresImageToImageMetric.hxx"
141 #endif
142 
143 #endif
itk::MeanSquaresImageToImageMetric::PerThreadS::m_MSEDerivative
DerivativeType m_MSEDerivative
Definition: itkMeanSquaresImageToImageMetric.h:131
itk::ImageToImageMetric
Computes similarity between regions of two images.
Definition: itkImageToImageMetric.h:54
itk::SingleValuedCostFunction::MeasureType
double MeasureType
Definition: itkSingleValuedCostFunction.h:50
itk::OptimizerParameters< TInternalComputationValueType >
itk::MeanSquaresImageToImageMetric::PerThreadS
Definition: itkMeanSquaresImageToImageMetric.h:127
itkPoint.h
itk::ImageToImageMetric::MovingImagePointType
typename TransformType::OutputPointType MovingImagePointType
Definition: itkImageToImageMetric.h:100
itk::SmartPointer< Self >
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::IndexValueType
long IndexValueType
Definition: itkIntTypes.h:93
itk::MeanSquaresImageToImageMetric::m_PerThread
std::unique_ptr< AlignedPerThreadType[]> m_PerThread
Definition: itkMeanSquaresImageToImageMetric.h:135
itk::ThreadIdType
unsigned int ThreadIdType
Definition: itkIntTypes.h:102
itk::LightObject
Light weight base class for most itk classes.
Definition: itkLightObject.h:55
itkImageToImageMetric.h
itk::MeanSquaresImageToImageMetric::PerThreadS::m_Jacobian
TransformJacobianType m_Jacobian
Definition: itkMeanSquaresImageToImageMetric.h:129
itkIndex.h
itk::MeanSquaresImageToImageMetric
TODO.
Definition: itkMeanSquaresImageToImageMetric.h:41
itk::MeanSquaresImageToImageMetric::PerThreadS::m_MSE
MeasureType m_MSE
Definition: itkMeanSquaresImageToImageMetric.h:130
itk::CovariantVector
A templated class holding a n-Dimensional covariant vector.
Definition: itkCovariantVector.h:70
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnatomicalOrientation.h:29
itk::Array
Array class with size defined at construction time.
Definition: itkArray.h:47
itk::SizeValueType
unsigned long SizeValueType
Definition: itkIntTypes.h:86