ITK  5.4.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"
22 #include "itkImageToImageMetric.h"
23 
24 namespace itk
25 {
38 template <typename TFixedImage, typename TMovingImage>
39 class ITK_TEMPLATE_EXPORT HistogramImageToImageMetric : public ImageToImageMetric<TFixedImage, TMovingImage>
40 {
41 public:
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 
76  using MeasurementVectorType = typename HistogramType::MeasurementVectorType;
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
145  GetValueAndDerivative(const TransformParametersType & parameters,
146  MeasureType & value,
147  DerivativeType & derivative) const override;
148 
152  void
153  SetLowerBound(const MeasurementVectorType & bounds);
154 
156  const MeasurementVectorType &
157  GetLowerBound() const;
158 
162  void
163  SetUpperBound(const MeasurementVectorType & bounds);
164 
166  const MeasurementVectorType &
167  GetUpperBound() const;
168 
169 protected:
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
204  ComputeHistogram(const TransformParametersType & parameters,
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 
222 private:
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
Pointer
SmartPointer< Self > Pointer
Definition: itkAddImageFilter.h:93
itk::ImageToImageMetric
Computes similarity between regions of two images.
Definition: itkImageToImageMetric.h:54
itk::SingleValuedCostFunction::MeasureType
double MeasureType
Definition: itkSingleValuedCostFunction.h:50
itk::HistogramImageToImageMetric::FixedImagePixelType
typename Superclass::FixedImageType::PixelType FixedImagePixelType
Definition: itkHistogramImageToImageMetric.h:65
itk::ImageToImageMetric::TransformParametersType
typename TransformType::ParametersType TransformParametersType
Definition: itkImageToImageMetric.h:92
itk::HistogramImageToImageMetric::HistogramPointer
typename HistogramType::Pointer HistogramPointer
Definition: itkHistogramImageToImageMetric.h:78
itk::GTest::TypedefsAndConstructors::Dimension2::SizeType
ImageBaseType::SizeType SizeType
Definition: itkGTestTypedefsAndConstructors.h:49
itk::SmartPointer< Self >
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::HistogramImageToImageMetric::FixedImageConstPointerType
typename Superclass::FixedImageConstPointer FixedImageConstPointerType
Definition: itkHistogramImageToImageMetric.h:68
itk::Statistics::Histogram
This class stores measurement vectors in the context of n-dimensional histogram.
Definition: itkHistogram.h:77
itk::LightObject
Light weight base class for most itk classes.
Definition: itkLightObject.h:55
itkHistogram.h
itkImageToImageMetric.h
itk::HistogramImageToImageMetric::MovingImageConstPointerType
typename Superclass::MovingImageConstPointer MovingImageConstPointerType
Definition: itkHistogramImageToImageMetric.h:69
itk::HistogramImageToImageMetric::HistogramSizeType
typename HistogramType::SizeType HistogramSizeType
Definition: itkHistogramImageToImageMetric.h:77
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itk::Array< double >
itk::HistogramImageToImageMetric::MeasurementVectorType
typename HistogramType::MeasurementVectorType MeasurementVectorType
Definition: itkHistogramImageToImageMetric.h:76
itk::Transform
Transform points and vectors from an input space to an output space.
Definition: itkTransform.h:83
itk::HistogramImageToImageMetric
Computes similarity between two objects to be registered.
Definition: itkHistogramImageToImageMetric.h:39
itk::HistogramImageToImageMetric::MovingImagePixelType
typename Superclass::MovingImageType::PixelType MovingImagePixelType
Definition: itkHistogramImageToImageMetric.h:67