ITK  4.8.0
Insight Segmentation and Registration Toolkit
itkCannyEdgeDetectionRecursiveGaussianImageFilter.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Insight Segmentation & Registration Toolkit
4  Module: itkCannyEdgeDetectionRecursiveGaussianImageFilter.h
5  Language: C++
6  Date: $Date$
7  Version: $Revision$
8 
9  Copyright (c) Insight Software Consortium. All rights reserved.
10  See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
11 
12  This software is distributed WITHOUT ANY WARRANTY; without even
13  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14  PURPOSE. See the above copyright notices for more information.
15 
16 =========================================================================*/
17 #ifndef __itkCannyEdgeDetectionRecursiveGaussianImageFilter_h
18 #define __itkCannyEdgeDetectionRecursiveGaussianImageFilter_h
19 
20 #include "itkImageToImageFilter.h"
21 #include "itkImage.h"
22 #include "itkFixedArray.h"
25 #include "itkMultiplyImageFilter.h"
27 #include "itkMultiThreader.h"
28 #include "itkDerivativeOperator.h"
29 #include "itkSparseFieldLayer.h"
30 #include "itkObjectStore.h"
31 
32 
33 namespace itk
34 {
35 
36 
37 template <class TValueType>
38 class ListNode
39 {
40 public:
41  TValueType m_Value;
42 
43  ListNode *Next;
45 };
46 
47 
91 template<class TInputImage, class TOutputImage>
93  : public ImageToImageFilter<TInputImage, TOutputImage>
94 {
95 public:
99 
101  typedef TInputImage InputImageType;
102  typedef TOutputImage OutputImageType;
103 
107 
109  typedef typename TInputImage::PixelType InputImagePixelType;
110  typedef typename TOutputImage::PixelType OutputImagePixelType;
111  typedef typename TInputImage::IndexType IndexType;
112 
117 
122 
128 
133 
135  itkNewMacro(Self);
136 
138  typedef typename TOutputImage::RegionType OutputImageRegionType;
139 
142 
144  itkStaticConstMacro(ImageDimension, unsigned int,
145  TInputImage::ImageDimension);
146  itkStaticConstMacro(OutputImageDimension, unsigned int,
147  TOutputImage::ImageDimension);
149 
152 
154  void SetSigmaArray( const SigmaArrayType & sigmas );
155  void SetSigma( ScalarRealType sigma );
156  SigmaArrayType GetSigmaArray() const;
157  ScalarRealType GetSigma() const;
159 
160  /* Set the Threshold value for detected edges. */
162  {
163  this->m_Threshold = th;
164  this->m_UpperThreshold = m_Threshold;
165  this->m_LowerThreshold = m_Threshold/2.0;
166  itkLegacyReplaceBodyMacro(SetThreshold, 2.2, SetUpperThreshold);
167  }
168 
170  {
171  itkLegacyReplaceBodyMacro(GetThreshold, 2.2, GetUpperThreshold);
172  return this->m_Threshold;
173  }
174 
176  itkSetMacro(UpperThreshold, OutputImagePixelType );
177  itkGetMacro(UpperThreshold, OutputImagePixelType);
178 
179  itkSetMacro(LowerThreshold, OutputImagePixelType );
180  itkGetMacro(LowerThreshold, OutputImagePixelType);
181 
182  /* Set the Thresholdvalue for detected edges. */
183  itkSetMacro(OutsideValue, OutputImagePixelType);
184  itkGetMacro(OutsideValue, OutputImagePixelType);
185 
187  {
188  return this->m_MultiplyImageFilter->GetOutput();
189  }
190 
198  virtual void GenerateInputRequestedRegion() throw(InvalidRequestedRegionError);
199 
200 #ifdef ITK_USE_CONCEPT_CHECKING
201 
202  itkConceptMacro(InputHasNumericTraitsCheck,
204  itkConceptMacro(OutputHasNumericTraitsCheck,
206  itkConceptMacro(SameDimensionCheck,
208  itkConceptMacro(InputIsFloatingPointCheck,
210  itkConceptMacro(OutputIsFloatingPointCheck,
212 
214 #endif
215 
216 protected:
219  void PrintSelf(std::ostream& os, Indent indent) const;
220 
221  void GenerateData();
222 
223  typedef MultiplyImageFilter< OutputImageType,
225 
226 private:
228 
231  {
233  };
234 
236  void AllocateUpdateBuffer();
237 
239  void HysteresisThresholding();
240 
242  void FollowEdge(IndexType index);
243 
245  bool InBounds(IndexType index);
246 
247 
251  void Compute2ndDerivative();
252 
261  // virtual
262  // int SplitUpdateContainer(int i, int num, ThreadRegionType& splitRegion);
263 
269  void ThreadedCompute2ndDerivative(const OutputImageRegionType&
270  outputRegionForThread, int threadId);
271 
276  Compute2ndDerivativeThreaderCallback( void * arg );
277 
281  OutputImagePixelType ComputeCannyEdge(const NeighborhoodType &it,
282  void *globalData );
283 
288  void Compute2ndDerivativePos();
289 
295  void ThreadedCompute2ndDerivativePos(const OutputImageRegionType&
296  outputRegionForThread, int threadId);
297 
302  Compute2ndDerivativePosThreaderCallback( void *arg );
303 
306 
310 
312  OutputImagePixelType m_UpperThreshold; //should be float here?
313 
315  OutputImagePixelType m_LowerThreshold; //should be float here?
316 
319 
322 
324  typename OutputImageType::Pointer m_UpdateBuffer1;
325 
328 
332 
340 
341  std::slice m_ComputeCannyEdgeSlice[ImageDimension];
342 
343  unsigned long m_Stride[ImageDimension];
344  unsigned long m_Center;
345 
348 
349 };
350 
351 } //end of namespace itk
352 
353 #ifndef ITK_MANUAL_INSTANTIATION
354 #include "itkCannyEdgeDetectionRecursiveGaussianImageFilter.hxx"
355 #endif
356 
357 #endif
A function object that determines a neighborhood of values at an image boundary according to a Neuman...
MultiplyImageFilter< OutputImageType, OutputImageType, OutputImageType > MultiplyImageFilterType
DerivativeOperator< OutputImagePixelType, itkGetStaticConstMacro(ImageDimension)> m_ComputeCannyEdge1stDerivativeOper
SmoothingRecursiveGaussianImageFilter< InputImageType, OutputImageType > GaussianImageFilterType
FixedArray< double, itkGetStaticConstMacro(ImageDimension)> ArrayType
Base class for all process objects that output image data.
Const version of NeighborhoodIterator, defining iteration of a local N-dimensional neighborhood of pi...
#define ITK_THREAD_RETURN_TYPE
ConstNeighborhoodIterator< OutputImageType, DefaultBoundaryConditionType > NeighborhoodType
DerivativeOperator< OutputImagePixelType, itkGetStaticConstMacro(ImageDimension)> m_ComputeCannyEdge2ndDerivativeOper
Computes the smoothing of an image by convolution with the Gaussian kernels implemented as IIR filter...
NumericTraits< PixelType >::ScalarRealType ScalarRealType
Base class for filters that take an image as input and produce an image as output.
OutputImageType::RegionType OutputImageRegionType
Control indentation during Print() invocation.
Definition: itkIndent.h:49
Pixel-wise multiplication of two images.
TOutputImage OutputImageType
A very simple linked list that is used to manage nodes in a layer of a sparse field level-set solver...
#define itkConceptMacro(name, concept)
A specialized memory management object for allocating and destroying contiguous blocks of objects...
ZeroFluxNeumannBoundaryCondition< OutputImageType > DefaultBoundaryConditionType