ITK  6.0.0
Insight Toolkit
itkCannyEdgeDetectionImageFilter.h
Go to the documentation of this file.
1/*=========================================================================
2 *
3 * Copyright NumFOCUS
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 * https://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
26#include "itkSparseFieldLayer.h"
27#include "itkObjectStore.h"
28#include "itkMath.h"
29
30namespace itk
31{
32template <typename TValue>
33class ITK_TEMPLATE_EXPORT ListNode
34{
35public:
36 TValue m_Value;
37
40};
41
87template <typename TInputImage, typename TOutputImage>
88class ITK_TEMPLATE_EXPORT CannyEdgeDetectionImageFilter : public ImageToImageFilter<TInputImage, TOutputImage>
89{
90public:
91 ITK_DISALLOW_COPY_AND_MOVE(CannyEdgeDetectionImageFilter);
92
96
98 using InputImageType = TInputImage;
99 using OutputImageType = TOutputImage;
100
104
106 using InputImagePixelType = typename TInputImage::PixelType;
107 using OutputImagePixelType = typename TOutputImage::PixelType;
110
114
119
124
126 itkNewMacro(Self);
127
131
133 itkOverrideGetNameOfClassMacro(CannyEdgeDetectionImageFilter);
134
136 static constexpr unsigned int ImageDimension = TInputImage::ImageDimension;
137 static constexpr unsigned int OutputImageDimension = TOutputImage::ImageDimension;
138
141
143 itkSetMacro(Variance, ArrayType);
144 itkGetConstMacro(Variance, const ArrayType);
149 itkSetMacro(MaximumError, ArrayType);
150 itkGetConstMacro(MaximumError, const ArrayType);
154 void
156 {
157 for (unsigned int i = 0; i < TInputImage::ImageDimension; ++i)
158 {
159 if (Math::NotExactlyEquals(m_Variance[i], v))
160 {
161 m_Variance.Fill(v);
162 this->Modified();
163 break;
164 }
165 }
166 }
171 void
173 {
174 for (unsigned int i = 0; i < TInputImage::ImageDimension; ++i)
175 {
176 if (Math::NotExactlyEquals(m_MaximumError[i], v))
177 {
178 m_MaximumError.Fill(v);
179 this->Modified();
180 break;
181 }
182 }
183 }
188 itkSetMacro(UpperThreshold, OutputImagePixelType);
189 itkGetConstMacro(UpperThreshold, OutputImagePixelType);
190
193 itkSetMacro(LowerThreshold, OutputImagePixelType);
194 itkGetConstMacro(LowerThreshold, OutputImagePixelType);
195
198 {
199 return this->m_MultiplyImageFilter->GetOutput();
200 }
201
202#ifdef ITK_USE_CONCEPT_CHECKING
203 // Begin concept checking
209 // End concept checking
210#endif
211
212protected:
214 void
215 PrintSelf(std::ostream & os, Indent indent) const override;
216
217 void
218 GenerateData() override;
219
222
223private:
224 ~CannyEdgeDetectionImageFilter() override = default;
225
227 void
229
231 void
233
235 void
236 FollowEdge(IndexType index, const OutputImageType * multiplyImageFilterOutput);
237
240 void
242
243
248 ComputeCannyEdge(const NeighborhoodType & it, void * globalData);
249
252 void
254
255 ArrayType m_Variance{};
256 ArrayType m_MaximumError{};
257
258 OutputImagePixelType m_UpperThreshold{}; // should be float here?
259 OutputImagePixelType m_LowerThreshold{}; // should be float here?
260
261 typename OutputImageType::Pointer m_UpdateBuffer1{};
262
264 typename GaussianImageFilterType::Pointer m_GaussianFilter{};
265
268 typename MultiplyImageFilterType::Pointer m_MultiplyImageFilter{};
269
274
275 std::slice m_ComputeCannyEdgeSlice[ImageDimension]{};
276
277 SizeValueType m_Stride[ImageDimension]{};
278 SizeValueType m_Center{};
279
280 typename ListNodeStorageType::Pointer m_NodeStore{};
281 ListPointerType m_NodeList{};
282
283 OutputImageType * m_OutputImage{};
284};
285} // end of namespace itk
286
287#ifndef ITK_MANUAL_INSTANTIATION
288# include "itkCannyEdgeDetectionImageFilter.hxx"
289#endif
290
291#endif
This filter is an implementation of a Canny edge detector for scalar-valued images.
void SetMaximumError(const typename ArrayType::ValueType v)
~CannyEdgeDetectionImageFilter() override=default
typename TInputImage::SizeValueType SizeValueType
void ThreadedCompute2ndDerivative(const OutputImageRegionType &outputRegionForThread)
OutputImagePixelType ComputeCannyEdge(const NeighborhoodType &it, void *globalData)
void SetVariance(const typename ArrayType::ValueType v)
void ThreadedCompute2ndDerivativePos(const OutputImageRegionType &outputRegionForThread)
void FollowEdge(IndexType index, const OutputImageType *multiplyImageFilterOutput)
void PrintSelf(std::ostream &os, Indent indent) const override
Const version of NeighborhoodIterator, defining iteration of a local N-dimensional neighborhood of pi...
Blurs an image by separable convolution with discrete gaussian kernels. This filter performs Gaussian...
Base class for all process objects that output image data.
typename OutputImageType::PixelType OutputImagePixelType
typename OutputImageType::RegionType OutputImageRegionType
Base class for filters that take an image as input and produce an image as output.
typename InputImageType::PixelType InputImagePixelType
typename InputImageType::RegionType InputImageRegionType
Control indentation during Print() invocation.
Definition: itkIndent.h:50
Pixel-wise multiplication of two images.
A specialized memory management object for allocating and destroying contiguous blocks of objects.
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
A very simple linked list that is used to manage nodes in a layer of a sparse field level-set solver.
A function object that determines a neighborhood of values at an image boundary according to a Neuman...
SmartPointer< Self > Pointer
#define itkConceptMacro(name, concept)
bool NotExactlyEquals(const TInput1 &x1, const TInput2 &x2)
Definition: itkMath.h:733
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
unsigned long SizeValueType
Definition: itkIntTypes.h:86