ITK  4.2.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 <math.h>
24 
25 namespace itk
26 {
59 template< class TSparseImageType >
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 
99  int GetNormalProcessType() const
100  { return m_NormalProcessType; }
101 
107  void SetConductanceParameter(NodeValueType cp)
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 
118  NodeValueType GetConductanceParameter() const
119  { return m_ConductanceParameter; }
120 
122  NodeValueType GetFluxStopConstant() const
123  { return m_FluxStopConstant; }
124 
129  virtual void PrecomputeSparseUpdate(NeighborhoodType & it) const;
130 
132  virtual NormalVectorType ComputeSparseUpdate(NeighborhoodType & neighborhood,
133  void *globalData,
134  const FloatOffsetType & offset) const;
135 
136 protected:
139  void PrintSelf(std::ostream & os, Indent indent) const;
140 
143  NodeValueType FluxStopFunction(const NodeValueType v) const
144  {
145  // the slow exp function could be replaced with a lookup table
146  if ( v <= 0.0 ) { return NumericTraits< NodeValueType >::One; }
147  else { return static_cast< NodeValueType >( vcl_exp(m_FluxStopConstant * v) ); }
148  }
150 
151 private:
154 
158 
161 
162  NormalVectorDiffusionFunction(const Self &); //purposely not implemented
163  void operator=(const Self &); //purposely not implemented
164 };
165 } // end namespace itk
166 
167 #ifndef ITK_MANUAL_INSTANTIATION
168 #include "itkNormalVectorDiffusionFunction.hxx"
169 #endif
170 
171 #endif
172