ITK  5.0.0
Insight Segmentation and Registration Toolkit
itkGPUMeanImageFilter.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 itkGPUMeanImageFilter_h
19 #define itkGPUMeanImageFilter_h
20 
21 #include "itkMeanImageFilter.h"
22 #include "itkGPUBoxImageFilter.h"
23 #include "itkVersion.h"
24 #include "itkObjectFactoryBase.h"
25 #include "itkOpenCLUtil.h"
26 
27 namespace itk
28 {
39 itkGPUKernelClassMacro(GPUMeanImageFilterKernel);
40 
41 template< typename TInputImage, typename TOutputImage >
42 class ITK_TEMPLATE_EXPORT GPUMeanImageFilter : //public GPUImageToImageFilter<
43  // TInputImage, TOutputImage,
44  // MeanImageFilter< TInputImage,
45  // TOutputImage > >
46  public GPUBoxImageFilter< TInputImage, TOutputImage, MeanImageFilter< TInputImage, TOutputImage > >
47 {
48 public:
49  ITK_DISALLOW_COPY_AND_ASSIGN(GPUMeanImageFilter);
50 
56 
57  itkNewMacro(Self);
58 
61 
63  using OutputImageRegionType = typename Superclass::OutputImageRegionType;
64  using OutputImagePixelType = typename Superclass::OutputImagePixelType;
65 
67  using InputImageType = TInputImage;
68  using InputImagePointer = typename InputImageType::Pointer;
69  using InputImageConstPointer = typename InputImageType::ConstPointer;
71  using InputImagePixelType = typename InputImageType::PixelType;
72 
74  static constexpr unsigned int InputImageDimension = TInputImage::ImageDimension;
75  static constexpr unsigned int OutputImageDimension = TOutputImage::ImageDimension;
76 
78  itkGetOpenCLSourceFromKernelMacro(GPUMeanImageFilterKernel);
79 
80 protected:
82  ~GPUMeanImageFilter() override;
83 
84  void PrintSelf(std::ostream & os, Indent indent) const override;
85 
86  void GPUGenerateData() override;
87 
88 private:
90 };
91 
98 {
99 public:
100  ITK_DISALLOW_COPY_AND_ASSIGN(GPUMeanImageFilterFactory);
101 
106 
108  const char* GetITKSourceVersion() const override
109  {
110  return ITK_SOURCE_VERSION;
111  }
112  const char* GetDescription() const override
113  {
114  return "A Factory for GPUMeanImageFilter";
115  }
117 
119  itkFactorylessNewMacro(Self);
120 
123 
125  static void RegisterOneFactory()
126  {
128 
130  }
131 
132 private:
133 #define OverrideMeanFilterTypeMacro(ipt,opt,dm) \
134  { \
135  using InputImageType = Image<ipt,dm>; \
136  using OutputImageType = Image<opt,dm>; \
137  this->RegisterOverride( \
138  typeid(MeanImageFilter<InputImageType,OutputImageType>).name(), \
139  typeid(GPUMeanImageFilter<InputImageType,OutputImageType>).name(), \
140  "GPU Mean Image Filter Override", \
141  true, \
142  CreateObjectFunction<GPUMeanImageFilter<InputImageType,OutputImageType> >::New() ); \
143  }
144 
146  {
147  if( IsGPUAvailable() )
148  {
149  OverrideMeanFilterTypeMacro(unsigned char, unsigned char, 1);
150  OverrideMeanFilterTypeMacro(char, char, 1);
151  OverrideMeanFilterTypeMacro(float,float,1);
152  OverrideMeanFilterTypeMacro(int,int,1);
153  OverrideMeanFilterTypeMacro(unsigned int,unsigned int,1);
154  OverrideMeanFilterTypeMacro(double,double,1);
155 
156  OverrideMeanFilterTypeMacro(unsigned char, unsigned char, 2);
157  OverrideMeanFilterTypeMacro(char, char, 2);
158  OverrideMeanFilterTypeMacro(float,float,2);
159  OverrideMeanFilterTypeMacro(int,int,2);
160  OverrideMeanFilterTypeMacro(unsigned int,unsigned int,2);
161  OverrideMeanFilterTypeMacro(double,double,2);
162 
163  OverrideMeanFilterTypeMacro(unsigned char, unsigned char, 3);
164  OverrideMeanFilterTypeMacro(char, char, 3);
165  OverrideMeanFilterTypeMacro(float,float,3);
166  OverrideMeanFilterTypeMacro(int,int,3);
167  OverrideMeanFilterTypeMacro(unsigned int,unsigned int,3);
168  OverrideMeanFilterTypeMacro(double,double,3);
169  }
170  }
171 
172 };
173 
174 } // end namespace itk
175 
176 #ifndef ITK_MANUAL_INSTANTIATION
177 #include "itkGPUMeanImageFilter.hxx"
178 #endif
179 
180 #endif
const char * GetITKSourceVersion() const override
Light weight base class for most itk classes.
A base class for all the GPU filters working on a box neighborhood.
#define ITK_SOURCE_VERSION
Definition: itkVersion.h:40
GPUMeanImageFilterFactory Self
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
Base class for all process objects that output image data.
Create instances of classes using an object factory.
itkGPUKernelClassMacro(GPUImageOpsKernel)
typename OutputImageType::PixelType OutputImagePixelType
typename InputImageType::PixelType InputImagePixelType
typename InputImageType::Pointer InputImagePointer
typename OutputImageType::RegionType OutputImageRegionType
#define OverrideMeanFilterTypeMacro(ipt, opt, dm)
typename InputImageType::RegionType InputImageRegionType
const char * GetDescription() const override
static bool RegisterFactory(ObjectFactoryBase *, InsertionPositionType where=INSERT_AT_BACK, vcl_size_t position=0)
Control indentation during Print() invocation.
Definition: itkIndent.h:49
bool IsGPUAvailable()
Object Factory implemenatation for GPUMeanImageFilter.
GPU-enabled implementation of the MeanImageFilter.
typename InputImageType::ConstPointer InputImageConstPointer