ImplicitSurfaceDistance.h
1 /*
2  * Medical Image Registration ToolKit (MIRTK)
3  *
4  * Copyright 2013-2016 Imperial College London
5  * Copyright 2013-2016 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_ImplicitSurfaceDistance_H
21 #define MIRTK_ImplicitSurfaceDistance_H
22 
23 #include "mirtk/ImplicitSurfaceForce.h"
24 
25 
26 namespace mirtk {
27 
28 
29 /**
30  * Force attracting the surface towards a given implicit surface / object boundary
31  *
32  * This force term is similar to a BalloonForce with the implicit surface
33  * model given as input image. Unlike the balloon force, however, this force
34  * does not vanish for a node which is close to the implicit surface. A separate
35  * image edge force which takes over once a vertex is nearby an image edge is
36  * therefore not required. Moreover, the force vectors can be scaled by the
37  * estimated distance of a point to the given implicit surface. Points which are
38  * further away, thus move faster. When a point lies on the implicit surface,
39  * its force vanishes. As soon as it is displaced again, e.g., by a smoothness
40  * therm, it starts pulling the point back to the implicit surface again.
41  *
42  * The input _Image of the force term is the discrete distance function of the
43  * implicit surface, e.g., a signed Euclidean distance transform of a binary
44  * object mask.
45  */
47 {
49 
50  // ---------------------------------------------------------------------------
51  // Attributes
52 
53  /// (Transformed) force magnitude image
54  ///
55  /// By default, points move either with constant magnitude or with magnitude
56  /// proportional to the implicit surface distance. When this optional input
57  /// is given, the force magnitude is set equal to the respective magnitude
58  /// value evaluated at each point location.
59  mirtkPublicAggregateMacro(RegisteredImage, MagnitudeImage);
60 
61  /// Whether to divide magnitude of forces by maximum magnitude
62  mirtkPublicAttributeMacro(bool, NormalizeMagnitude);
63 
64  /// Whether to invert magnitude, i.e., move points with lower magnitude value
65  /// faster then points with positive magnitude value
66  mirtkPublicAttributeMacro(bool, InvertMagnitude);
67 
68  /// Minimum distance threshold used by distance to force magnitude map
69  mirtkPublicAttributeMacro(double, MinThreshold);
70 
71  /// Distance threshold used by distance to force magnitude map
72  mirtkPublicAttributeMacro(double, MaxThreshold);
73 
74  /// Copy attributes of this class from another instance
75  void CopyAttributes(const ImplicitSurfaceDistance &);
76 
77  // ---------------------------------------------------------------------------
78  // Construction/Destruction
79 public:
80 
81  /// Constructor
82  ImplicitSurfaceDistance(const char * = "", double = 1.0);
83 
84  /// Copy constructor
86 
87  /// Assignment operator
89 
90  /// Destructor
91  virtual ~ImplicitSurfaceDistance();
92 
93  /// Initialize force term once input and parameters have been set
94  virtual void Initialize();
95 
96  // ---------------------------------------------------------------------------
97  // Evaluation
98 
99  /// Update moving input points and internal state of force term
100  virtual void Update(bool = true);
101 
102 protected:
103 
104  /// Evaluate external force term
105  virtual double Evaluate();
106 
107  /// Evaluate external force
108  virtual void EvaluateGradient(double *, double, double);
109 
110  // ---------------------------------------------------------------------------
111  // Force magnitude
112 
113  /// Update force magnitude at surface points
114  void UpdateMagnitude();
115 
116 };
117 
118 
119 } // namespace mirtk
120 
121 #endif // MIRTK_ImplicitSurfaceDistance_H
ImplicitSurfaceDistance & operator=(const ImplicitSurfaceDistance &)
Assignment operator.
ImplicitSurfaceDistance(const char *="", double=1.0)
Constructor.
virtual void Update(bool=true)
Update moving input points and internal state of force term.
Implicit surface distance force.
Definition: EnergyMeasure.h:73
virtual ~ImplicitSurfaceDistance()
Destructor.
virtual void Initialize()
Initialize force term once input and parameters have been set.
Definition: IOConfig.h:41
virtual double Evaluate()
Evaluate external force term.
void UpdateMagnitude()
Update force magnitude at surface points.
virtual void EvaluateGradient(double *, double, double)
Evaluate external force.