ITK  4.13.0
Insight Segmentation and Registration Toolkit
itkNormalVectorDiffusionFunction.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 itkNormalVectorDiffusionFunction_h
19 #define itkNormalVectorDiffusionFunction_h
20 
22 #include "itkNumericTraits.h"
23 #include <cmath>
24 
25 namespace itk
26 {
59 template< typename TSparseImageType >
60 class ITK_TEMPLATE_EXPORT NormalVectorDiffusionFunction:
61  public NormalVectorFunctionBase< TSparseImageType >
62 {
63 public:
69 
72 
74  itkStaticConstMacro(ImageDimension, unsigned int, Superclass::ImageDimension);
75 
77  itkNewMacro(Self);
78 
80  typedef typename Superclass::TimeStepType TimeStepType;
85  typedef typename Superclass::IndexType IndexType;
86  typedef typename Superclass::SparseImageType SparseImageType;
87  typedef typename Superclass::NodeType NodeType;
89  typedef typename Superclass::NormalVectorType NormalVectorType;
90 
95  void SetNormalProcessType(int npt)
96  { m_NormalProcessType = npt; }
97 
100  { return m_NormalProcessType; }
101 
108  {
109  m_ConductanceParameter = cp + static_cast< NodeValueType >( 0.001 );
110  // we add a minimum conductance to avoid divide by zero
111  // can make this a parameter.
112  m_FluxStopConstant = static_cast< NodeValueType >
113  ( -1.0 / ( m_ConductanceParameter * m_ConductanceParameter ) );
114  }
116 
119  { return m_ConductanceParameter; }
120 
123  { return m_FluxStopConstant; }
124 
129  virtual void PrecomputeSparseUpdate(NeighborhoodType & it) const ITK_OVERRIDE;
130 
132  virtual NormalVectorType ComputeSparseUpdate(NeighborhoodType & neighborhood,
133  void *globalData,
134  const FloatOffsetType & offset) const ITK_OVERRIDE;
135 
136 protected:
139  void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE;
140 
144  {
145  // the slow exp function could be replaced with a lookup table
146  if ( v <= 0.0 ) { return NumericTraits< NodeValueType >::OneValue(); }
147  else { return static_cast< NodeValueType >( std::exp(m_FluxStopConstant * v) ); }
148  }
150 
151 private:
154 
158 
161 
162  ITK_DISALLOW_COPY_AND_ASSIGN(NormalVectorDiffusionFunction);
163 };
164 } // end namespace itk
165 
166 #ifndef ITK_MANUAL_INSTANTIATION
167 #include "itkNormalVectorDiffusionFunction.hxx"
168 #endif
169 
170 #endif
NormalVectorFunctionBase< TSparseImageType > Superclass
Light weight base class for most itk classes.
Superclass::NeighborhoodScalesType NeighborhoodScalesType
This class defines the common functionality for Sparse Image neighborhoods of unit vectors...
ConstNeighborhoodIterator< TSparseImageType >::RadiusType RadiusType
Const version of NeighborhoodIterator, defining iteration of a local N-dimensional neighborhood of pi...
NodeValueType FluxStopFunction(const NodeValueType v) const
This class defines all the necessary functionality for performing isotropic and anisotropic diffusion...
A templated class holding a n-Dimensional vector.
Definition: itkVector.h:62
Control indentation during Print() invocation.
Definition: itkIndent.h:49