ITK  4.6.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 
29 namespace itk
30 {
31 template< typename TValue >
32 class ListNode
33 {
34 public:
35  TValue m_Value;
36 
39 };
40 
85 template< typename TInputImage, typename TOutputImage >
87  public ImageToImageFilter< TInputImage, TOutputImage >
88 {
89 public:
93 
95  typedef TInputImage InputImageType;
96  typedef TOutputImage OutputImageType;
97 
101 
103  typedef typename TInputImage::PixelType InputImagePixelType;
104  typedef typename TOutputImage::PixelType OutputImagePixelType;
105  typedef typename TInputImage::IndexType IndexType;
107 
112 
118 
123 
125  itkNewMacro(Self);
126 
128  typedef typename TOutputImage::RegionType OutputImageRegionType;
129  typedef typename TInputImage::RegionType InputImageRegionType;
130 
133 
135  itkStaticConstMacro(ImageDimension, unsigned int,
136  TInputImage::ImageDimension);
137  itkStaticConstMacro(OutputImageDimension, unsigned int,
138  TOutputImage::ImageDimension);
140 
143 
145  itkSetMacro(Variance, ArrayType);
146  itkGetConstMacro(Variance, const ArrayType);
147  itkSetMacro(MaximumError, ArrayType);
148  itkGetConstMacro(MaximumError, const ArrayType);
150 
153  void SetVariance(const typename ArrayType::ValueType v)
154  {
155  for ( unsigned int i = 0; i < TInputImage::ImageDimension; i++ )
156  {
157  if ( m_Variance[i] != v )
158  {
159  m_Variance.Fill(v);
160  this->Modified();
161  break;
162  }
163  }
164  }
166 
169  void SetMaximumError(const typename ArrayType::ValueType v)
170  {
171  for ( unsigned int i = 0; i < TInputImage::ImageDimension; i++ )
172  {
173  if ( m_MaximumError[i] != v )
174  {
175  m_MaximumError.Fill(v);
176  this->Modified();
177  break;
178  }
179  }
180  }
182 
193  itkSetMacro(UpperThreshold, OutputImagePixelType);
194  itkGetConstMacro(UpperThreshold, OutputImagePixelType);
195 
196  itkSetMacro(LowerThreshold, OutputImagePixelType);
197  itkGetConstMacro(LowerThreshold, OutputImagePixelType);
198 
200  {
201  return this->m_MultiplyImageFilter->GetOutput();
202  }
203 
211  virtual void GenerateInputRequestedRegion();
212 
213 #ifdef ITK_USE_CONCEPT_CHECKING
214  // Begin concept checking
215  itkConceptMacro( InputHasNumericTraitsCheck,
217  itkConceptMacro( OutputHasNumericTraitsCheck,
219  itkConceptMacro( SameDimensionCheck,
221  itkConceptMacro( InputIsFloatingPointCheck,
223  itkConceptMacro( OutputIsFloatingPointCheck,
225  // End concept checking
226 #endif
227 
228 protected:
230  void PrintSelf(std::ostream & os, Indent indent) const;
231 
232  void GenerateData();
233 
238 
239 private:
240  CannyEdgeDetectionImageFilter(const Self &); //purposely not implemented
241  void operator=(const Self &); //purposely not implemented
242 
244 
247  {
249  };
250 
252  void AllocateUpdateBuffer();
253 
255  void HysteresisThresholding();
256 
258  void FollowEdge(IndexType index, const OutputImageType *multiplyImageFilterOutput);
259 
263  void Compute2ndDerivative();
264 
273  // virtual
274  // int SplitUpdateContainer(int i, int num, ThreadRegionType& splitRegion);
275 
282  outputRegionForThread, ThreadIdType threadId);
283 
289 
294  void *globalData);
295 
301 
308  outputRegionForThread, ThreadIdType threadId);
309 
315 
318 
322 
324  OutputImagePixelType m_UpperThreshold; //should be float here?
325 
327  OutputImagePixelType m_LowerThreshold; //should be float here?
328 
330  typename OutputImageType::Pointer m_UpdateBuffer1;
331 
334 
338 
346 
348 
351 
354 
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
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
GaussianImageFilterType::Pointer m_GaussianFilter
static ITK_THREAD_RETURN_TYPE Compute2ndDerivativePosThreaderCallback(void *arg)
void PrintSelf(std::ostream &os, Indent indent) const
DiscreteGaussianImageFilter< InputImageType, OutputImageType > GaussianImageFilterType
MultiplyImageFilterType::Pointer m_MultiplyImageFilter
DerivativeOperator< OutputImagePixelType, itkGetStaticConstMacro(ImageDimension) > m_ComputeCannyEdge2ndDerivativeOper
virtual void GenerateInputRequestedRegion()
void FollowEdge(IndexType index, const OutputImageType *multiplyImageFilterOutput)
void ThreadedCompute2ndDerivative(const OutputImageRegionType &outputRegionForThread, ThreadIdType threadId)
ZeroFluxNeumannBoundaryCondition< OutputImageType > DefaultBoundaryConditionType
OutputImageType::PixelType OutputImagePixelType
virtual void Modified() const
MultiplyImageFilter< OutputImageType, OutputImageType, OutputImageType > MultiplyImageFilterType
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...
unsigned int ThreadIdType
Definition: itkIntTypes.h:159
This filter is an implementation of a Canny edge detector for scalar-valued images.