Orfeo Toolbox  3.16
itkLevelSetFunction.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Insight Segmentation & Registration Toolkit
4  Module: $RCSfile: itkLevelSetFunction.h,v $
5  Language: C++
6  Date: $Date: 2009-11-24 02:27:27 $
7  Version: $Revision: 1.26 $
8 
9  Copyright (c) Insight Software Consortium. All rights reserved.
10  See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
11 
12  This software is distributed WITHOUT ANY WARRANTY; without even
13  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14  PURPOSE. See the above copyright notices for more information.
15 
16 =========================================================================*/
17 #ifndef __itkLevelSetFunction_h
18 #define __itkLevelSetFunction_h
19 
21 #include "vnl/vnl_matrix_fixed.h"
22 
23 namespace itk {
24 
63 template <class TImageType>
65  : public FiniteDifferenceFunction<TImageType>
66 {
67 public:
73 
75  itkNewMacro(Self);
76 
79 
81  itkStaticConstMacro(ImageDimension, unsigned int,Superclass::ImageDimension);
82 
84  typedef double TimeStepType;
85  typedef typename Superclass::ImageType ImageType;
86  typedef typename Superclass::PixelType PixelType;
88  typedef typename Superclass::PixelRealType PixelRealType;
89  typedef typename Superclass::RadiusType RadiusType;
90  typedef typename Superclass::NeighborhoodType NeighborhoodType;
91  typedef typename Superclass::NeighborhoodScalesType NeighborhoodScalesType;
92  typedef typename Superclass::FloatOffsetType FloatOffsetType;
93 
95  // typedef
97 
104  {
108 
110  vnl_matrix_fixed<ScalarValueType,
111  itkGetStaticConstMacro(ImageDimension),
112  itkGetStaticConstMacro(ImageDimension)> m_dxy;
113 
115  ScalarValueType m_dx[itkGetStaticConstMacro(ImageDimension)];
116 
117  ScalarValueType m_dx_forward[itkGetStaticConstMacro(ImageDimension)];
118  ScalarValueType m_dx_backward[itkGetStaticConstMacro(ImageDimension)];
119 
121  };
122 
124  virtual VectorType AdvectionField(const NeighborhoodType &,
125  const FloatOffsetType &, GlobalDataStruct * = 0) const
126  { return m_ZeroVectorConstant; }
127 
130  virtual ScalarValueType PropagationSpeed(
131  const NeighborhoodType& ,
132  const FloatOffsetType &, GlobalDataStruct * = 0 ) const
133  { return NumericTraits<ScalarValueType>::Zero; }
134 
137  virtual ScalarValueType CurvatureSpeed(const NeighborhoodType &,
138  const FloatOffsetType &, GlobalDataStruct * = 0
139  ) const
140  { return NumericTraits<ScalarValueType>::One; }
141 
144  virtual ScalarValueType LaplacianSmoothingSpeed(
145  const NeighborhoodType &,
146  const FloatOffsetType &, GlobalDataStruct * = 0) const
147  { return NumericTraits<ScalarValueType>::One; }
148 
150  virtual void SetAdvectionWeight(const ScalarValueType a)
151  { m_AdvectionWeight = a; }
152  ScalarValueType GetAdvectionWeight() const
153  { return m_AdvectionWeight; }
154 
156  virtual void SetPropagationWeight(const ScalarValueType p)
157  { m_PropagationWeight = p; }
158  ScalarValueType GetPropagationWeight() const
159  { return m_PropagationWeight; }
160 
162  virtual void SetCurvatureWeight(const ScalarValueType c)
163  { m_CurvatureWeight = c; }
164  ScalarValueType GetCurvatureWeight() const
165  { return m_CurvatureWeight; }
166 
168  void SetLaplacianSmoothingWeight(const ScalarValueType c)
169  { m_LaplacianSmoothingWeight = c; }
170  ScalarValueType GetLaplacianSmoothingWeight() const
171  { return m_LaplacianSmoothingWeight; }
172 
174  void SetEpsilonMagnitude(const ScalarValueType e)
175  { m_EpsilonMagnitude = e; }
176  ScalarValueType GetEpsilonMagnitude() const
177  { return m_EpsilonMagnitude; }
178 
180  virtual PixelType ComputeUpdate(const NeighborhoodType &neighborhood,
181  void *globalData,
182  const FloatOffsetType& = FloatOffsetType(0.0));
183 
190  virtual TimeStepType ComputeGlobalTimeStep(void *GlobalData) const;
191 
199  virtual void *GetGlobalDataPointer() const
200  {
201  GlobalDataStruct *ans = new GlobalDataStruct();
202  ans->m_MaxAdvectionChange = NumericTraits<ScalarValueType>::Zero;
203  ans->m_MaxPropagationChange = NumericTraits<ScalarValueType>::Zero;
204  ans->m_MaxCurvatureChange = NumericTraits<ScalarValueType>::Zero;
205  return ans;
206  }
207 
211  virtual void Initialize(const RadiusType &r);
212 
217  virtual void ReleaseGlobalDataPointer(void *GlobalData) const
218  { delete (GlobalDataStruct *) GlobalData; }
219 
221  virtual ScalarValueType ComputeCurvatureTerm(const NeighborhoodType &,
222  const FloatOffsetType &,
223  GlobalDataStruct *gd = 0
224  );
225  virtual ScalarValueType ComputeMeanCurvature(const NeighborhoodType &,
226  const FloatOffsetType &,
227  GlobalDataStruct *gd = 0
228  );
229 
230  virtual ScalarValueType ComputeMinimalCurvature(const NeighborhoodType &,
231  const FloatOffsetType &,
232  GlobalDataStruct *gd = 0
233  );
234 
235  virtual ScalarValueType Compute3DMinimalCurvature(const NeighborhoodType &,
236  const FloatOffsetType &,
237  GlobalDataStruct *gd = 0
238  );
239 
241  void SetUseMinimalCurvature( bool b )
242  {
243  m_UseMinimalCurvature = b;
244  }
245  bool GetUseMinimalCurvature() const
246  {
247  return m_UseMinimalCurvature;
248  }
249  void UseMinimalCurvatureOn()
250  {
251  this->SetUseMinimalCurvature(true);
252  }
253  void UseMinimalCurvatureOff()
254  {
255  this->SetUseMinimalCurvature(false);
256  }
257 
262  static void SetMaximumCurvatureTimeStep(double n)
263  {
264  m_DT = n;
265  }
266  static double GetMaximumCurvatureTimeStep()
267  {
268  return m_DT;
269  }
270 
275  static void SetMaximumPropagationTimeStep(double n)
276  {
277  m_WaveDT = n;
278  }
279  static double GetMaximumPropagationTimeStep()
280  {
281  return m_WaveDT;
282  }
283 
284 protected:
286  {
287  m_EpsilonMagnitude = static_cast<ScalarValueType>( 1.0e-5 );
288  m_AdvectionWeight = m_PropagationWeight
289  = m_CurvatureWeight = m_LaplacianSmoothingWeight
290  = NumericTraits<ScalarValueType>::Zero;
291  m_UseMinimalCurvature = false;
292  }
293  virtual ~LevelSetFunction() {}
294  void PrintSelf(std::ostream &s, Indent indent) const;
295 
297  static double m_WaveDT;
298  static double m_DT;
299 
301  std::slice x_slice[itkGetStaticConstMacro(ImageDimension)];
302 
304  ::size_t m_Center;
305 
307  ::size_t m_xStride[itkGetStaticConstMacro(ImageDimension)];
308 
310 
313  static VectorType InitializeZeroVectorConstant();
314 
317 
320 
323 
326 
329 
332 
333 private:
334  LevelSetFunction(const Self&); //purposely not implemented
335  void operator=(const Self&); //purposely not implemented
336 };
337 
338 } // namespace itk
339 
340 // Define instantiation macro for this template.
341 #define ITK_TEMPLATE_LevelSetFunction(_, EXPORT, x, y) namespace itk { \
342  _(1(class EXPORT LevelSetFunction< ITK_TEMPLATE_1 x >)) \
343  namespace Templates { typedef LevelSetFunction< ITK_TEMPLATE_1 x > \
344  LevelSetFunction##y; } \
345  }
346 
347 #if ITK_TEMPLATE_EXPLICIT
348 # include "Templates/itkLevelSetFunction+-.h"
349 #endif
350 
351 #if ITK_TEMPLATE_TXX
352 # include "itkLevelSetFunction.txx"
353 #endif
354 
355 #endif

Generated at Sat Feb 2 2013 23:50:59 for Orfeo Toolbox with doxygen 1.8.1.1