ITK  4.6.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  typedef double InternalMeasureType;
43 
45  typedef vnl_vector< InternalMeasureType > InternalParametersType;
46 
48  typedef vnl_vector< InternalMeasureType > InternalDerivativeType;
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  virtual InternalMeasureType f(const InternalParametersType & inparameters) ITK_OVERRIDE;
79 
81  virtual void gradf(const InternalParametersType & inparameters, InternalDerivativeType & gradient) ITK_OVERRIDE;
82 
84  virtual void compute(const InternalParametersType & x, InternalMeasureType *f, InternalDerivativeType *g) ITK_OVERRIDE;
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
SingleValuedVnlCostFunctionAdaptorv4(unsigned int spaceDimension)
virtual void compute(const InternalParametersType &x, InternalMeasureType *f, InternalDerivativeType *g) ITK_OVERRIDE
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)
virtual InternalMeasureType f(const InternalParametersType &inparameters) ITK_OVERRIDE
Abstraction of the Events used to communicating among filters and with GUIs.
OptimizerParameters< InternalMeasureType > ScalesType
unsigned long AddObserver(const EventObject &event, Command *) const
virtual void gradf(const InternalParametersType &inparameters, InternalDerivativeType &gradient) ITK_OVERRIDE
const ParametersType & GetCachedCurrentParameters() const
void ReportIteration(const EventObject &event) const
const ObjectToObjectMetricBase * GetCostFunction(void) const
Superclass for callback/observer methods.
Definition: itkCommand.h:44