ITK  5.2.0
Insight Toolkit
itkNormalVectorDiffusionFunction.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  * 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 : public NormalVectorFunctionBase<TSparseImageType>
61 {
62 public:
63  ITK_DISALLOW_COPY_AND_MOVE(NormalVectorDiffusionFunction);
64 
70 
73 
75  static constexpr unsigned int ImageDimension = Superclass::ImageDimension;
76 
78  itkNewMacro(Self);
79 
86  using IndexType = typename Superclass::IndexType;
87  using SparseImageType = typename Superclass::SparseImageType;
88  using NodeType = typename Superclass::NodeType;
90  using NormalVectorType = typename Superclass::NormalVectorType;
91 
96  void
98  {
99  m_NormalProcessType = npt;
100  }
101 
103  int
105  {
106  return m_NormalProcessType;
107  }
108 
114  void
116  {
117  m_ConductanceParameter = cp + static_cast<NodeValueType>(0.001);
118  // we add a minimum conductance to avoid divide by zero
119  // can make this a parameter.
120  m_FluxStopConstant = static_cast<NodeValueType>(-1.0 / (m_ConductanceParameter * m_ConductanceParameter));
121  }
123 
125  NodeValueType
127  {
128  return m_ConductanceParameter;
129  }
130 
132  NodeValueType
134  {
135  return m_FluxStopConstant;
136  }
137 
142  void
143  PrecomputeSparseUpdate(NeighborhoodType & it) const override;
144 
146  NormalVectorType
147  ComputeSparseUpdate(NeighborhoodType & it, void * globalData, const FloatOffsetType & offset) const override;
148 
149 protected:
151  ~NormalVectorDiffusionFunction() override = default;
152  void
153  PrintSelf(std::ostream & os, Indent indent) const override;
154 
157  NodeValueType
159  {
160  // the slow exp function could be replaced with a lookup table
161  if (v <= 0.0)
162  {
164  }
165  else
166  {
167  return static_cast<NodeValueType>(std::exp(m_FluxStopConstant * v));
168  }
169  }
171 
172 private:
175 
179 
182 };
183 } // end namespace itk
184 
185 #ifndef ITK_MANUAL_INSTANTIATION
186 # include "itkNormalVectorDiffusionFunction.hxx"
187 #endif
188 
189 #endif
itk::FiniteDifferenceFunction< TSparseImageType >::RadiusType
typename ConstNeighborhoodIterator< TSparseImageType >::RadiusType RadiusType
Definition: itkFiniteDifferenceFunction.h:97
itk::FiniteDifferenceSparseImageFunction::FloatOffsetType
typename Superclass::FloatOffsetType FloatOffsetType
Definition: itkFiniteDifferenceSparseImageFunction.h:69
itk::NormalVectorDiffusionFunction::NodeValueType
typename Superclass::NodeValueType NodeValueType
Definition: itkNormalVectorDiffusionFunction.h:89
itkNormalVectorFunctionBase.h
itk::FiniteDifferenceSparseImageFunction::NeighborhoodType
typename Superclass::NeighborhoodType NeighborhoodType
Definition: itkFiniteDifferenceSparseImageFunction.h:68
itk::Vector
A templated class holding a n-Dimensional vector.
Definition: itkVector.h:62
itk::NormalVectorDiffusionFunction::SetConductanceParameter
void SetConductanceParameter(NodeValueType cp)
Definition: itkNormalVectorDiffusionFunction.h:115
itk::SmartPointer< Self >
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::NormalVectorFunctionBase
This class defines the common functionality for Sparse Image neighborhoods of unit vectors.
Definition: itkNormalVectorFunctionBase.h:52
itk::NormalVectorDiffusionFunction::FluxStopFunction
NodeValueType FluxStopFunction(const NodeValueType v) const
Definition: itkNormalVectorDiffusionFunction.h:158
itk::NormalVectorDiffusionFunction::GetNormalProcessType
int GetNormalProcessType() const
Definition: itkNormalVectorDiffusionFunction.h:104
itk::GTest::TypedefsAndConstructors::Dimension2::IndexType
ImageBaseType::IndexType IndexType
Definition: itkGTestTypedefsAndConstructors.h:50
itk::FiniteDifferenceSparseImageFunction::IndexType
typename SparseImageType::IndexType IndexType
Definition: itkFiniteDifferenceSparseImageFunction.h:73
itk::LightObject
Light weight base class for most itk classes.
Definition: itkLightObject.h:59
itk::NormalVectorDiffusionFunction::SetNormalProcessType
void SetNormalProcessType(int npt)
Definition: itkNormalVectorDiffusionFunction.h:97
itk::NumericTraits::OneValue
static T OneValue()
Definition: itkNumericTraits.h:156
itk::NormalVectorDiffusionFunction
This class defines all the necessary functionality for performing isotropic and anisotropic diffusion...
Definition: itkNormalVectorDiffusionFunction.h:60
itk::NormalVectorDiffusionFunction::m_ConductanceParameter
NodeValueType m_ConductanceParameter
Definition: itkNormalVectorDiffusionFunction.h:174
itk::FiniteDifferenceSparseImageFunction::TimeStepType
typename Superclass::TimeStepType TimeStepType
Definition: itkFiniteDifferenceSparseImageFunction.h:66
itk::NormalVectorDiffusionFunction::m_NormalProcessType
int m_NormalProcessType
Definition: itkNormalVectorDiffusionFunction.h:181
itk::NormalVectorFunctionBase::NodeValueType
typename NodeType::NodeValueType NodeValueType
Definition: itkNormalVectorFunctionBase.h:81
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itk::NormalVectorDiffusionFunction::GetFluxStopConstant
NodeValueType GetFluxStopConstant() const
Definition: itkNormalVectorDiffusionFunction.h:133
itk::ConstNeighborhoodIterator
Const version of NeighborhoodIterator, defining iteration of a local N-dimensional neighborhood of pi...
Definition: itkConstNeighborhoodIterator.h:51
itk::FiniteDifferenceSparseImageFunction::NodeType
typename SparseImageType::NodeType NodeType
Definition: itkFiniteDifferenceSparseImageFunction.h:76
itk::NormalVectorDiffusionFunction::NeighborhoodScalesType
typename Superclass::NeighborhoodScalesType NeighborhoodScalesType
Definition: itkNormalVectorDiffusionFunction.h:84
itk::FiniteDifferenceSparseImageFunction::RadiusType
typename Superclass::RadiusType RadiusType
Definition: itkFiniteDifferenceSparseImageFunction.h:67
itkNumericTraits.h
itk::NormalVectorDiffusionFunction::m_FluxStopConstant
NodeValueType m_FluxStopConstant
Definition: itkNormalVectorDiffusionFunction.h:178
itk::FiniteDifferenceFunction< TSparseImageType >
itk::NormalVectorDiffusionFunction::NormalVectorType
typename Superclass::NormalVectorType NormalVectorType
Definition: itkNormalVectorDiffusionFunction.h:90
itk::FiniteDifferenceSparseImageFunction::SparseImageType
typename Superclass::ImageType SparseImageType
Definition: itkFiniteDifferenceSparseImageFunction.h:70
itk::NormalVectorDiffusionFunction::GetConductanceParameter
NodeValueType GetConductanceParameter() const
Definition: itkNormalVectorDiffusionFunction.h:126
itk::FiniteDifferenceFunction< TSparseImageType >::TimeStepType
double TimeStepType
Definition: itkFiniteDifferenceFunction.h:90