ITK  5.4.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 * https://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
25namespace itk
26{
59template <typename TSparseImageType>
60class ITK_TEMPLATE_EXPORT NormalVectorDiffusionFunction : public NormalVectorFunctionBase<TSparseImageType>
61{
62public:
63 ITK_DISALLOW_COPY_AND_MOVE(NormalVectorDiffusionFunction);
64
70
72 itkOverrideGetNameOfClassMacro(NormalVectorDiffusionFunction);
73
75 static constexpr unsigned int ImageDimension = Superclass::ImageDimension;
76
78 itkNewMacro(Self);
79
81 using typename Superclass::TimeStepType;
82 using typename Superclass::RadiusType;
83 using typename Superclass::NeighborhoodType;
85 using typename Superclass::FloatOffsetType;
86 using typename Superclass::IndexType;
87 using typename Superclass::SparseImageType;
88 using typename Superclass::NodeType;
89 using typename Superclass::NodeValueType;
90 using 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 }
125 NodeValueType
127 {
128 return m_ConductanceParameter;
129 }
130
132 NodeValueType
134 {
135 return m_FluxStopConstant;
136 }
137
142 void
144
147 ComputeSparseUpdate(NeighborhoodType & it, void * globalData, const FloatOffsetType & offset) const override;
148
149protected:
151 ~NormalVectorDiffusionFunction() override = default;
152 void
153 PrintSelf(std::ostream & os, Indent indent) const override;
154
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 }
172private:
174 NodeValueType m_ConductanceParameter{};
175
178 NodeValueType m_FluxStopConstant{};
179
181 int m_NormalProcessType{};
182};
183} // end namespace itk
184
185#ifndef ITK_MANUAL_INSTANTIATION
186# include "itkNormalVectorDiffusionFunction.hxx"
187#endif
188
189#endif
Const version of NeighborhoodIterator, defining iteration of a local N-dimensional neighborhood of pi...
typename ConstNeighborhoodIterator< TSparseImageType >::RadiusType RadiusType
Control indentation during Print() invocation.
Definition: itkIndent.h:50
Light weight base class for most itk classes.
This class defines all the necessary functionality for performing isotropic and anisotropic diffusion...
NodeValueType FluxStopFunction(const NodeValueType v) const
NormalVectorType ComputeSparseUpdate(NeighborhoodType &it, void *globalData, const FloatOffsetType &offset) const override
~NormalVectorDiffusionFunction() override=default
void PrecomputeSparseUpdate(NeighborhoodType &it) const override
void PrintSelf(std::ostream &os, Indent indent) const override
This class defines the common functionality for Sparse Image neighborhoods of unit vectors.
typename NodeType::NodeValueType NodeValueType
typename NodeType::NodeDataType NormalVectorType
A templated class holding a n-Dimensional vector.
Definition: itkVector.h:63
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....