ITK  6.0.0
Insight Toolkit
itkKernelImageFilter.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 itkKernelImageFilter_h
19#define itkKernelImageFilter_h
20
21#include "itkBoxImageFilter.h"
22
23namespace itk
24{
25
26template <unsigned int VDimension>
27class FlatStructuringElement;
39template< typename TInputImage, typename TOutputImage, typename TKernel /*=Neighborhood<bool,
40 TInputImage::ImageDimension>*/ >
41class ITK_TEMPLATE_EXPORT KernelImageFilter:
42 public BoxImageFilter< TInputImage, TOutputImage >
43{
44public:
45 ITK_DISALLOW_COPY_AND_MOVE(KernelImageFilter);
46
52
54 itkNewMacro(Self);
55
57 itkOverrideGetNameOfClassMacro(KernelImageFilter);
58
60 using InputImageType = TInputImage;
64 using OffsetType = typename TInputImage::OffsetType;
65
66 using InputPixelType = typename TInputImage::PixelType;
67
68 using OutputImageType = TOutputImage;
69 using OutputPixelType = typename TOutputImage::PixelType;
70
71 using KernelType = TKernel;
72
74 static constexpr unsigned int ImageDimension = TInputImage::ImageDimension;
75
77 using FlatKernelType = FlatStructuringElement<(Self::ImageDimension)>;
78
81
83 virtual void
84 SetKernel(const KernelType & kernel);
85
86 itkGetConstReferenceMacro(Kernel, KernelType);
87
89 void
90 SetRadius(const RadiusType & radius) override;
91
92 void
93 SetRadius(const SizeValueType & radius) override
94 {
95 // needed because of the overloading of the method
96 Superclass::SetRadius(radius);
97 }
98
99protected:
101 ~KernelImageFilter() override = default;
102
103 void
104 PrintSelf(std::ostream & os, Indent indent) const override;
105
107 KernelType m_Kernel{};
108
109private:
110 template <typename T>
111 void
112 MakeKernel(const RadiusType & radius, T & kernel)
113 {
114 kernel.SetRadius(radius);
115 for (typename T::Iterator kit = kernel.Begin(); kit != kernel.End(); ++kit)
116 {
117 *kit = 1;
118 }
119 }
120
121 void
122 MakeKernel(const RadiusType & radius, FlatKernelType & kernel)
123 {
124 // set up a decomposable box structuring element which is
125 // much efficient with van Herk / Gil Werman filters
126 kernel = FlatKernelType::Box(radius);
127 assert(kernel.GetDecomposable());
128 }
129};
130} // namespace itk
131
132#ifndef ITK_MANUAL_INSTANTIATION
133# include "itkKernelImageFilter.hxx"
134#endif
135
136#endif
A base class for all the filters working on a box neighborhood.
typename TInputImage::RegionType RegionType
typename TInputImage::SizeType SizeType
typename TInputImage::PixelType InputPixelType
typename TInputImage::SizeType RadiusType
typename TInputImage::IndexType IndexType
typename TOutputImage::PixelType OutputPixelType
typename TInputImage::OffsetType OffsetType
A class to support a variety of flat structuring elements, including versions created by decompositio...
Base class for all process objects that output image data.
TOutputImage OutputImageType
Control indentation during Print() invocation.
Definition: itkIndent.h:50
A base class for all the filters working on an arbitrary shaped neighborhood.
void MakeKernel(const RadiusType &radius, T &kernel)
~KernelImageFilter() override=default
void PrintSelf(std::ostream &os, Indent indent) const override
virtual void SetKernel(const KernelType &kernel)
void MakeKernel(const RadiusType &radius, FlatKernelType &kernel)
void SetRadius(const SizeValueType &radius) override
void SetRadius(const RadiusType &radius) override
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
unsigned long SizeValueType
Definition: itkIntTypes.h:86