BalloonForce.h
1 /*
2  * Medical Image Registration ToolKit (MIRTK)
3  *
4  * Copyright 2013-2015 Imperial College London
5  * Copyright 2013-2015 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_BalloonForce_H
21 #define MIRTK_BalloonForce_H
22 
23 #include "mirtk/SurfaceForce.h"
24 
25 
26 namespace mirtk {
27 
28 
29 /**
30  * Balloon/inflation force
31  *
32  * The balloon force inflates the surface while inside the object and deflates
33  * it when outside the object assuming that the image intensities within the
34  * object are within a certain range. It is therefore also referred to as inflation
35  * force and is mainly used while the surface is not in the vicinity of an edge.
36  *
37  * McInerney & Terzopoulos, Topology adaptive deformable surfaces for medical
38  * image volume segmentation. IEEE Transactions on Medical Imaging, 18(10),
39  * 840–850. doi:10.1109/42.811261 (1999)
40  *
41  * This balloon force has also been used in
42  *
43  * Park et al., A non-self-intersecting adaptive deformable surface for complex
44  * boundary extraction from volumetric images. Computer & Graphics, 25, 421–440,
45  * (2001)
46  */
47 class BalloonForce : public SurfaceForce
48 {
49  mirtkEnergyTermMacro(BalloonForce, EM_BalloonForce);
50 
51  // ---------------------------------------------------------------------------
52  // Attributes
53 
54  /// Mask defining intensity values used for local intensity statistics
55  /// When not specified, the interior of the current surface is used.
56  mirtkPublicAggregateMacro(BinaryImage, ForegroundMask);
57 
58  /// Whether to deflate the surface inside the object
59  mirtkPublicAttributeMacro(bool, DeflateSurface);
60 
61  /// Lower global intensity threshold for inside region
62  mirtkPublicAttributeMacro(double, LowerIntensity);
63 
64  /// Upper global intensity threshold for inside regin
65  mirtkPublicAttributeMacro(double, UpperIntensity);
66 
67  /// Multiplier of intensity standard deviation for local lower intensity threshold
68  mirtkPublicAttributeMacro(double, LowerIntensitySigma);
69 
70  /// Multiplier of intensity standard deviation for local upper intensity threshold
71  mirtkPublicAttributeMacro(double, UpperIntensitySigma);
72 
73  /// Multiplier of standard deviation of foreground intensities
74  mirtkPublicAttributeMacro(double, ForegroundSigmaFactor);
75 
76  /// Multiplier of standard deviation of background intensities
77  mirtkPublicAttributeMacro(double, BackgroundSigmaFactor);
78 
79  /// Box window radius within which to compute local image intensity statistics
80  mirtkPublicAttributeMacro(double, Radius);
81 
82  /// Positive multiplicative factor in (0, 1] used to progressively reduce
83  /// the magnitude of the balloon force whenever its sign changes
84  mirtkPublicAttributeMacro(double, DampingFactor);
85 
86  /// Minimum magnitude threshold, once the magnitude falls below this threshold,
87  /// it is set to zero such that the node is no longer affected by this force
88  mirtkPublicAttributeMacro(double, MagnitudeThreshold);
89 
90  // ---------------------------------------------------------------------------
91  // Construction/Destruction
92 protected:
93 
94  /// Copy attributes of this class from another instance
95  void CopyAttributes(const BalloonForce &);
96 
97 public:
98 
99  /// Constructor
100  BalloonForce(const char * = "", double = 1.0);
101 
102  /// Copy constructor
103  BalloonForce(const BalloonForce &);
104 
105  /// Assignment operator
107 
108  /// Destructor
109  virtual ~BalloonForce();
110 
111  // ---------------------------------------------------------------------------
112  // Configuration
113 protected:
114 
115  /// Set parameter value from string
116  virtual bool SetWithoutPrefix(const char *, const char *);
117 
118 public:
119 
120  // Import other overloads
122 
123  /// Get parameter name/value pairs
124  virtual ParameterList Parameter() const;
125 
126  // ---------------------------------------------------------------------------
127  // Initialization
128 protected:
129 
130  /// Compute local intensity thresholds and/or background/foreground statistics
131  void ComputeLocalIntensityAttributes(bool, bool);
132 
133 public:
134 
135  /// Initialize external force once input and parameters have been set
136  virtual void Initialize();
137 
138  /// Update moving input points and internal state of force term
139  virtual void Update(bool = true);
140 
141  // ---------------------------------------------------------------------------
142  // Evaluation
143 protected:
144 
145  /// Evaluate external force
146  virtual void EvaluateGradient(double *, double, double);
147 
148 };
149 
150 
151 } // namespace mirtk
152 
153 #endif // MIRTK_BalloonForce_H
virtual void Update(bool=true)
Update moving input points and internal state of force term.
void ComputeLocalIntensityAttributes(bool, bool)
Compute local intensity thresholds and/or background/foreground statistics.
void CopyAttributes(const BalloonForce &)
Copy attributes of this class from another instance.
virtual void Initialize()
Initialize external force once input and parameters have been set.
Balloon/inflation force.
Definition: EnergyMeasure.h:70
Array< Pair< string, string > > ParameterList
Ordered list of parameter name/value pairs.
Definition: Object.h:38
BalloonForce & operator=(const BalloonForce &)
Assignment operator.
virtual void EvaluateGradient(double *, double, double)
Evaluate external force.
virtual ParameterList Parameter() const
Get parameter key/value as string map.
Definition: IOConfig.h:41
virtual ~BalloonForce()
Destructor.
virtual ParameterList Parameter() const
Get parameter name/value pairs.
virtual bool SetWithoutPrefix(const char *, const char *)
Set parameter value from string.
BalloonForce(const char *="", double=1.0)
Constructor.