ITK  5.1.0
Insight Toolkit
itkObjectToObjectMetricBase.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 itkObjectToObjectMetricBase_h
19 #define itkObjectToObjectMetricBase_h
20 
21 #include "itkTransformBase.h"
23 #include "ITKOptimizersv4Export.h"
24 
25 namespace itk
26 {
33 {
37 };
38 
43 {
44  UNKNOWN_METRIC = 0,
45  OBJECT_METRIC = 1,
46  IMAGE_METRIC = 2,
47  POINT_SET_METRIC = 3,
48  MULTI_METRIC = 4
49 };
50 
73 template <typename TInternalComputationValueType = double>
74 class ITK_TEMPLATE_EXPORT ObjectToObjectMetricBaseTemplate
75  : public SingleValuedCostFunctionv4Template<TInternalComputationValueType>
76 {
77 public:
78  ITK_DISALLOW_COPY_AND_ASSIGN(ObjectToObjectMetricBaseTemplate);
79 
85 
88 
90  using CoordinateRepresentationType = TInternalComputationValueType;
91 
93  using MeasureType = typename Superclass::MeasureType;
94 
96  using DerivativeType = typename Superclass::DerivativeType;
97  using DerivativeValueType = typename DerivativeType::ValueType;
98 
100  using ParametersType = typename Superclass::ParametersType;
101  using ParametersValueType = TInternalComputationValueType;
102 
106 
108  itkSetConstObjectMacro(FixedObject, ObjectType);
109  itkGetConstObjectMacro(FixedObject, ObjectType);
111 
113  itkSetConstObjectMacro(MovingObject, ObjectType);
114  itkGetConstObjectMacro(MovingObject, ObjectType);
116 
119 #if !defined(ITK_LEGACY_REMOVE)
120  // We need to expose the enum values at the class level
121  // for backwards compatibility
125 #endif
126 
133  itkSetMacro(GradientSource, GradientSourceType);
134 
139  itkGetConstMacro(GradientSource, GradientSourceType);
140 
143  bool
144  GetGradientSourceIncludesFixed() const;
145 
148  bool
149  GetGradientSourceIncludesMoving() const;
150 
155  virtual void
156  Initialize() = 0;
157 
160  using NumberOfParametersType = unsigned int;
161 
166  GetValue() const override = 0;
167 
171  virtual void
172  GetDerivative(DerivativeType &) const = 0;
173 
176  void
177  GetValueAndDerivative(MeasureType & value, DerivativeType & derivative) const override = 0;
178 
183  GetNumberOfParameters() const override = 0;
184  virtual NumberOfParametersType
185  GetNumberOfLocalParameters() const = 0;
187 
189  virtual void
190  SetParameters(ParametersType & params) = 0;
191 
193  virtual const ParametersType &
194  GetParameters() const = 0;
195 
198  virtual bool
199  HasLocalSupport() const = 0;
200 
207  virtual void
208  UpdateTransformParameters(const DerivativeType & derivative,
210 
217  GetCurrentValue() const;
218 
219  typedef enum
220  {
226  } MetricCategoryType;
227 
229  virtual MetricCategoryType
231  {
232  return UNKNOWN_METRIC;
233  }
234 
235 protected:
237  ~ObjectToObjectMetricBaseTemplate() override = default;
238 
239  void
240  PrintSelf(std::ostream & os, Indent indent) const override;
241 
245 
247 
250 };
251 
254 
256 extern ITKOptimizersv4_EXPORT std::ostream &
257  operator<<(std::ostream & out, const GradientSourceEnum value);
258 extern ITKOptimizersv4_EXPORT std::ostream &
259  operator<<(std::ostream & out, const MetricCategoryEnum value);
261 
262 } // end namespace itk
263 
264 #ifndef ITK_MANUAL_INSTANTIATION
265 # include "itkObjectToObjectMetricBase.hxx"
266 #endif
267 
268 #endif
itk::uint8_t
::uint8_t uint8_t
Definition: itkIntTypes.h:29
itk::OptimizerParameters
Class to hold and manage different parameter types used during optimization.
Definition: itkOptimizerParameters.h:34
itk::MetricCategoryEnum::MULTI_METRIC
itk::GradientSourceEnum
GradientSourceEnum
Definition: itkObjectToObjectMetricBase.h:32
itk::operator<<
std::ostream & operator<<(std::ostream &os, const Array< TValue > &arr)
Definition: itkArray.h:211
itk::ObjectToObjectMetricBaseTemplate< TParametersValueType >::NumberOfParametersType
unsigned int NumberOfParametersType
Definition: itkObjectToObjectMetricBase.h:160
itk::GradientSourceEnum::GRADIENT_SOURCE_MOVING
itk::ObjectToObjectMetricBaseTemplate::m_GradientSource
GradientSourceType m_GradientSource
Definition: itkObjectToObjectMetricBase.h:246
itk::GradientSourceEnum::GRADIENT_SOURCE_BOTH
itk::SmartPointer< Self >
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::MetricCategoryEnum::POINT_SET_METRIC
itk::ObjectToObjectMetricBaseTemplate< TParametersValueType >::DerivativeValueType
typename DerivativeType::ValueType DerivativeValueType
Definition: itkObjectToObjectMetricBase.h:97
itk::MetricCategoryEnum::IMAGE_METRIC
itkSingleValuedCostFunctionv4.h
itk::LightObject
Light weight base class for most itk classes.
Definition: itkLightObject.h:59
itk::ObjectToObjectMetricBaseTemplate< TParametersValueType >::CoordinateRepresentationType
TParametersValueType CoordinateRepresentationType
Definition: itkObjectToObjectMetricBase.h:90
itk::CostFunctionTemplate< TParametersValueType >::ParametersValueType
TParametersValueType ParametersValueType
Definition: itkCostFunction.h:52
itk::MetricCategoryEnum::UNKNOWN_METRIC
itk::ObjectToObjectMetricBaseTemplate
Base class for all object-to-object similarity metrics added in ITKv4.
Definition: itkObjectToObjectMetricBase.h:74
itk::ObjectToObjectMetricBaseTemplate::m_MovingObject
ObjectConstPointer m_MovingObject
Definition: itkObjectToObjectMetricBase.h:244
itk::ObjectToObjectMetricBaseTemplate::m_Value
MeasureType m_Value
Definition: itkObjectToObjectMetricBase.h:249
itk::SingleValuedCostFunctionv4Template
This class is a base for a CostFunction that returns a single value.
Definition: itkSingleValuedCostFunctionv4.h:49
itk::NumericTraits
Define additional traits for native types such as int or float.
Definition: itkNumericTraits.h:58
itk::ObjectToObjectMetricBaseTemplate< TParametersValueType >::MeasureType
typename Superclass::MeasureType MeasureType
Definition: itkObjectToObjectMetricBase.h:93
itk::ObjectToObjectMetricBaseTemplate::m_FixedObject
ObjectConstPointer m_FixedObject
Definition: itkObjectToObjectMetricBase.h:243
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkArray.h:26
itk::GradientSourceEnum::GRADIENT_SOURCE_FIXED
MetricCategoryEnum
itk::Object
Base class for most ITK classes.
Definition: itkObject.h:60
itkTransformBase.h
itk::ObjectToObjectMetricBaseTemplate< TParametersValueType >::ObjectConstPointer
typename ObjectType::ConstPointer ObjectConstPointer
Definition: itkObjectToObjectMetricBase.h:105
GradientSourceEnum
itk::ObjectToObjectMetricBaseTemplate< TParametersValueType >::DerivativeType
typename Superclass::DerivativeType DerivativeType
Definition: itkObjectToObjectMetricBase.h:96
itk::MetricCategoryEnum::OBJECT_METRIC
itk::ObjectToObjectMetricBaseTemplate::GetMetricCategory
virtual MetricCategoryType GetMetricCategory() const
Definition: itkObjectToObjectMetricBase.h:230