ITK  5.0.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:
64  ITK_DISALLOW_COPY_AND_ASSIGN(NormalVectorDiffusionFunction);
65 
71 
74 
76  static constexpr unsigned int ImageDimension = Superclass::ImageDimension;
77 
79  itkNewMacro(Self);
80 
87  using IndexType = typename Superclass::IndexType;
88  using SparseImageType = typename Superclass::SparseImageType;
89  using NodeType = typename Superclass::NodeType;
91  using NormalVectorType = typename Superclass::NormalVectorType;
92 
97  void SetNormalProcessType(int npt)
98  { m_NormalProcessType = npt; }
99 
102  { return m_NormalProcessType; }
103 
110  {
111  m_ConductanceParameter = cp + static_cast< NodeValueType >( 0.001 );
112  // we add a minimum conductance to avoid divide by zero
113  // can make this a parameter.
114  m_FluxStopConstant = static_cast< NodeValueType >
115  ( -1.0 / ( m_ConductanceParameter * m_ConductanceParameter ) );
116  }
118 
121  { return m_ConductanceParameter; }
122 
125  { return m_FluxStopConstant; }
126 
131  void PrecomputeSparseUpdate(NeighborhoodType & it) const override;
132 
134  NormalVectorType ComputeSparseUpdate(NeighborhoodType & neighborhood,
135  void *globalData,
136  const FloatOffsetType & offset) const override;
137 
138 protected:
140  ~NormalVectorDiffusionFunction() override = default;
141  void PrintSelf(std::ostream & os, Indent indent) const override;
142 
146  {
147  // the slow exp function could be replaced with a lookup table
148  if ( v <= 0.0 ) { return NumericTraits< NodeValueType >::OneValue(); }
149  else { return static_cast< NodeValueType >( std::exp(m_FluxStopConstant * v) ); }
150  }
152 
153 private:
156 
160 
163 
164 };
165 } // end namespace itk
166 
167 #ifndef ITK_MANUAL_INSTANTIATION
168 #include "itkNormalVectorDiffusionFunction.hxx"
169 #endif
170 
171 #endif
Light weight base class for most itk classes.
Define numeric traits for std::vector.
typename Superclass::NormalVectorType NormalVectorType
This class defines the common functionality for Sparse Image neighborhoods of unit vectors...
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...
typename ConstNeighborhoodIterator< TSparseImageType >::RadiusType RadiusType
A templated class holding a n-Dimensional vector.
Definition: itkVector.h:62
typename Superclass::NeighborhoodScalesType NeighborhoodScalesType
Control indentation during Print() invocation.
Definition: itkIndent.h:49
typename Superclass::NodeValueType NodeValueType
typename NodeType::NodeValueType NodeValueType