ITK  6.0.0
Insight Toolkit
itkHistogramImageToImageMetric.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 itkHistogramImageToImageMetric_h
19#define itkHistogramImageToImageMetric_h
20
21#include "itkHistogram.h"
23
24namespace itk
25{
38template <typename TFixedImage, typename TMovingImage>
39class ITK_TEMPLATE_EXPORT HistogramImageToImageMetric : public ImageToImageMetric<TFixedImage, TMovingImage>
40{
41public:
42 ITK_DISALLOW_COPY_AND_MOVE(HistogramImageToImageMetric);
43
49
51 itkOverrideGetNameOfClassMacro(HistogramImageToImageMetric);
52
54 using typename Superclass::RealType;
55 using typename Superclass::TransformType;
56 using typename Superclass::TransformPointer;
57 using typename Superclass::TransformParametersType;
58 using typename Superclass::TransformJacobianType;
59 using typename Superclass::GradientPixelType;
60 using typename Superclass::InputPointType;
61 using typename Superclass::OutputPointType;
62 using typename Superclass::MeasureType;
63 using typename Superclass::DerivativeType;
64 using typename Superclass::FixedImageType;
65 using FixedImagePixelType = typename Superclass::FixedImageType::PixelType;
66 using typename Superclass::MovingImageType;
67 using MovingImagePixelType = typename Superclass::MovingImageType::PixelType;
68 using FixedImageConstPointerType = typename Superclass::FixedImageConstPointer;
69 using MovingImageConstPointerType = typename Superclass::MovingImageConstPointer;
70
75
79
81 void
82 Initialize() override;
83
86 void
87 SetTransform(TransformType * transform) override;
88
91 itkSetMacro(HistogramSize, HistogramSizeType);
92
94 itkGetConstReferenceMacro(HistogramSize, HistogramSizeType);
95
98 itkSetMacro(UpperBoundIncreaseFactor, double);
99 itkGetConstMacro(UpperBoundIncreaseFactor, double);
103 itkSetMacro(PaddingValue, FixedImagePixelType);
104
106 itkGetConstReferenceMacro(PaddingValue, FixedImagePixelType);
107
111 itkGetConstReferenceMacro(Histogram, HistogramPointer);
112
116 itkSetMacro(UsePaddingValue, bool);
117 itkGetConstMacro(UsePaddingValue, bool);
121 itkSetMacro(DerivativeStepLength, double);
122
124 itkGetConstMacro(DerivativeStepLength, double);
125
128
130 itkSetMacro(DerivativeStepLengthScales, ScalesType);
131
133 itkGetConstReferenceMacro(DerivativeStepLengthScales, ScalesType);
134
137 GetValue(const TransformParametersType & parameters) const override;
138
140 void
141 GetDerivative(const TransformParametersType & parameters, DerivativeType & derivative) const override;
142
144 void
146 MeasureType & value,
147 DerivativeType & derivative) const override;
148
152 void
154
158
162 void
164
168
169protected:
173 ~HistogramImageToImageMetric() override = default;
177 HistogramSizeType m_HistogramSize{};
178
180 mutable MeasurementVectorType m_LowerBound{};
181
183 mutable MeasurementVectorType m_UpperBound{};
184
186 double m_UpperBoundIncreaseFactor{};
187
190 bool m_LowerBoundSetByUser{};
191
194 bool m_UpperBoundSetByUser{};
195
198 void
199 ComputeHistogram(const TransformParametersType & parameters, HistogramType & histogram) const;
200
203 void
205 unsigned int parameter,
206 double step,
207 HistogramType & histogram) const;
208
210 void
211 CopyHistogram(HistogramType & target, HistogramType & source) const;
212
215 virtual MeasureType
216 EvaluateMeasure(HistogramType & histogram) const = 0;
217
219 void
220 PrintSelf(std::ostream & os, Indent indent) const override;
221
222private:
224 FixedImagePixelType m_PaddingValue{};
225
229 bool m_UsePaddingValue{};
230
232 double m_DerivativeStepLength{};
233
235 ScalesType m_DerivativeStepLengthScales{};
236
239 HistogramPointer m_Histogram{};
240};
241} // end namespace itk
242
243#ifndef ITK_MANUAL_INSTANTIATION
244# include "itkHistogramImageToImageMetric.hxx"
245#endif
246
247#endif // itkHistogramImageToImageMetric_h
Computes similarity between two objects to be registered.
void SetTransform(TransformType *transform) override
void ComputeHistogram(const TransformParametersType &parameters, unsigned int parameter, double step, HistogramType &histogram) const
const MeasurementVectorType & GetLowerBound() const
typename Superclass::MovingImageConstPointer MovingImageConstPointerType
const MeasurementVectorType & GetUpperBound() const
typename HistogramType::SizeType HistogramSizeType
void SetLowerBound(const MeasurementVectorType &bounds)
void GetValueAndDerivative(const TransformParametersType &parameters, MeasureType &value, DerivativeType &derivative) const override
void ComputeHistogram(const TransformParametersType &parameters, HistogramType &histogram) const
~HistogramImageToImageMetric() override=default
virtual MeasureType EvaluateMeasure(HistogramType &histogram) const =0
void SetUpperBound(const MeasurementVectorType &bounds)
typename Superclass::MovingImageType::PixelType MovingImagePixelType
typename Superclass::FixedImageConstPointer FixedImageConstPointerType
typename Superclass::FixedImageType::PixelType FixedImagePixelType
typename HistogramType::Pointer HistogramPointer
void CopyHistogram(HistogramType &target, HistogramType &source) const
MeasureType GetValue(const TransformParametersType &parameters) const override
void GetDerivative(const TransformParametersType &parameters, DerivativeType &derivative) const override
typename HistogramType::MeasurementVectorType MeasurementVectorType
void PrintSelf(std::ostream &os, Indent indent) const override
Computes similarity between regions of two images.
typename TransformType::ParametersType TransformParametersType
Control indentation during Print() invocation.
Definition: itkIndent.h:50
Light weight base class for most itk classes.
This class stores measurement vectors in the context of n-dimensional histogram.
Definition: itkHistogram.h:78
Transform points and vectors from an input space to an output space.
Definition: itkTransform.h:84
SmartPointer< Self > Pointer
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....