ITK  5.4.0
Insight Toolkit
itkLevelSetFunction.h
Go to the documentation of this file.
1/*=========================================================================
2 *
3 * Copyright NumFOCUS
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 * https://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 itkLevelSetFunction_h
19#define itkLevelSetFunction_h
20
22#include "vnl/vnl_matrix_fixed.h"
23
24namespace itk
25{
65template <typename TImageType>
66class ITK_TEMPLATE_EXPORT LevelSetFunction : public FiniteDifferenceFunction<TImageType>
67{
68public:
69 ITK_DISALLOW_COPY_AND_MOVE(LevelSetFunction);
70
76
78 itkNewMacro(Self);
79
81 itkOverrideGetNameOfClassMacro(LevelSetFunction);
82
84 static constexpr unsigned int ImageDimension = Superclass::ImageDimension;
85
87 using TimeStepType = double;
88 using typename Superclass::ImageType;
89 using typename Superclass::PixelType;
91 using typename Superclass::PixelRealType;
92 using typename Superclass::RadiusType;
93 using typename Superclass::NeighborhoodType;
94 using typename Superclass::NeighborhoodScalesType;
95 using typename Superclass::FloatOffsetType;
96
98 // typedef
100
107 {
111
113 vnl_matrix_fixed<ScalarValueType, Self::ImageDimension, Self::ImageDimension> m_dxy;
114
116 ScalarValueType m_dx[Self::ImageDimension];
117
118 ScalarValueType m_dx_forward[Self::ImageDimension];
119 ScalarValueType m_dx_backward[Self::ImageDimension];
120
122 };
123
125 virtual VectorType
127 {
128 return m_ZeroVectorConstant;
129 }
130
133 virtual ScalarValueType
135 {
136 return ScalarValueType{};
137 }
138
141 virtual ScalarValueType
143 {
145 }
146
149 virtual ScalarValueType
151 {
153 }
154
156 virtual void
158 {
159 m_AdvectionWeight = a;
160 }
161 ScalarValueType
163 {
164 return m_AdvectionWeight;
165 }
169 virtual void
171 {
172 m_PropagationWeight = p;
173 }
174 ScalarValueType
176 {
177 return m_PropagationWeight;
178 }
182 virtual void
184 {
185 m_CurvatureWeight = c;
186 }
187 ScalarValueType
189 {
190 return m_CurvatureWeight;
191 }
195 void
197 {
198 m_LaplacianSmoothingWeight = c;
199 }
200 ScalarValueType
202 {
203 return m_LaplacianSmoothingWeight;
204 }
208 void
210 {
211 m_EpsilonMagnitude = e;
212 }
213 ScalarValueType
215 {
216 return m_EpsilonMagnitude;
217 }
221 PixelType
223 void * globalData,
224 const FloatOffsetType & = FloatOffsetType(0.0)) override;
225
233 ComputeGlobalTimeStep(void * GlobalData) const override;
234
242 void *
243 GetGlobalDataPointer() const override
244 {
245 auto * ans = new GlobalDataStruct();
246
247 ans->m_MaxAdvectionChange = ScalarValueType{};
248 ans->m_MaxPropagationChange = ScalarValueType{};
249 ans->m_MaxCurvatureChange = ScalarValueType{};
250 return ans;
251 }
252
256 virtual void
258
263 void
264 ReleaseGlobalDataPointer(void * GlobalData) const override
265 {
266 delete (GlobalDataStruct *)GlobalData;
267 }
268
270 virtual ScalarValueType
272
273 virtual ScalarValueType
275
276 virtual ScalarValueType
278
279 virtual ScalarValueType
281
283 void
285 {
286 m_UseMinimalCurvature = b;
287 }
288
289 bool
291 {
292 return m_UseMinimalCurvature;
293 }
294
295 void
297 {
298 this->SetUseMinimalCurvature(true);
299 }
300
301 void
303 {
304 this->SetUseMinimalCurvature(false);
305 }
306
311 static void
313 {
314 m_DT = n;
315 }
316
317 static double
319 {
320 return m_DT;
321 }
322
327 static void
329 {
330 m_WaveDT = n;
331 }
332
333 static double
335 {
336 return m_WaveDT;
337 }
338
339protected:
341 : m_EpsilonMagnitude(static_cast<ScalarValueType>(1.0e-5))
342 , m_AdvectionWeight(ScalarValueType{})
343 , m_PropagationWeight(ScalarValueType{})
344 , m_CurvatureWeight(ScalarValueType{})
345 , m_LaplacianSmoothingWeight(ScalarValueType{})
346 {}
347
348 ~LevelSetFunction() override = default;
349 void
350 PrintSelf(std::ostream & os, Indent indent) const override;
351
353 static double m_WaveDT;
354 static double m_DT;
355
357 std::slice x_slice[Self::ImageDimension];
358
360 OffsetValueType m_Center{ 0 };
361
363 OffsetValueType m_xStride[Self::ImageDimension]{};
364
365 bool m_UseMinimalCurvature{ false };
366
369 static VectorType
371
374
376 ScalarValueType m_EpsilonMagnitude{};
377
379 ScalarValueType m_AdvectionWeight{};
380
382 ScalarValueType m_PropagationWeight{};
383
385 ScalarValueType m_CurvatureWeight{};
386
388 ScalarValueType m_LaplacianSmoothingWeight{};
389};
390} // namespace itk
391
392#ifndef ITK_MANUAL_INSTANTIATION
393# include "itkLevelSetFunction.hxx"
394#endif
395
396#endif
Const version of NeighborhoodIterator, defining iteration of a local N-dimensional neighborhood of pi...
typename ImageType::PixelType PixelType
typename ConstNeighborhoodIterator< TImageType >::RadiusType RadiusType
Simulate a standard C array with copy semantics.
Definition: itkFixedArray.h:54
Control indentation during Print() invocation.
Definition: itkIndent.h:50
The LevelSetFunction class is a generic function object which can be used to create a level set metho...
virtual void Initialize(const RadiusType &r)
static double GetMaximumPropagationTimeStep()
virtual ScalarValueType ComputeMinimalCurvature(const NeighborhoodType &, const FloatOffsetType &, GlobalDataStruct *gd=0)
ScalarValueType GetAdvectionWeight() const
virtual ScalarValueType ComputeCurvatureTerm(const NeighborhoodType &, const FloatOffsetType &, GlobalDataStruct *gd=0)
ScalarValueType GetLaplacianSmoothingWeight() const
virtual void SetAdvectionWeight(const ScalarValueType a)
void ReleaseGlobalDataPointer(void *GlobalData) const override
void SetEpsilonMagnitude(const ScalarValueType e)
virtual VectorType AdvectionField(const NeighborhoodType &, const FloatOffsetType &, GlobalDataStruct *=0) const
virtual ScalarValueType PropagationSpeed(const NeighborhoodType &, const FloatOffsetType &, GlobalDataStruct *=0) const
virtual ScalarValueType CurvatureSpeed(const NeighborhoodType &, const FloatOffsetType &, GlobalDataStruct *=nullptr) const
~LevelSetFunction() override=default
static VectorType InitializeZeroVectorConstant()
static void SetMaximumPropagationTimeStep(double n)
PixelType ComputeUpdate(const NeighborhoodType &it, void *globalData, const FloatOffsetType &=FloatOffsetType(0.0)) override
static double GetMaximumCurvatureTimeStep()
ScalarValueType GetPropagationWeight() const
virtual ScalarValueType LaplacianSmoothingSpeed(const NeighborhoodType &, const FloatOffsetType &, GlobalDataStruct *=0) const
void * GetGlobalDataPointer() const override
virtual ScalarValueType Compute3DMinimalCurvature(const NeighborhoodType &, const FloatOffsetType &, GlobalDataStruct *gd=0)
void SetLaplacianSmoothingWeight(const ScalarValueType c)
void PrintSelf(std::ostream &os, Indent indent) const override
TimeStepType ComputeGlobalTimeStep(void *GlobalData) const override
ScalarValueType GetCurvatureWeight() const
static VectorType m_ZeroVectorConstant
ScalarValueType GetEpsilonMagnitude() const
virtual void SetPropagationWeight(const ScalarValueType p)
virtual ScalarValueType ComputeMeanCurvature(const NeighborhoodType &, const FloatOffsetType &, GlobalDataStruct *gd=0)
void SetUseMinimalCurvature(bool b)
bool GetUseMinimalCurvature() const
virtual void SetCurvatureWeight(const ScalarValueType c)
static void SetMaximumCurvatureTimeStep(double n)
Light weight base class for most itk classes.
A templated class holding a n-Dimensional vector.
Definition: itkVector.h:63
static constexpr double e
Definition: itkMath.h:56
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
long OffsetValueType
Definition: itkIntTypes.h:94
vnl_matrix_fixed< ScalarValueType, Self::ImageDimension, Self::ImageDimension > m_dxy