ITK  4.9.0
Insight Segmentation and Registration Toolkit
itkCannyEdgeDetectionImageFilter.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
18 #ifndef itkCannyEdgeDetectionImageFilter_h
19 #define itkCannyEdgeDetectionImageFilter_h
20 
23 #include "itkMultiplyImageFilter.h"
24 #include "itkMultiThreader.h"
25 #include "itkDerivativeOperator.h"
26 #include "itkSparseFieldLayer.h"
27 #include "itkObjectStore.h"
28 #include "itkMath.h"
29 
30 namespace itk
31 {
32 template< typename TValue >
33 class ListNode
34 {
35 public:
36  TValue m_Value;
37 
40 };
41 
86 template< typename TInputImage, typename TOutputImage >
88  public ImageToImageFilter< TInputImage, TOutputImage >
89 {
90 public:
94 
96  typedef TInputImage InputImageType;
97  typedef TOutputImage OutputImageType;
98 
102 
104  typedef typename TInputImage::PixelType InputImagePixelType;
105  typedef typename TOutputImage::PixelType OutputImagePixelType;
106  typedef typename TInputImage::IndexType IndexType;
108 
113 
119 
124 
126  itkNewMacro(Self);
127 
129  typedef typename TOutputImage::RegionType OutputImageRegionType;
130  typedef typename TInputImage::RegionType InputImageRegionType;
131 
134 
136  itkStaticConstMacro(ImageDimension, unsigned int,
137  TInputImage::ImageDimension);
138  itkStaticConstMacro(OutputImageDimension, unsigned int,
139  TOutputImage::ImageDimension);
141 
144 
146  itkSetMacro(Variance, ArrayType);
147  itkGetConstMacro(Variance, const ArrayType);
148  itkSetMacro(MaximumError, ArrayType);
149  itkGetConstMacro(MaximumError, const ArrayType);
151 
154  void SetVariance(const typename ArrayType::ValueType v)
155  {
156  for ( unsigned int i = 0; i < TInputImage::ImageDimension; i++ )
157  {
158  if ( Math::NotExactlyEquals(m_Variance[i], v) )
159  {
160  m_Variance.Fill(v);
161  this->Modified();
162  break;
163  }
164  }
165  }
167 
170  void SetMaximumError(const typename ArrayType::ValueType v)
171  {
172  for ( unsigned int i = 0; i < TInputImage::ImageDimension; i++ )
173  {
175  {
176  m_MaximumError.Fill(v);
177  this->Modified();
178  break;
179  }
180  }
181  }
183 
194  itkSetMacro(UpperThreshold, OutputImagePixelType);
195  itkGetConstMacro(UpperThreshold, OutputImagePixelType);
196 
197  itkSetMacro(LowerThreshold, OutputImagePixelType);
198  itkGetConstMacro(LowerThreshold, OutputImagePixelType);
199 
201  {
202  return this->m_MultiplyImageFilter->GetOutput();
203  }
204 
212  virtual void GenerateInputRequestedRegion() ITK_OVERRIDE;
213 
214 #ifdef ITK_USE_CONCEPT_CHECKING
215  // Begin concept checking
216  itkConceptMacro( InputHasNumericTraitsCheck,
218  itkConceptMacro( OutputHasNumericTraitsCheck,
220  itkConceptMacro( SameDimensionCheck,
222  itkConceptMacro( InputIsFloatingPointCheck,
224  itkConceptMacro( OutputIsFloatingPointCheck,
226  // End concept checking
227 #endif
228 
229 protected:
231  void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE;
232 
233  void GenerateData() ITK_OVERRIDE;
234 
238  OutputImageType, OutputImageType > MultiplyImageFilterType;
239 
240 private:
241  CannyEdgeDetectionImageFilter(const Self &) ITK_DELETE_FUNCTION;
242  void operator=(const Self &) ITK_DELETE_FUNCTION;
243 
245 
248  {
250  };
251 
253  void AllocateUpdateBuffer();
254 
256  void HysteresisThresholding();
257 
259  void FollowEdge(IndexType index, const OutputImageType *multiplyImageFilterOutput);
260 
264  void Compute2ndDerivative();
265 
274  // virtual
275  // int SplitUpdateContainer(int i, int num, ThreadRegionType& splitRegion);
276 
283  outputRegionForThread, ThreadIdType threadId);
284 
290 
295  void *globalData);
296 
302 
309  outputRegionForThread, ThreadIdType threadId);
310 
316 
319 
323 
325  OutputImagePixelType m_UpperThreshold; //should be float here?
326 
328  OutputImagePixelType m_LowerThreshold; //should be float here?
329 
331  typename OutputImageType::Pointer m_UpdateBuffer1;
332 
335 
339 
347 
349 
352 
355 
357 };
358 } //end of namespace itk
359 
360 #ifndef ITK_MANUAL_INSTANTIATION
361 #include "itkCannyEdgeDetectionImageFilter.hxx"
362 #endif
363 
364 #endif
FixedArray< double, itkGetStaticConstMacro(ImageDimension) > ArrayType
A function object that determines a neighborhood of values at an image boundary according to a Neuman...
Light weight base class for most itk classes.
static ITK_THREAD_RETURN_TYPE Compute2ndDerivativeThreaderCallback(void *arg)
ConstNeighborhoodIterator< OutputImageType, DefaultBoundaryConditionType > NeighborhoodType
void SetVariance(const typename ArrayType::ValueType v)
DerivativeOperator< OutputImagePixelType, itkGetStaticConstMacro(ImageDimension) > m_ComputeCannyEdge1stDerivativeOper
void PrintSelf(std::ostream &os, Indent indent) const override
Const version of NeighborhoodIterator, defining iteration of a local N-dimensional neighborhood of pi...
unsigned long SizeValueType
Definition: itkIntTypes.h:143
#define ITK_THREAD_RETURN_TYPE
void Fill(const ValueType &)
ImageToImageFilter< TInputImage, TOutputImage > Superclass
typedef(Concept::HasNumericTraits< InputImagePixelType >) InputHasNumericTraitsCheck
GaussianImageFilterType::Pointer m_GaussianFilter
virtual void GenerateInputRequestedRegion() override
static ITK_THREAD_RETURN_TYPE Compute2ndDerivativePosThreaderCallback(void *arg)
MultiplyImageFilterType::Pointer m_MultiplyImageFilter
DerivativeOperator< OutputImagePixelType, itkGetStaticConstMacro(ImageDimension) > m_ComputeCannyEdge2ndDerivativeOper
void FollowEdge(IndexType index, const OutputImageType *multiplyImageFilterOutput)
void ThreadedCompute2ndDerivative(const OutputImageRegionType &outputRegionForThread, ThreadIdType threadId)
ZeroFluxNeumannBoundaryCondition< OutputImageType > DefaultBoundaryConditionType
OutputImageType::PixelType OutputImagePixelType
bool NotExactlyEquals(const TInput1 &x1, const TInput2 &x2)
Definition: itkMath.h:676
virtual void Modified() const
unsigned int ThreadIdType
Definition: itkIntTypes.h:159
OutputImagePixelType ComputeCannyEdge(const NeighborhoodType &it, void *globalData)
void ThreadedCompute2ndDerivativePos(const OutputImageRegionType &outputRegionForThread, ThreadIdType threadId)
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.
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...
void SetMaximumError(const typename ArrayType::ValueType v)
Blurs an image by separable convolution with discrete gaussian kernels. This filter performs Gaussian...
This filter is an implementation of a Canny edge detector for scalar-valued images.