ITK  6.0.0
Insight Toolkit
itkSingleValuedVnlCostFunctionAdaptorv4.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 itkSingleValuedVnlCostFunctionAdaptorv4_h
19 #define itkSingleValuedVnlCostFunctionAdaptorv4_h
20 
21 #include "itkOptimizerParameters.h"
23 #include "vnl/vnl_cost_function.h"
24 
25 namespace itk
26 {
37 class SingleValuedVnlCostFunctionAdaptorv4 : public vnl_cost_function
38 {
39 public:
40 
42  using InternalMeasureType = double;
43 
45  using InternalParametersType = vnl_vector<InternalMeasureType>;
46 
48  using InternalDerivativeType = vnl_vector<InternalMeasureType>;
49 
52 
55 
58 
61 
63  SingleValuedVnlCostFunctionAdaptorv4(unsigned int spaceDimension);
64 
66  void
68  {
69  m_ObjectMetric = costFunction;
70  }
71 
75  {
76  return m_ObjectMetric;
77  }
78 
81  f(const InternalParametersType & inparameters) override;
82 
84  void
85  gradf(const InternalParametersType & inparameters, InternalDerivativeType & gradient) override;
86 
88  void
90 
92  void
94 
96  void
97  SetScales(const ScalesType & scales);
98 
103  unsigned long
104  AddObserver(const EventObject & event, Command *) const;
105 
110  itkGetConstReferenceMacro(CachedValue, MeasureType);
111 
112  itkGetConstReferenceMacro(CachedDerivative, DerivativeType);
113 
115  const ParametersType &
117 
118 protected:
121  void
122  ReportIteration(const EventObject & event) const;
123 
124 private:
129 
132 
133 }; // end of Class CostFunction
134 
135 } // end namespace itk
136 
137 #endif
itk::SingleValuedVnlCostFunctionAdaptorv4::compute
void compute(const InternalParametersType &x, InternalMeasureType *fun, InternalDerivativeType *g) override
itk::OptimizerParameters< TInternalComputationValueType >
itk::SingleValuedVnlCostFunctionAdaptorv4::m_CachedValue
MeasureType m_CachedValue
Definition: itkSingleValuedVnlCostFunctionAdaptorv4.h:130
itk::SingleValuedVnlCostFunctionAdaptorv4::AddObserver
unsigned long AddObserver(const EventObject &event, Command *) const
itk::SingleValuedVnlCostFunctionAdaptorv4::m_Reporter
Object::Pointer m_Reporter
Definition: itkSingleValuedVnlCostFunctionAdaptorv4.h:128
itk::SingleValuedVnlCostFunctionAdaptorv4::m_CachedDerivative
DerivativeType m_CachedDerivative
Definition: itkSingleValuedVnlCostFunctionAdaptorv4.h:131
itk::SingleValuedVnlCostFunctionAdaptorv4::m_Scales
ScalesType m_Scales
Definition: itkSingleValuedVnlCostFunctionAdaptorv4.h:127
itk::SingleValuedVnlCostFunctionAdaptorv4::InternalDerivativeType
vnl_vector< InternalMeasureType > InternalDerivativeType
Definition: itkSingleValuedVnlCostFunctionAdaptorv4.h:48
itk::SmartPointer< Self >
itk::SingleValuedVnlCostFunctionAdaptorv4::gradf
void gradf(const InternalParametersType &inparameters, InternalDerivativeType &gradient) override
itk::SingleValuedVnlCostFunctionAdaptorv4::DerivativeType
ObjectToObjectMetricBase::DerivativeType DerivativeType
Definition: itkSingleValuedVnlCostFunctionAdaptorv4.h:54
itk::SingleValuedVnlCostFunctionAdaptorv4::SetScales
void SetScales(const ScalesType &scales)
itk::SingleValuedVnlCostFunctionAdaptorv4::m_ObjectMetric
ObjectToObjectMetricBase::Pointer m_ObjectMetric
Definition: itkSingleValuedVnlCostFunctionAdaptorv4.h:125
itk::SingleValuedVnlCostFunctionAdaptorv4::ConvertExternalToInternalGradient
void ConvertExternalToInternalGradient(const DerivativeType &input, InternalDerivativeType &output) const
itk::SingleValuedCostFunctionv4Template::MeasureType
TInternalComputationValueType MeasureType
Definition: itkSingleValuedCostFunctionv4.h:67
itk::Command
Superclass for callback/observer methods.
Definition: itkCommand.h:45
itkOptimizerParameters.h
itk::SingleValuedVnlCostFunctionAdaptorv4::ReportIteration
void ReportIteration(const EventObject &event) const
itk::SingleValuedVnlCostFunctionAdaptorv4::ScalesType
OptimizerParameters< InternalMeasureType > ScalesType
Definition: itkSingleValuedVnlCostFunctionAdaptorv4.h:60
itk::SingleValuedVnlCostFunctionAdaptorv4::MeasureType
ObjectToObjectMetricBase::MeasureType MeasureType
Definition: itkSingleValuedVnlCostFunctionAdaptorv4.h:57
itk::SingleValuedVnlCostFunctionAdaptorv4::InternalParametersType
vnl_vector< InternalMeasureType > InternalParametersType
Definition: itkSingleValuedVnlCostFunctionAdaptorv4.h:45
itk::ObjectToObjectMetricBaseTemplate
Base class for all object-to-object similarity metrics added in ITKv4.
Definition: itkObjectToObjectMetricBase.h:90
itk::SingleValuedVnlCostFunctionAdaptorv4::GetCachedCurrentParameters
const ParametersType & GetCachedCurrentParameters() const
itk::SingleValuedCostFunctionv4Template::DerivativeType
Array< TInternalComputationValueType > DerivativeType
Definition: itkSingleValuedCostFunctionv4.h:75
itk::SingleValuedVnlCostFunctionAdaptorv4::InternalMeasureType
double InternalMeasureType
Definition: itkSingleValuedVnlCostFunctionAdaptorv4.h:42
itkObjectToObjectMetricBase.h
itk::SingleValuedVnlCostFunctionAdaptorv4
This class is an Adaptor that allows to pass itk::ObjectToObjectMetricBase objects to vnl_optimizers ...
Definition: itkSingleValuedVnlCostFunctionAdaptorv4.h:37
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnatomicalOrientation.h:29
itk::CostFunctionTemplate::ParametersType
OptimizerParameters< TInternalComputationValueType > ParametersType
Definition: itkCostFunction.h:53
itk::SingleValuedVnlCostFunctionAdaptorv4::ParametersType
ObjectToObjectMetricBase::ParametersType ParametersType
Definition: itkSingleValuedVnlCostFunctionAdaptorv4.h:51
itk::SingleValuedVnlCostFunctionAdaptorv4::GetCostFunction
const ObjectToObjectMetricBase * GetCostFunction() const
Definition: itkSingleValuedVnlCostFunctionAdaptorv4.h:74
itk::Array< TInternalComputationValueType >
itk::SingleValuedVnlCostFunctionAdaptorv4::SingleValuedVnlCostFunctionAdaptorv4
SingleValuedVnlCostFunctionAdaptorv4(unsigned int spaceDimension)
itk::EventObject
Abstraction of the Events used to communicating among filters and with GUIs.
Definition: itkEventObject.h:58
itk::SingleValuedVnlCostFunctionAdaptorv4::SetCostFunction
void SetCostFunction(ObjectToObjectMetricBase *costFunction)
Definition: itkSingleValuedVnlCostFunctionAdaptorv4.h:67
itk::SingleValuedVnlCostFunctionAdaptorv4::m_ScalesInitialized
bool m_ScalesInitialized
Definition: itkSingleValuedVnlCostFunctionAdaptorv4.h:126
itk::SingleValuedVnlCostFunctionAdaptorv4::f
InternalMeasureType f(const InternalParametersType &inparameters) override