ITK  4.13.0
Insight Segmentation and Registration Toolkit
itkLevelSetFunction.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 itkLevelSetFunction_h
19 #define itkLevelSetFunction_h
20 
22 #include "vnl/vnl_matrix_fixed.h"
23 
24 namespace itk
25 {
65 template< typename TImageType >
66 class ITK_TEMPLATE_EXPORT LevelSetFunction:
67  public FiniteDifferenceFunction< TImageType >
68 {
69 public:
75 
77  itkNewMacro(Self);
78 
81 
83  itkStaticConstMacro(ImageDimension, unsigned int, Superclass::ImageDimension);
84 
86  typedef double TimeStepType;
87  typedef typename Superclass::ImageType ImageType;
88  typedef typename Superclass::PixelType PixelType;
90  typedef typename Superclass::PixelRealType PixelRealType;
91  typedef typename Superclass::RadiusType RadiusType;
93  typedef typename Superclass::NeighborhoodScalesType NeighborhoodScalesType;
94  typedef typename Superclass::FloatOffsetType FloatOffsetType;
95 
97  // typedef
99 
109 
111  vnl_matrix_fixed< ScalarValueType,
112  itkGetStaticConstMacro(ImageDimension),
113  itkGetStaticConstMacro(ImageDimension) > m_dxy;
114 
116  ScalarValueType m_dx[itkGetStaticConstMacro(ImageDimension)];
117 
118  ScalarValueType m_dx_forward[itkGetStaticConstMacro(ImageDimension)];
119  ScalarValueType m_dx_backward[itkGetStaticConstMacro(ImageDimension)];
120 
122  };
123 
126  const FloatOffsetType &, GlobalDataStruct * = 0) const
127  { return m_ZeroVectorConstant; }
128 
132  const NeighborhoodType &,
133  const FloatOffsetType &, GlobalDataStruct * = 0) const
135 
139  const FloatOffsetType &, GlobalDataStruct * = 0
140  ) const
142 
146  const NeighborhoodType &,
147  const FloatOffsetType &, GlobalDataStruct * = 0) const
149 
151  virtual void SetAdvectionWeight(const ScalarValueType a)
152  { m_AdvectionWeight = a; }
154  { return m_AdvectionWeight; }
156 
158  virtual void SetPropagationWeight(const ScalarValueType p)
159  { m_PropagationWeight = p; }
161  { return m_PropagationWeight; }
163 
165  virtual void SetCurvatureWeight(const ScalarValueType c)
166  { m_CurvatureWeight = c; }
168  { return m_CurvatureWeight; }
170 
173  { m_LaplacianSmoothingWeight = c; }
175  { return m_LaplacianSmoothingWeight; }
177 
180  { m_EpsilonMagnitude = e; }
182  { return m_EpsilonMagnitude; }
184 
186  virtual PixelType ComputeUpdate( const NeighborhoodType & neighborhood,
187  void *globalData,
188  const FloatOffsetType & = FloatOffsetType(0.0) ) ITK_OVERRIDE;
189 
196  virtual TimeStepType ComputeGlobalTimeStep(void *GlobalData) const ITK_OVERRIDE;
197 
205  virtual void * GetGlobalDataPointer() const ITK_OVERRIDE
206  {
207  GlobalDataStruct *ans = new GlobalDataStruct();
208 
212  return ans;
213  }
214 
218  virtual void Initialize(const RadiusType & r);
219 
224  virtual void ReleaseGlobalDataPointer(void *GlobalData) const ITK_OVERRIDE
225  { delete (GlobalDataStruct *)GlobalData; }
226 
228  virtual ScalarValueType ComputeCurvatureTerm(const NeighborhoodType &,
229  const FloatOffsetType &,
230  GlobalDataStruct *gd = 0
231  );
232 
233  virtual ScalarValueType ComputeMeanCurvature(const NeighborhoodType &,
234  const FloatOffsetType &,
235  GlobalDataStruct *gd = 0
236  );
237 
238  virtual ScalarValueType ComputeMinimalCurvature(const NeighborhoodType &,
239  const FloatOffsetType &,
240  GlobalDataStruct *gd = 0
241  );
242 
243  virtual ScalarValueType Compute3DMinimalCurvature(const NeighborhoodType &,
244  const FloatOffsetType &,
245  GlobalDataStruct *gd = 0
246  );
247 
250  {
251  m_UseMinimalCurvature = b;
252  }
253 
255  {
256  return m_UseMinimalCurvature;
257  }
258 
260  {
261  this->SetUseMinimalCurvature(true);
262  }
263 
265  {
266  this->SetUseMinimalCurvature(false);
267  }
268 
273  static void SetMaximumCurvatureTimeStep(double n)
274  {
275  m_DT = n;
276  }
277 
279  {
280  return m_DT;
281  }
282 
287  static void SetMaximumPropagationTimeStep(double n)
288  {
289  m_WaveDT = n;
290  }
291 
293  {
294  return m_WaveDT;
295  }
296 
297 protected:
299  m_Center(0),
300  m_UseMinimalCurvature(false),
301  m_EpsilonMagnitude(static_cast< ScalarValueType >( 1.0e-5 )),
302  m_AdvectionWeight(NumericTraits< ScalarValueType >::ZeroValue()),
303  m_PropagationWeight(NumericTraits< ScalarValueType >::ZeroValue()),
304  m_CurvatureWeight(NumericTraits< ScalarValueType >::ZeroValue()),
305  m_LaplacianSmoothingWeight(NumericTraits< ScalarValueType >::ZeroValue())
306  {
307  }
308 
309  virtual ~LevelSetFunction() ITK_OVERRIDE {}
310  void PrintSelf(std::ostream & s, Indent indent) const ITK_OVERRIDE;
311 
313  static double m_WaveDT;
314  static double m_DT;
315 
317  std::slice x_slice[itkGetStaticConstMacro(ImageDimension)];
318 
321 
323  OffsetValueType m_xStride[itkGetStaticConstMacro(ImageDimension)];
324 
326 
329  static VectorType InitializeZeroVectorConstant();
330 
333 
336 
339 
342 
345 
348 
349 private:
350  ITK_DISALLOW_COPY_AND_ASSIGN(LevelSetFunction);
351 };
352 } // namespace itk
353 
354 #ifndef ITK_MANUAL_INSTANTIATION
355 #include "itkLevelSetFunction.hxx"
356 #endif
357 
358 #endif
static void SetMaximumCurvatureTimeStep(double n)
static VectorType m_ZeroVectorConstant
Superclass::RadiusType RadiusType
Light weight base class for most itk classes.
The LevelSetFunction class is a generic function object which can be used to create a level set metho...
virtual ~LevelSetFunction() override
Superclass::NeighborhoodType NeighborhoodType
Superclass::PixelType PixelType
signed long OffsetValueType
Definition: itkIntTypes.h:154
static double GetMaximumCurvatureTimeStep()
Superclass::FloatOffsetType FloatOffsetType
ScalarValueType GetEpsilonMagnitude() const
Superclass::ImageType ImageType
Const version of NeighborhoodIterator, defining iteration of a local N-dimensional neighborhood of pi...
vnl_matrix_fixed< ScalarValueType, itkGetStaticConstMacro(ImageDimension), itkGetStaticConstMacro(ImageDimension) > m_dxy
ScalarValueType m_AdvectionWeight
bool GetUseMinimalCurvature() const
virtual ScalarValueType PropagationSpeed(const NeighborhoodType &, const FloatOffsetType &, GlobalDataStruct *=0) const
virtual ScalarValueType LaplacianSmoothingSpeed(const NeighborhoodType &, const FloatOffsetType &, GlobalDataStruct *=0) const
Simulate a standard C array with copy semnatics.
Definition: itkFixedArray.h:50
ScalarValueType m_PropagationWeight
Superclass::NeighborhoodScalesType NeighborhoodScalesType
SmartPointer< Self > Pointer
static double GetMaximumPropagationTimeStep()
virtual void ReleaseGlobalDataPointer(void *GlobalData) const override
virtual ScalarValueType CurvatureSpeed(const NeighborhoodType &, const FloatOffsetType &, GlobalDataStruct *=0) const
A templated class holding a n-Dimensional vector.
Definition: itkVector.h:62
virtual void SetPropagationWeight(const ScalarValueType p)
ScalarValueType m_EpsilonMagnitude
ScalarValueType m_CurvatureWeight
Superclass::PixelRealType PixelRealType
ScalarValueType GetLaplacianSmoothingWeight() const
Control indentation during Print() invocation.
Definition: itkIndent.h:49
ScalarValueType GetAdvectionWeight() const
FixedArray< ScalarValueType, itkGetStaticConstMacro(ImageDimension) > VectorType
SmartPointer< const Self > ConstPointer
Define additional traits for native types such as int or float.
virtual void SetCurvatureWeight(const ScalarValueType c)
virtual void SetAdvectionWeight(const ScalarValueType a)
static ITK_CONSTEXPR_VAR double e
The base of the natural logarithm or Euler&#39;s number
Definition: itkMath.h:56
ScalarValueType GetCurvatureWeight() const
static void SetMaximumPropagationTimeStep(double n)
void SetLaplacianSmoothingWeight(const ScalarValueType c)
void SetUseMinimalCurvature(bool b)
void SetEpsilonMagnitude(const ScalarValueType e)
ScalarValueType GetPropagationWeight() const
virtual VectorType AdvectionField(const NeighborhoodType &, const FloatOffsetType &, GlobalDataStruct *=0) const
FiniteDifferenceFunction< TImageType > Superclass
ScalarValueType m_LaplacianSmoothingWeight