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: 2002/12/17 17:50:35 $
00007   Version:   $Revision: 1.10 $
00008 
00009   Copyright (c) 2002 Insight 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 
00027 namespace itk
00028 {
00069 template<class TInputImage, class TOutputImage>
00070 class ITK_EXPORT CannyEdgeDetectionImageFilter
00071   : public ImageToImageFilter<TInputImage, TOutputImage>
00072 {
00073 public:
00075   typedef CannyEdgeDetectionImageFilter    Self;
00076   typedef ImageToImageFilter<TInputImage, TOutputImage> Superclass;
00077    
00079   typedef TInputImage  InputImageType;
00080   typedef TOutputImage OutputImageType;
00081       
00083   typedef SmartPointer<Self>  Pointer;
00084   typedef SmartPointer<const Self>  ConstPointer;
00085 
00087   typedef typename TInputImage::PixelType  InputImagePixelType;
00088   typedef typename TOutputImage::PixelType  OutputImagePixelType;
00089 
00092   typedef ZeroFluxNeumannBoundaryCondition<OutputImageType>
00093   DefaultBoundaryConditionType;
00094 
00098   typedef ConstNeighborhoodIterator<OutputImageType,
00099     DefaultBoundaryConditionType> NeighborhoodType;
00100 
00102   itkNewMacro(Self);  
00103     
00105   typedef typename TOutputImage::RegionType OutputImageRegionType;
00106     
00108   itkTypeMacro(CannyEdgeDetectionImageFilter, ImageToImageFilter);
00109   
00111   itkStaticConstMacro(ImageDimension, unsigned int,
00112                       TInputImage::ImageDimension);
00113   
00115   itkSetVectorMacro(Variance, double, ImageDimension); 
00116   itkGetVectorMacro(Variance, const double, ImageDimension); 
00117   itkSetVectorMacro(MaximumError, double, ImageDimension); 
00118   itkGetVectorMacro(MaximumError, const double, ImageDimension);
00119   
00122   void SetVariance(const double v)
00123     {
00124       double vArray[ImageDimension];
00125       for (unsigned int i = 0; i<ImageDimension; ++i) { vArray[i] = v; }
00126       this->SetVariance(vArray);
00127     }
00128   
00131   void SetMaximumError(const double v)
00132     {
00133       double vArray[ImageDimension];
00134       for (unsigned int i = 0; i<ImageDimension; ++i) { vArray[i] = v; }
00135       this->SetMaximumError(vArray);
00136     }
00137   
00138   /* Set the Threshold value for detected edges. */
00139   itkSetMacro(Threshold, OutputImagePixelType );
00140   itkGetMacro(Threshold, OutputImagePixelType);
00141 
00142     /* Set the Thresholdvalue for detected edges. */
00143   itkSetMacro(OutsideValue, OutputImagePixelType);
00144   itkGetMacro(OutsideValue, OutputImagePixelType);
00145   
00153   virtual void GenerateInputRequestedRegion() throw(InvalidRequestedRegionError);
00154 
00155 protected:
00156   CannyEdgeDetectionImageFilter();
00157   CannyEdgeDetectionImageFilter(const Self&) {}
00158   void PrintSelf(std::ostream& os, Indent indent) const;
00159 
00160   void GenerateData();
00161 
00162 private:
00163   virtual ~CannyEdgeDetectionImageFilter(){};
00164 
00166   struct CannyThreadStruct
00167   {
00168     CannyEdgeDetectionImageFilter *Filter;
00169   };
00170 
00172   void AllocateUpdateBuffer();
00173 
00174 
00178   void Compute2ndDerivative();
00179 
00188   //  virtual
00189   //  int SplitUpdateContainer(int i, int num, ThreadRegionType& splitRegion);
00190 
00196   void ThreadedCompute2ndDerivative(const OutputImageRegionType&
00197                                     outputRegionForThread, int threadId);
00198 
00202   static ITK_THREAD_RETURN_TYPE
00203       Compute2ndDerivativeThreaderCallback( void * arg );
00204 
00208   OutputImagePixelType ComputeCannyEdge(const NeighborhoodType &it,
00209                                         void *globalData );
00210 
00215   void Compute2ndDerivativePos();
00216 
00222   void ThreadedCompute2ndDerivativePos(const OutputImageRegionType&
00223                                        outputRegionForThread, int threadId);
00224 
00228   static ITK_THREAD_RETURN_TYPE
00229   Compute2ndDerivativePosThreaderCallback( void *arg );
00230 
00232   double m_Variance[ImageDimension];
00233 
00236   double m_MaximumError[ImageDimension];  
00237 
00239   OutputImagePixelType m_Threshold;
00240 
00242   OutputImagePixelType m_OutsideValue;
00243 
00245   typename OutputImageType::Pointer  m_UpdateBuffer;
00246   typename OutputImageType::Pointer  m_UpdateBuffer1;
00247 
00250   DerivativeOperator<OutputImagePixelType,itkGetStaticConstMacro(ImageDimension)>
00251     m_ComputeCannyEdge1stDerivativeOper;
00252   DerivativeOperator<OutputImagePixelType,itkGetStaticConstMacro(ImageDimension)>
00253     m_ComputeCannyEdge2ndDerivativeOper;
00254 
00255   std::slice  m_ComputeCannyEdgeSlice[ImageDimension];
00256 
00257   unsigned long m_Stride[ImageDimension];
00258   unsigned long m_Center;
00259 };
00260 
00261 } //end of namespace itk
00262 
00263 #ifndef ITK_MANUAL_INSTANTIATION
00264 #include "itkCannyEdgeDetectionImageFilter.txx"
00265 #endif
00266   
00267 #endif
00268 

Generated at Fri May 21 01:14:30 2004 for ITK by doxygen 1.2.15 written by Dimitri van Heesch, © 1997-2000