DistanceErrorFunction.h
1 /*
2  * Medical Image Registration ToolKit (MIRTK)
3  *
4  * Copyright 2013-2015 Imperial College London
5  * Copyright 2013-2015 Stefan Pszczolkowski Parraguez, Andreas Schuh
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19 
20 #ifndef MIRTK_DistanceErrorFunction_H
21 #define MIRTK_DistanceErrorFunction_H
22 
23 #include "mirtk/RadialErrorFunction.h"
24 #include "mirtk/Math.h"
25 
26 
27 namespace mirtk {
28 
29 
30 /**
31  * Euclidean distance registration error function
32  */
34 {
35  mirtkObjectMacro(DistanceErrorFunction);
36 
37 public:
38 
39  /// Constructor
41 
42  /// Copy constructor
44 
45  /// Destructor
47 
48  /// Copy construct a new instance
50  {
51  return new DistanceErrorFunction(*this);
52  }
53 
54  /// Type enumeration value
55  virtual TypeId Type() const
56  {
57  return Distance;
58  }
59 
60  /// Evaluate radial registration error
61  virtual double Value(double d) const
62  {
63  return sqrt(d);
64  }
65 
66  /// Evaluate derivative of radial registration error
67  virtual double Derivative(double d) const
68  {
69  return (d == .0 ? .0 : 0.5 / sqrt(d));
70  }
71 
72 };
73 
74 
75 } // namespace mirtk
76 
77 #endif // MIRTK_DistanceErrorFunction_H
virtual RadialErrorFunction * NewInstance() const
Copy construct a new instance.
TypeId
Enumeration of available error functions.
DistanceErrorFunction(const DistanceErrorFunction &)
Copy constructor.
Definition: IOConfig.h:41
virtual double Value(double d) const
Evaluate radial registration error.
virtual TypeId Type() const
Type enumeration value.
virtual double Derivative(double d) const
Evaluate derivative of radial registration error.