ITK  5.0.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 "itkMultiThreaderBase.h"
28 #include "itkDerivativeOperator.h"
29 #include "itkSparseFieldLayer.h"
30 #include "itkObjectStore.h"
31 
32 
33 namespace itk
34 {
36 
37 
38 template <typename TValueType>
39 class ListNode
40 {
41 public:
42  TValueType m_Value;
43 
44  ListNode *Next;
46 };
47 
48 
92 template<typename TInputImage, typename TOutputImage>
94  : public ImageToImageFilter<TInputImage, TOutputImage>
95 {
96 public:
100 
102  using InputImageType = TInputImage;
103  using OutputImageType = TOutputImage;
104 
108 
110  using InputImagePixelType = typename TInputImage::PixelType;
111  using OutputImagePixelType = typename TOutputImage::PixelType;
113 
118 
122 
128 
133 
135  itkNewMacro(Self);
136 
139 
142 
144  static constexpr unsigned int ImageDimension = TInputImage::ImageDimension;
145  static constexpr unsigned int OutputImageDimension = TOutputImage::ImageDimension;
146 
149 
151  void SetSigmaArray( const SigmaArrayType & sigmas );
152  void SetSigma( ScalarRealType sigma );
153  SigmaArrayType GetSigmaArray() const;
154  ScalarRealType GetSigma() const;
156 
157  /* Set the Threshold value for detected edges. */
159  {
160  this->m_Threshold = th;
161  this->m_UpperThreshold = m_Threshold;
162  this->m_LowerThreshold = m_Threshold/2.0;
163  itkLegacyReplaceBodyMacro(SetThreshold, 2.2, SetUpperThreshold);
164  }
165 
167  {
168  itkLegacyReplaceBodyMacro(GetThreshold, 2.2, GetUpperThreshold);
169  return this->m_Threshold;
170  }
171 
173  itkSetMacro(UpperThreshold, OutputImagePixelType );
174  itkGetMacro(UpperThreshold, OutputImagePixelType);
175 
176  itkSetMacro(LowerThreshold, OutputImagePixelType );
177  itkGetMacro(LowerThreshold, OutputImagePixelType);
178 
179  /* Set the Thresholdvalue for detected edges. */
180  itkSetMacro(OutsideValue, OutputImagePixelType);
181  itkGetMacro(OutsideValue, OutputImagePixelType);
182 
184  {
185  return this->m_MultiplyImageFilter->GetOutput();
186  }
187 
195  void GenerateInputRequestedRegion() throw(InvalidRequestedRegionError) override;
196 
197 #ifdef ITK_USE_CONCEPT_CHECKING
198 
199  itkConceptMacro(InputHasNumericTraitsCheck,
201  itkConceptMacro(OutputHasNumericTraitsCheck,
203  itkConceptMacro(SameDimensionCheck,
205  itkConceptMacro(InputIsFloatingPointCheck,
207  itkConceptMacro(OutputIsFloatingPointCheck,
209 
211 #endif
212 
213 protected:
216  void PrintSelf(std::ostream& os, Indent indent) const override;
217 
218  void GenerateData() override;
219 
220  using MultiplyImageFilterType = MultiplyImageFilter< OutputImageType,
222 
223 private:
225 
228  {
230  };
231 
233  void AllocateUpdateBuffer();
234 
236  void HysteresisThresholding();
237 
239  void FollowEdge(IndexType index);
240 
242  bool InBounds(IndexType index);
243 
244 
248  void Compute2ndDerivative();
249 
258  // virtual
259  // int SplitUpdateContainer(int i, int num, ThreadRegionType& splitRegion);
260 
266  void ThreadedCompute2ndDerivative(const OutputImageRegionType&
267  outputRegionForThread, int threadId);
268 
273  Compute2ndDerivativeThreaderCallback( void * arg );
274 
278  OutputImagePixelType ComputeCannyEdge(const NeighborhoodType &it,
279  void *globalData );
280 
285  void Compute2ndDerivativePos();
286 
292  void ThreadedCompute2ndDerivativePos(const OutputImageRegionType&
293  outputRegionForThread, int threadId);
294 
299  Compute2ndDerivativePosThreaderCallback( void *arg );
300 
303 
307 
309  OutputImagePixelType m_UpperThreshold; //should be float here?
310 
312  OutputImagePixelType m_LowerThreshold; //should be float here?
313 
316 
319 
321  typename OutputImageType::Pointer m_UpdateBuffer1;
322 
325 
329 
337 
338  std::slice m_ComputeCannyEdgeSlice[ImageDimension];
339 
340  unsigned long m_Stride[ImageDimension];
341  unsigned long m_Center;
342 
345 
346 };
347 
348 } //end of namespace itk
349 
350 #ifndef ITK_MANUAL_INSTANTIATION
351 #include "itkCannyEdgeDetectionRecursiveGaussianImageFilter.hxx"
352 #endif
353 
354 #endif
A function object that determines a neighborhood of values at an image boundary according to a Neuman...
DerivativeOperator< OutputImagePixelType, itkGetStaticConstMacro(ImageDimension)> m_ComputeCannyEdge1stDerivativeOper
typename NumericTraits< PixelType >::ScalarRealType ScalarRealType
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
Base class for all process objects that output image data.
Const version of NeighborhoodIterator, defining iteration of a local N-dimensional neighborhood of pi...
void ITK_THREAD_RETURN_TYPE
typename OutputImageType::PixelType OutputImagePixelType
typename InputImageType::PixelType InputImagePixelType
DerivativeOperator< OutputImagePixelType, itkGetStaticConstMacro(ImageDimension)> m_ComputeCannyEdge2ndDerivativeOper
typename OutputImageType::RegionType OutputImageRegionType
TOutputImage OutputImageType
Computes the smoothing of an image by convolution with the Gaussian kernels implemented as IIR filter...
A class for performing multithreaded execution.
Base class for filters that take an image as input and produce an image as output.
Control indentation during Print() invocation.
Definition: itkIndent.h:49
Pixel-wise multiplication of two images.
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...