Main Page   Groups   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Concepts

itkCannyEdgeDetectionImageFilter.h

Go to the documentation of this file.
00001 /*========================================================================= 00002 00003 Program: Insight Segmentation & Registration Toolkit 00004 Module: $RCSfile: itkCannyEdgeDetectionImageFilter.h,v $ 00005 Language: C++ 00006 Date: $Date: 2003/09/10 14:28:45 $ 00007 Version: $Revision: 1.15 $ 00008 00009 Copyright (c) Insight Software Consortium. All rights reserved. 00010 See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. 00011 00012 This software is distributed WITHOUT ANY WARRANTY; without even 00013 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00014 PURPOSE. See the above copyright notices for more information. 00015 00016 =========================================================================*/ 00017 #ifndef __itkCannyEdgeDetectionImageFilter_h 00018 #define __itkCannyEdgeDetectionImageFilter_h 00019 00020 #include "itkImageToImageFilter.h" 00021 #include "itkImage.h" 00022 #include "itkConstNeighborhoodIterator.h" 00023 #include "itkZeroFluxNeumannBoundaryCondition.h" 00024 #include "itkMultiThreader.h" 00025 #include "itkDerivativeOperator.h" 00026 #include "itkSparseFieldLayer.h" 00027 #include "itkObjectStore.h" 00028 00029 00030 namespace itk 00031 { 00032 00033 00034 template <class TValueType> 00035 class ListNode 00036 { 00037 public: 00038 TValueType m_Value; 00039 ListNode *Next; 00040 ListNode *Previous; 00041 }; 00042 00043 00085 template<class TInputImage, class TOutputImage> 00086 class ITK_EXPORT CannyEdgeDetectionImageFilter 00087 : public ImageToImageFilter<TInputImage, TOutputImage> 00088 { 00089 public: 00091 typedef CannyEdgeDetectionImageFilter Self; 00092 typedef ImageToImageFilter<TInputImage, TOutputImage> Superclass; 00093 00095 typedef TInputImage InputImageType; 00096 typedef TOutputImage OutputImageType; 00097 00099 typedef SmartPointer<Self> Pointer; 00100 typedef SmartPointer<const Self> ConstPointer; 00101 00103 typedef typename TInputImage::PixelType InputImagePixelType; 00104 typedef typename TOutputImage::PixelType OutputImagePixelType; 00105 typedef typename TInputImage::IndexType IndexType; 00106 00109 typedef ZeroFluxNeumannBoundaryCondition<OutputImageType> 00110 DefaultBoundaryConditionType; 00111 00115 typedef ConstNeighborhoodIterator<OutputImageType, 00116 DefaultBoundaryConditionType> NeighborhoodType; 00117 00118 typedef ListNode<IndexType> ListNodeType; 00119 typedef ObjectStore<ListNodeType> ListNodeStorageType; 00120 typedef SparseFieldLayer<ListNodeType> ListType; 00121 typedef typename ListType::Pointer ListPointerType; 00122 00124 itkNewMacro(Self); 00125 00127 typedef typename TOutputImage::RegionType OutputImageRegionType; 00128 00130 itkTypeMacro(CannyEdgeDetectionImageFilter, ImageToImageFilter); 00131 00133 itkStaticConstMacro(ImageDimension, unsigned int, 00134 TInputImage::ImageDimension); 00135 00137 itkSetVectorMacro(Variance, double, ImageDimension); 00138 itkGetVectorMacro(Variance, const double, ImageDimension); 00139 itkSetVectorMacro(MaximumError, double, ImageDimension); 00140 itkGetVectorMacro(MaximumError, const double, ImageDimension); 00141 00144 void SetVariance(const double v) 00145 { 00146 double vArray[ImageDimension]; 00147 for (unsigned int i = 0; i<ImageDimension; ++i) { vArray[i] = v; } 00148 this->SetVariance(vArray); 00149 } 00150 00153 void SetMaximumError(const double v) 00154 { 00155 double vArray[ImageDimension]; 00156 for (unsigned int i = 0; i<ImageDimension; ++i) { vArray[i] = v; } 00157 this->SetMaximumError(vArray); 00158 } 00159 00160 /* Set the Threshold value for detected edges. */ 00161 itkSetMacro(Threshold, OutputImagePixelType ); 00162 itkGetMacro(Threshold, OutputImagePixelType); 00163 00165 //itkSetMacro(UpperThreshold, OutputImagePixelType ); 00166 //itkGetMacro(UpperThreshold, OutputImagePixelType); 00167 00168 //itkSetMacro(LowerThreshold, OutputImagePixelType ); 00169 //itkGetMacro(LowerThreshold, OutputImagePixelType); 00170 00171 /* Set the Thresholdvalue for detected edges. */ 00172 itkSetMacro(OutsideValue, OutputImagePixelType); 00173 itkGetMacro(OutsideValue, OutputImagePixelType); 00174 00182 virtual void GenerateInputRequestedRegion() throw(InvalidRequestedRegionError); 00183 00184 protected: 00185 CannyEdgeDetectionImageFilter(); 00186 CannyEdgeDetectionImageFilter(const Self&) {} 00187 void PrintSelf(std::ostream& os, Indent indent) const; 00188 00189 void GenerateData(); 00190 00191 private: 00192 virtual ~CannyEdgeDetectionImageFilter(){}; 00193 00195 struct CannyThreadStruct 00196 { 00197 CannyEdgeDetectionImageFilter *Filter; 00198 }; 00199 00201 void AllocateUpdateBuffer(); 00202 00204 void HysteresisThresholding(); 00205 00207 void FollowEdge(IndexType index); 00208 00210 bool InBounds(IndexType index); 00211 00212 00216 void Compute2ndDerivative(); 00217 00226 // virtual 00227 // int SplitUpdateContainer(int i, int num, ThreadRegionType& splitRegion); 00228 00234 void ThreadedCompute2ndDerivative(const OutputImageRegionType& 00235 outputRegionForThread, int threadId); 00236 00240 static ITK_THREAD_RETURN_TYPE 00241 Compute2ndDerivativeThreaderCallback( void * arg ); 00242 00246 OutputImagePixelType ComputeCannyEdge(const NeighborhoodType &it, 00247 void *globalData ); 00248 00253 void Compute2ndDerivativePos(); 00254 00260 void ThreadedCompute2ndDerivativePos(const OutputImageRegionType& 00261 outputRegionForThread, int threadId); 00262 00266 static ITK_THREAD_RETURN_TYPE 00267 Compute2ndDerivativePosThreaderCallback( void *arg ); 00268 00270 double m_Variance[ImageDimension]; 00271 00274 double m_MaximumError[ImageDimension]; 00275 00277 OutputImagePixelType m_UpperThreshold; //should be float here? 00278 00280 OutputImagePixelType m_LowerThreshold; //should be float here? 00281 00283 OutputImagePixelType m_Threshold; 00284 00286 OutputImagePixelType m_OutsideValue; 00287 00289 typename OutputImageType::Pointer m_UpdateBuffer; 00290 typename OutputImageType::Pointer m_UpdateBuffer1; 00291 00294 DerivativeOperator<OutputImagePixelType,itkGetStaticConstMacro(ImageDimension)> 00295 m_ComputeCannyEdge1stDerivativeOper; 00296 DerivativeOperator<OutputImagePixelType,itkGetStaticConstMacro(ImageDimension)> 00297 m_ComputeCannyEdge2ndDerivativeOper; 00298 00299 std::slice m_ComputeCannyEdgeSlice[ImageDimension]; 00300 00301 unsigned long m_Stride[ImageDimension]; 00302 unsigned long m_Center; 00303 00304 typename ListNodeStorageType::Pointer m_NodeStore; 00305 ListPointerType m_NodeList; 00306 00307 }; 00308 00309 } //end of namespace itk 00310 00311 #ifndef ITK_MANUAL_INSTANTIATION 00312 #include "itkCannyEdgeDetectionImageFilter.txx" 00313 #endif 00314 00315 #endif 00316

Generated at Sat Mar 31 02:15:24 2007 for ITK by doxygen 1.3.8 written by Dimitri van Heesch, © 1997-2000