ITK  5.4.0
Insight Toolkit
itkGPUMeanImageFilter.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 itkGPUMeanImageFilter_h
19#define itkGPUMeanImageFilter_h
20
21#include "itkMeanImageFilter.h"
23#include "itkVersion.h"
25#include "itkOpenCLUtil.h"
26
27namespace itk
28{
40itkGPUKernelClassMacro(GPUMeanImageFilterKernel);
41
42template <typename TInputImage, typename TOutputImage>
43class ITK_TEMPLATE_EXPORT GPUMeanImageFilter
44 : // public GPUImageToImageFilter<
45 // TInputImage, TOutputImage,
46 // MeanImageFilter< TInputImage,
47 // TOutputImage > >
48 public GPUBoxImageFilter<TInputImage, TOutputImage, MeanImageFilter<TInputImage, TOutputImage>>
49{
50public:
51 ITK_DISALLOW_COPY_AND_MOVE(GPUMeanImageFilter);
52
58
59 itkNewMacro(Self);
60
62 itkOverrideGetNameOfClassMacro(GPUMeanImageFilter);
63
65 using typename Superclass::OutputImageRegionType;
66 using typename Superclass::OutputImagePixelType;
67
69 using InputImageType = TInputImage;
73 using InputImagePixelType = typename InputImageType::PixelType;
74
76 static constexpr unsigned int InputImageDimension = TInputImage::ImageDimension;
77 static constexpr unsigned int OutputImageDimension = TOutputImage::ImageDimension;
78
80 itkGetOpenCLSourceFromKernelMacro(GPUMeanImageFilterKernel);
81
82protected:
85
86 void
87 PrintSelf(std::ostream & os, Indent indent) const override;
88
89 void
90 GPUGenerateData() override;
91
92private:
93 int m_MeanFilterGPUKernelHandle{};
94};
95
103{
104public:
105 ITK_DISALLOW_COPY_AND_MOVE(GPUMeanImageFilterFactory);
106
111
113 const char *
114 GetITKSourceVersion() const override
115 {
116 return ITK_SOURCE_VERSION;
117 }
118 const char *
119 GetDescription() const override
120 {
121 return "A Factory for GPUMeanImageFilter";
122 }
126 itkFactorylessNewMacro(Self);
127
129 itkOverrideGetNameOfClassMacro(GPUMeanImageFilterFactory);
130
132 static void
134 {
135 auto factory = GPUMeanImageFilterFactory::New();
136
138 }
139
140private:
141#define OverrideMeanFilterTypeMacro(ipt, opt, dm) \
142 { \
143 using InputImageType = Image<ipt, dm>; \
144 using OutputImageType = Image<opt, dm>; \
145 this->RegisterOverride(typeid(MeanImageFilter<InputImageType, OutputImageType>).name(), \
146 typeid(GPUMeanImageFilter<InputImageType, OutputImageType>).name(), \
147 "GPU Mean Image Filter Override", \
148 true, \
149 CreateObjectFunction<GPUMeanImageFilter<InputImageType, OutputImageType>>::New()); \
150 } \
151 ITK_MACROEND_NOOP_STATEMENT
152
154 {
155 if (IsGPUAvailable())
156 {
157 OverrideMeanFilterTypeMacro(unsigned char, unsigned char, 1);
158 OverrideMeanFilterTypeMacro(char, char, 1);
159 OverrideMeanFilterTypeMacro(float, float, 1);
160 OverrideMeanFilterTypeMacro(int, int, 1);
161 OverrideMeanFilterTypeMacro(unsigned int, unsigned int, 1);
162 OverrideMeanFilterTypeMacro(double, double, 1);
163
164 OverrideMeanFilterTypeMacro(unsigned char, unsigned char, 2);
165 OverrideMeanFilterTypeMacro(char, char, 2);
166 OverrideMeanFilterTypeMacro(float, float, 2);
167 OverrideMeanFilterTypeMacro(int, int, 2);
168 OverrideMeanFilterTypeMacro(unsigned int, unsigned int, 2);
169 OverrideMeanFilterTypeMacro(double, double, 2);
170
171 OverrideMeanFilterTypeMacro(unsigned char, unsigned char, 3);
172 OverrideMeanFilterTypeMacro(char, char, 3);
173 OverrideMeanFilterTypeMacro(float, float, 3);
174 OverrideMeanFilterTypeMacro(int, int, 3);
175 OverrideMeanFilterTypeMacro(unsigned int, unsigned int, 3);
176 OverrideMeanFilterTypeMacro(double, double, 3);
177 }
178 }
179};
180
181} // end namespace itk
182
183#ifndef ITK_MANUAL_INSTANTIATION
184# include "itkGPUMeanImageFilter.hxx"
185#endif
186
187#endif
A base class for all the GPU filters working on a box neighborhood.
Object Factory implementation for GPUMeanImageFilter.
const char * GetITKSourceVersion() const override
const char * GetDescription() const override
GPU-enabled implementation of the MeanImageFilter.
itkGetOpenCLSourceFromKernelMacro(GPUMeanImageFilterKernel)
void PrintSelf(std::ostream &os, Indent indent) const override
void GPUGenerateData() override
~GPUMeanImageFilter() override
Base class for all process objects that output image data.
typename InputImageType::ConstPointer InputImageConstPointer
typename InputImageType::Pointer InputImagePointer
typename InputImageType::PixelType InputImagePixelType
typename InputImageType::RegionType InputImageRegionType
Control indentation during Print() invocation.
Definition: itkIndent.h:50
Light weight base class for most itk classes.
Create instances of classes using an object factory.
static bool RegisterFactory(ObjectFactoryBase *, InsertionPositionEnum where=InsertionPositionEnum::INSERT_AT_BACK, vcl_size_t position=0)
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
SmartPointer< const Self > ConstPointer
SmartPointer< Self > Pointer
#define OverrideMeanFilterTypeMacro(ipt, opt, dm)
#define ITK_SOURCE_VERSION
Definition: itkVersion.h:39
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
itkGPUKernelClassMacro(GPUImageOpsKernel)
bool IsGPUAvailable()