ITK
4.1.0
Insight Segmentation and Registration Toolkit
|
00001 /*========================================================================= 00002 * 00003 * Copyright Insight Software Consortium 00004 * 00005 * Licensed under the Apache License, Version 2.0 (the "License"); 00006 * you may not use this file except in compliance with the License. 00007 * You may obtain a copy of the License at 00008 * 00009 * http://www.apache.org/licenses/LICENSE-2.0.txt 00010 * 00011 * Unless required by applicable law or agreed to in writing, software 00012 * distributed under the License is distributed on an "AS IS" BASIS, 00013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00014 * See the License for the specific language governing permissions and 00015 * limitations under the License. 00016 * 00017 *=========================================================================*/ 00018 #ifndef __itkNormalVectorDiffusionFunction_h 00019 #define __itkNormalVectorDiffusionFunction_h 00020 00021 #include "itkNormalVectorFunctionBase.h" 00022 #include "itkNumericTraits.h" 00023 #include <math.h> 00024 00025 namespace itk 00026 { 00059 template< class TSparseImageType > 00060 class ITK_EXPORT NormalVectorDiffusionFunction: 00061 public NormalVectorFunctionBase< TSparseImageType > 00062 { 00063 public: 00065 typedef NormalVectorDiffusionFunction Self; 00066 typedef NormalVectorFunctionBase< TSparseImageType > Superclass; 00067 typedef SmartPointer< Self > Pointer; 00068 typedef SmartPointer< const Self > ConstPointer; 00069 00071 itkTypeMacro(NormalVectorDiffusionFunction, NormalVectorFunctionBase); 00072 00074 itkStaticConstMacro(ImageDimension, unsigned int, Superclass::ImageDimension); 00075 00077 itkNewMacro(Self); 00078 00080 typedef typename Superclass::TimeStepType TimeStepType; 00081 typedef typename Superclass::RadiusType RadiusType; 00082 typedef typename Superclass::NeighborhoodType NeighborhoodType; 00083 typedef typename Superclass::NeighborhoodScalesType NeighborhoodScalesType; 00084 typedef typename Superclass::FloatOffsetType FloatOffsetType; 00085 typedef typename Superclass::IndexType IndexType; 00086 typedef typename Superclass::SparseImageType SparseImageType; 00087 typedef typename Superclass::NodeType NodeType; 00088 typedef typename Superclass::NodeValueType NodeValueType; 00089 typedef typename Superclass::NormalVectorType NormalVectorType; 00090 00095 void SetNormalProcessType(int npt) 00096 { m_NormalProcessType = npt; } 00097 00099 int GetNormalProcessType() const 00100 { return m_NormalProcessType; } 00101 00107 void SetConductanceParameter(NodeValueType cp) 00108 { 00109 m_ConductanceParameter = cp + static_cast< NodeValueType >( 0.001 ); 00110 // we add a minimum conductance to avoid divide by zero 00111 // can make this a parameter. 00112 m_FluxStopConstant = static_cast< NodeValueType > 00113 ( -1.0 / ( m_ConductanceParameter * m_ConductanceParameter ) ); 00114 } 00116 00118 NodeValueType GetConductanceParameter() const 00119 { return m_ConductanceParameter; } 00120 00122 NodeValueType GetFluxStopConstant() const 00123 { return m_FluxStopConstant; } 00124 00129 virtual void PrecomputeSparseUpdate(NeighborhoodType & it) const; 00130 00132 virtual NormalVectorType ComputeSparseUpdate(NeighborhoodType & neighborhood, 00133 void *globalData, 00134 const FloatOffsetType & offset) const; 00135 00136 protected: 00137 NormalVectorDiffusionFunction(); 00138 ~NormalVectorDiffusionFunction() {} 00139 void PrintSelf(std::ostream & os, Indent indent) const; 00140 00143 NodeValueType FluxStopFunction(const NodeValueType v) const 00144 { 00145 // the slow exp function could be replaced with a lookup table 00146 if ( v <= 0.0 ) { return NumericTraits< NodeValueType >::One; } 00147 else { return static_cast< NodeValueType >( vcl_exp(m_FluxStopConstant * v) ); } 00148 } 00150 00151 private: 00153 NodeValueType m_ConductanceParameter; 00154 00157 NodeValueType m_FluxStopConstant; 00158 00160 int m_NormalProcessType; 00161 00162 NormalVectorDiffusionFunction(const Self &); //purposely not implemented 00163 void operator=(const Self &); //purposely not implemented 00164 }; 00165 } // end namespace itk 00166 00167 #ifndef ITK_MANUAL_INSTANTIATION 00168 #include "itkNormalVectorDiffusionFunction.hxx" 00169 #endif 00170 00171 #endif 00172