ITK  4.4.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< class TImageType >
66 class ITK_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 
125  virtual VectorType AdvectionField(const NeighborhoodType &,
126  const FloatOffsetType &, GlobalDataStruct * = 0) const
127  { return m_ZeroVectorConstant; }
128 
131  virtual ScalarValueType PropagationSpeed(
132  const NeighborhoodType &,
133  const FloatOffsetType &, GlobalDataStruct * = 0) const
135 
138  virtual ScalarValueType CurvatureSpeed(const NeighborhoodType &,
139  const FloatOffsetType &, GlobalDataStruct * = 0
140  ) const
142 
145  virtual ScalarValueType LaplacianSmoothingSpeed(
146  const NeighborhoodType &,
147  const FloatOffsetType &, GlobalDataStruct * = 0) const
149 
151  virtual void SetAdvectionWeight(const ScalarValueType a)
152  { m_AdvectionWeight = a; }
153  ScalarValueType GetAdvectionWeight() const
154  { return m_AdvectionWeight; }
156 
158  virtual void SetPropagationWeight(const ScalarValueType p)
159  { m_PropagationWeight = p; }
160  ScalarValueType GetPropagationWeight() const
161  { return m_PropagationWeight; }
163 
165  virtual void SetCurvatureWeight(const ScalarValueType c)
166  { m_CurvatureWeight = c; }
167  ScalarValueType GetCurvatureWeight() const
168  { return m_CurvatureWeight; }
170 
172  void SetLaplacianSmoothingWeight(const ScalarValueType c)
173  { m_LaplacianSmoothingWeight = c; }
174  ScalarValueType GetLaplacianSmoothingWeight() const
175  { return m_LaplacianSmoothingWeight; }
177 
179  void SetEpsilonMagnitude(const ScalarValueType e)
180  { m_EpsilonMagnitude = e; }
181  ScalarValueType GetEpsilonMagnitude() const
182  { return m_EpsilonMagnitude; }
184 
186  virtual PixelType ComputeUpdate( const NeighborhoodType & neighborhood,
187  void *globalData,
188  const FloatOffsetType & = FloatOffsetType(0.0) );
189 
196  virtual TimeStepType ComputeGlobalTimeStep(void *GlobalData) const;
197 
205  virtual void * GetGlobalDataPointer() const
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
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 
249  void SetUseMinimalCurvature(bool b)
250  {
251  m_UseMinimalCurvature = b;
252  }
253 
254  bool GetUseMinimalCurvature() const
255  {
256  return m_UseMinimalCurvature;
257  }
258 
259  void UseMinimalCurvatureOn()
260  {
261  this->SetUseMinimalCurvature(true);
262  }
263 
264  void UseMinimalCurvatureOff()
265  {
266  this->SetUseMinimalCurvature(false);
267  }
268 
273  static void SetMaximumCurvatureTimeStep(double n)
274  {
275  m_DT = n;
276  }
277 
278  static double GetMaximumCurvatureTimeStep()
279  {
280  return m_DT;
281  }
282 
287  static void SetMaximumPropagationTimeStep(double n)
288  {
289  m_WaveDT = n;
290  }
291 
292  static double GetMaximumPropagationTimeStep()
293  {
294  return m_WaveDT;
295  }
296 
297 protected:
299  {
300  m_EpsilonMagnitude = static_cast< ScalarValueType >( 1.0e-5 );
301  m_AdvectionWeight = m_PropagationWeight =
302  m_CurvatureWeight = m_LaplacianSmoothingWeight =
304  m_UseMinimalCurvature = false;
305  }
306 
307  virtual ~LevelSetFunction() {}
308  void PrintSelf(std::ostream & s, Indent indent) const;
309 
311  static double m_WaveDT;
312  static double m_DT;
313 
315  std::slice x_slice[itkGetStaticConstMacro(ImageDimension)];
316 
319 
321  OffsetValueType m_xStride[itkGetStaticConstMacro(ImageDimension)];
322 
324 
327  static VectorType InitializeZeroVectorConstant();
328 
331 
334 
337 
340 
343 
346 
347 private:
348  LevelSetFunction(const Self &); //purposely not implemented
349  void operator=(const Self &); //purposely not implemented
350 };
351 } // namespace itk
352 
353 #ifndef ITK_MANUAL_INSTANTIATION
354 #include "itkLevelSetFunction.hxx"
355 #endif
356 
357 #endif
358