ITK  5.0.0
Insight Segmentation and Registration Toolkit
itkSingleValuedVnlCostFunctionAdaptorv4.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 itkSingleValuedVnlCostFunctionAdaptorv4_h
19 #define itkSingleValuedVnlCostFunctionAdaptorv4_h
20 
21 #include "itkOptimizerParameters.h"
23 #include "vnl/vnl_cost_function.h"
24 
25 namespace itk
26 {
37  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 
67  {
68  m_ObjectMetric = costFunction;
69  }
70 
73  {
74  return m_ObjectMetric;
75  }
76 
78  InternalMeasureType f(const InternalParametersType & inparameters) override;
79 
81  void gradf(const InternalParametersType & inparameters, InternalDerivativeType & gradient) override;
82 
85 
87  void ConvertExternalToInternalGradient( const DerivativeType & input, InternalDerivativeType & output) const;
88 
90  void SetScales(const ScalesType & scales);
91 
96  unsigned long AddObserver(const EventObject & event, Command *) const;
97 
102  itkGetConstReferenceMacro(CachedValue, MeasureType);
103 
104  itkGetConstReferenceMacro(CachedDerivative, DerivativeType);
105 
108 
109 protected:
110 
113  void ReportIteration(const EventObject & event) const;
114 
115 private:
116 
121 
124 
125 }; // end of Class CostFunction
126 
127 } // end namespace itk
128 
129 #endif
InternalMeasureType f(const InternalParametersType &inparameters) override
SingleValuedVnlCostFunctionAdaptorv4(unsigned int spaceDimension)
void SetCostFunction(ObjectToObjectMetricBase *costFunction)
Base class for all object-to-object similarlity metrics added in ITKv4.
void ConvertExternalToInternalGradient(const DerivativeType &input, InternalDerivativeType &output) const
This class is an Adaptor that allows to pass itk::ObjectToObjectMetricBase objects to vnl_optimizers ...
void SetScales(const ScalesType &scales)
typename Superclass::MeasureType MeasureType
const ObjectToObjectMetricBase * GetCostFunction() const
void gradf(const InternalParametersType &inparameters, InternalDerivativeType &gradient) override
Abstraction of the Events used to communicating among filters and with GUIs.
unsigned long AddObserver(const EventObject &event, Command *) const
OptimizerParameters< InternalMeasureType > ScalesType
void compute(const InternalParametersType &x, InternalMeasureType *f, InternalDerivativeType *g) override
const ParametersType & GetCachedCurrentParameters() const
void ReportIteration(const EventObject &event) const
typename Superclass::DerivativeType DerivativeType
typename Superclass::ParametersType ParametersType
Superclass for callback/observer methods.
Definition: itkCommand.h:44