ITK  4.2.0
Insight Segmentation and Registration Toolkit
itkSingleValuedVnlCostFunctionAdaptor.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 __itkSingleValuedVnlCostFunctionAdaptor_h
19 #define __itkSingleValuedVnlCostFunctionAdaptor_h
20 
22 #include "vnl/vnl_cost_function.h"
23 
24 namespace itk
25 {
37  public vnl_cost_function
38 {
39 public:
40 
43 
45  typedef double InternalMeasureType;
46 
49 
52 
55 
58 
61 
63  SingleValuedVnlCostFunctionAdaptor(unsigned int spaceDimension);
64 
66  void SetCostFunction(SingleValuedCostFunction *costFunction)
67  { m_CostFunction = costFunction; }
68 
70  const SingleValuedCostFunction * GetCostFunction(void) const
71  { return m_CostFunction; }
72 
74  virtual InternalMeasureType f(const InternalParametersType & inparameters);
75 
77  virtual void gradf(const InternalParametersType & inparameters,
78  InternalDerivativeType & gradient);
79 
81  virtual void compute(const InternalParametersType & x,
82  InternalMeasureType *f,
83  InternalDerivativeType *g);
84 
86  void ConvertExternalToInternalGradient(
87  const DerivativeType & input,
88  InternalDerivativeType & output) const;
89 
91  void SetScales(const ScalesType & scales);
92 
101  void SetNegateCostFunction(bool value);
102 
103  bool GetNegateCostFunction() const;
104 
105  void NegateCostFunctionOn() { m_NegateCostFunction = true; }
106  void NegateCostFunctionOff() { m_NegateCostFunction = false; }
107 
112  unsigned long AddObserver(const EventObject & event, Command *) const;
113 
118  const MeasureType & GetCachedValue() const;
119 
120  const DerivativeType & GetCachedDerivative() const;
121 
122  const ParametersType & GetCachedCurrentParameters() const;
123 
124 protected:
125 
128  void ReportIteration(const EventObject & event) const;
129 
130 private:
131 
137 
141 }; // end of Class CostFunction
142 } // end namespace itk
143 
144 #endif
145