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 __itkThresholdSegmentationLevelSetFunction_h 00019 #define __itkThresholdSegmentationLevelSetFunction_h 00020 00021 #include "itkSegmentationLevelSetFunction.h" 00022 #include "itkNumericTraits.h" 00023 namespace itk 00024 { 00055 template< class TImageType, class TFeatureImageType = TImageType > 00056 class ITK_EXPORT ThresholdSegmentationLevelSetFunction: 00057 public SegmentationLevelSetFunction< TImageType, TFeatureImageType > 00058 { 00059 public: 00061 typedef ThresholdSegmentationLevelSetFunction Self; 00062 typedef SegmentationLevelSetFunction< TImageType, TFeatureImageType > 00063 Superclass; 00064 typedef SmartPointer< Self > Pointer; 00065 typedef SmartPointer< const Self > ConstPointer; 00066 typedef TFeatureImageType FeatureImageType; 00067 00069 itkNewMacro(Self); 00070 00072 itkTypeMacro(ThresholdSegmentationLevelSetFunction, SegmentationLevelSetFunction); 00073 00075 typedef typename Superclass::ImageType ImageType; 00076 typedef typename Superclass::ScalarValueType ScalarValueType; 00077 typedef typename Superclass::FeatureScalarType FeatureScalarType; 00078 typedef typename Superclass::RadiusType RadiusType; 00079 00081 itkStaticConstMacro(ImageDimension, unsigned int, 00082 Superclass::ImageDimension); 00083 00085 void SetUpperThreshold(FeatureScalarType f) 00086 { m_UpperThreshold = f; } 00087 FeatureScalarType GetUpperThreshold() const 00088 { return m_UpperThreshold; } 00089 void SetLowerThreshold(FeatureScalarType f) 00090 { m_LowerThreshold = f; } 00091 FeatureScalarType GetLowerThreshold() const 00092 { return m_LowerThreshold; } 00094 00095 virtual void CalculateSpeedImage(); 00096 00097 virtual void Initialize(const RadiusType & r) 00098 { 00099 Superclass::Initialize(r); 00100 00101 this->SetAdvectionWeight(NumericTraits< ScalarValueType >::Zero); 00102 this->SetPropagationWeight(-1.0 * NumericTraits< ScalarValueType >::One); 00103 this->SetCurvatureWeight(NumericTraits< ScalarValueType >::One); 00104 } 00105 00108 void SetEdgeWeight(const ScalarValueType p) 00109 { 00110 m_EdgeWeight = p; 00111 } 00112 00113 ScalarValueType GetEdgeWeight() const 00114 { 00115 return m_EdgeWeight; 00116 } 00117 00121 void SetSmoothingConductance(const ScalarValueType p) 00122 { 00123 m_SmoothingConductance = p; 00124 } 00125 00126 ScalarValueType GetSmoothingConductance() const 00127 { 00128 return m_SmoothingConductance; 00129 } 00130 00134 void SetSmoothingIterations(const int p) 00135 { 00136 m_SmoothingIterations = p; 00137 } 00138 00139 int GetSmoothingIterations() const 00140 { 00141 return m_SmoothingIterations; 00142 } 00143 00147 void SetSmoothingTimeStep(const ScalarValueType i) 00148 { 00149 m_SmoothingTimeStep = i; 00150 } 00151 00152 ScalarValueType GetSmoothingTimeStep() const 00153 { 00154 return m_SmoothingTimeStep; 00155 } 00156 00157 protected: 00158 ThresholdSegmentationLevelSetFunction() 00159 { 00160 m_UpperThreshold = NumericTraits< FeatureScalarType >::max(); 00161 m_LowerThreshold = NumericTraits< FeatureScalarType >::NonpositiveMin(); 00162 this->SetAdvectionWeight(0.0); 00163 this->SetPropagationWeight(1.0); 00164 this->SetCurvatureWeight(1.0); 00165 this->SetSmoothingIterations(5); 00166 this->SetSmoothingConductance(0.8); 00167 this->SetSmoothingTimeStep(0.1); 00168 this->SetEdgeWeight(0.0); 00169 } 00170 00171 virtual ~ThresholdSegmentationLevelSetFunction(){} 00172 00173 ThresholdSegmentationLevelSetFunction(const Self &); //purposely not 00174 // implemented 00175 void operator=(const Self &); //purposely not 00176 // implemented 00177 00178 void PrintSelf(std::ostream & os, Indent indent) const 00179 { 00180 Superclass::PrintSelf(os, indent); 00181 os << indent << "UpperThreshold: " << m_UpperThreshold << std::endl; 00182 os << indent << "LowerThreshold: " << m_LowerThreshold << std::endl; 00183 os << indent << "EdgeWeight: " << m_EdgeWeight << std::endl; 00184 os << indent << "SmoothingTimeStep: " << m_SmoothingTimeStep << std::endl; 00185 os << indent << "SmoothingIterations: " << m_SmoothingIterations << std::endl; 00186 os << indent << "SmoothingConductance: " << m_SmoothingConductance << std::endl; 00187 } 00188 00189 FeatureScalarType m_UpperThreshold; 00190 FeatureScalarType m_LowerThreshold; 00191 ScalarValueType m_EdgeWeight; 00192 ScalarValueType m_SmoothingConductance; 00193 int m_SmoothingIterations; 00194 ScalarValueType m_SmoothingTimeStep; 00195 }; 00196 } // end namespace itk 00197 00198 #ifndef ITK_MANUAL_INSTANTIATION 00199 #include "itkThresholdSegmentationLevelSetFunction.hxx" 00200 #endif 00201 00202 #endif 00203