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 __itkCannySegmentationLevelSetFunction_h 00019 #define __itkCannySegmentationLevelSetFunction_h 00020 00021 #include "itkSegmentationLevelSetFunction.h" 00022 #include "itkCastImageFilter.h" 00023 #include "itkCannyEdgeDetectionImageFilter.h" 00024 #include "itkDanielssonDistanceMapImageFilter.h" 00025 00026 namespace itk 00027 { 00034 template< class TImageType, class TFeatureImageType = TImageType > 00035 class ITK_EXPORT CannySegmentationLevelSetFunction: 00036 public SegmentationLevelSetFunction< TImageType, TFeatureImageType > 00037 { 00038 public: 00040 typedef CannySegmentationLevelSetFunction Self; 00041 typedef SegmentationLevelSetFunction< TImageType, TFeatureImageType > Superclass; 00042 typedef SmartPointer< Self > Pointer; 00043 typedef SmartPointer< const Self > ConstPointer; 00044 typedef TFeatureImageType FeatureImageType; 00045 00047 itkNewMacro(Self); 00048 00050 itkTypeMacro(CannySegmentationLevelSetFunction, SegmentationLevelSetFunction); 00051 00053 typedef typename Superclass::ImageType ImageType; 00054 typedef typename Superclass::ScalarValueType ScalarValueType; 00055 typedef typename Superclass::VectorImageType VectorImageType; 00056 typedef typename Superclass::FeatureScalarType FeatureScalarType; 00057 typedef typename Superclass::RadiusType RadiusType; 00058 00060 itkStaticConstMacro(ImageDimension, unsigned int, 00061 Superclass::ImageDimension); 00062 00064 void SetThreshold(ScalarValueType v) 00065 { m_Threshold = v; } 00066 ScalarValueType GetThreshold() const 00067 { return m_Threshold; } 00069 00071 void SetVariance(double v) 00072 { m_Variance = v; } 00073 double GetVariance() const 00074 { return m_Variance; } 00076 00079 virtual void CalculateSpeedImage(); 00080 00083 virtual void CalculateAdvectionImage(); 00084 00087 virtual void CalculateDistanceImage(); 00088 00089 virtual void Initialize(const RadiusType & r) 00090 { 00091 Superclass::Initialize(r); 00092 00093 this->SetAdvectionWeight(-1.0 * NumericTraits< ScalarValueType >::One); 00094 this->SetPropagationWeight(-1.0 * NumericTraits< ScalarValueType >::One); 00095 this->SetCurvatureWeight(NumericTraits< ScalarValueType >::One); 00096 } 00097 00098 ImageType * GetCannyImage() 00099 { return m_Canny->GetOutput(); } 00100 protected: 00101 CannySegmentationLevelSetFunction() 00102 { 00103 m_Variance = 0.0; 00104 m_Threshold = NumericTraits< ScalarValueType >::Zero; 00105 m_Caster = CastImageFilter< FeatureImageType, ImageType >::New(); 00106 m_Canny = CannyEdgeDetectionImageFilter< ImageType, ImageType >::New(); 00107 m_Distance = DanielssonDistanceMapImageFilter< ImageType, ImageType >::New(); 00108 } 00109 00110 virtual ~CannySegmentationLevelSetFunction() {} 00111 00112 CannySegmentationLevelSetFunction(const Self &); //purposely not implemented 00113 void operator=(const Self &); //purposely not implemented 00114 00115 private: 00116 ScalarValueType m_Variance; 00117 double m_Threshold; 00118 00119 typename CannyEdgeDetectionImageFilter< ImageType, ImageType >::Pointer m_Canny; 00120 00121 typename DanielssonDistanceMapImageFilter< ImageType, ImageType >::Pointer m_Distance; 00122 00123 typename CastImageFilter< FeatureImageType, ImageType >::Pointer m_Caster; 00124 00128 template <class DummyImagePointerType> 00129 void AssignCannyInput(typename FeatureImageType::Pointer &feature, 00130 DummyImagePointerType &) 00131 { 00132 m_Caster->SetInput(feature); 00133 m_Canny->SetInput( m_Caster->GetOutput() ); 00134 } 00135 00139 void AssignCannyInput(typename FeatureImageType::Pointer &feature, 00140 typename FeatureImageType::Pointer &) 00141 { 00142 m_Canny->SetInput(feature); 00143 } 00144 }; 00145 } // end namespace itk 00147 00148 #ifndef ITK_MANUAL_INSTANTIATION 00149 #include "itkCannySegmentationLevelSetFunction.hxx" 00150 #endif 00151 00152 #endif 00153