ITK  4.13.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:
54 
55  itkNewMacro(Self);
56 
59 
61  typedef typename Superclass::OutputImageRegionType OutputImageRegionType;
62  typedef typename Superclass::OutputImagePixelType OutputImagePixelType;
63 
65  typedef TInputImage InputImageType;
66  typedef typename InputImageType::Pointer InputImagePointer;
67  typedef typename InputImageType::ConstPointer InputImageConstPointer;
68  typedef typename InputImageType::RegionType InputImageRegionType;
69  typedef typename InputImageType::PixelType InputImagePixelType;
70 
72  itkStaticConstMacro(InputImageDimension, unsigned int,
73  TInputImage::ImageDimension);
74  itkStaticConstMacro(OutputImageDimension, unsigned int,
75  TOutputImage::ImageDimension);
77 
79  itkGetOpenCLSourceFromKernelMacro(GPUMeanImageFilterKernel);
80 
81 protected:
83  ~GPUMeanImageFilter() ITK_OVERRIDE;
84 
85  virtual void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE;
86 
87  virtual void GPUGenerateData() ITK_OVERRIDE;
88 
89 private:
90  ITK_DISALLOW_COPY_AND_ASSIGN(GPUMeanImageFilter);
91 
92  int m_MeanFilterGPUKernelHandle;
93 };
94 
101 {
102 public:
104  typedef ObjectFactoryBase Superclass;
107 
109  virtual const char* GetITKSourceVersion() const ITK_OVERRIDE
110  {
111  return ITK_SOURCE_VERSION;
112  }
113  const char* GetDescription() const ITK_OVERRIDE
114  {
115  return "A Factory for GPUMeanImageFilter";
116  }
118 
120  itkFactorylessNewMacro(Self);
121 
124 
126  static void RegisterOneFactory(void)
127  {
129 
131  }
132 
133 private:
134  ITK_DISALLOW_COPY_AND_ASSIGN(GPUMeanImageFilterFactory);
135 
136 #define OverrideMeanFilterTypeMacro(ipt,opt,dm) \
137  { \
138  typedef Image<ipt,dm> InputImageType; \
139  typedef Image<opt,dm> OutputImageType; \
140  this->RegisterOverride( \
141  typeid(MeanImageFilter<InputImageType,OutputImageType>).name(), \
142  typeid(GPUMeanImageFilter<InputImageType,OutputImageType>).name(), \
143  "GPU Mean Image Filter Override", \
144  true, \
145  CreateObjectFunction<GPUMeanImageFilter<InputImageType,OutputImageType> >::New() ); \
146  }
147 
149  {
150  if( IsGPUAvailable() )
151  {
152  OverrideMeanFilterTypeMacro(unsigned char, unsigned char, 1);
153  OverrideMeanFilterTypeMacro(char, char, 1);
154  OverrideMeanFilterTypeMacro(float,float,1);
155  OverrideMeanFilterTypeMacro(int,int,1);
156  OverrideMeanFilterTypeMacro(unsigned int,unsigned int,1);
157  OverrideMeanFilterTypeMacro(double,double,1);
158 
159  OverrideMeanFilterTypeMacro(unsigned char, unsigned char, 2);
160  OverrideMeanFilterTypeMacro(char, char, 2);
161  OverrideMeanFilterTypeMacro(float,float,2);
162  OverrideMeanFilterTypeMacro(int,int,2);
163  OverrideMeanFilterTypeMacro(unsigned int,unsigned int,2);
164  OverrideMeanFilterTypeMacro(double,double,2);
165 
166  OverrideMeanFilterTypeMacro(unsigned char, unsigned char, 3);
167  OverrideMeanFilterTypeMacro(char, char, 3);
168  OverrideMeanFilterTypeMacro(float,float,3);
169  OverrideMeanFilterTypeMacro(int,int,3);
170  OverrideMeanFilterTypeMacro(unsigned int,unsigned int,3);
171  OverrideMeanFilterTypeMacro(double,double,3);
172  }
173  }
174 
175 };
176 
177 } // end namespace itk
178 
179 #ifndef ITK_MANUAL_INSTANTIATION
180 #include "itkGPUMeanImageFilter.hxx"
181 #endif
182 
183 #endif
A base class for all the GPU filters working on a box neighborhood.
InputImageType::PixelType InputImagePixelType
#define ITK_SOURCE_VERSION
Definition: itkVersion.h:40
InputImageType::Pointer InputImagePointer
Base class for all process objects that output image data.
Create instances of classes using an object factory.
itkGPUKernelClassMacro(GPUImageOpsKernel)
SmartPointer< const Self > ConstPointer
Superclass::OutputImageRegionType OutputImageRegionType
InputImageType::RegionType InputImageRegionType
SmartPointer< Self > Pointer
#define OverrideMeanFilterTypeMacro(ipt, opt, dm)
InputImageType::ConstPointer InputImageConstPointer
GPUMeanImageFilterFactory Self
const char * GetDescription() const override
SmartPointer< const Self > ConstPointer
static bool RegisterFactory(ObjectFactoryBase *, InsertionPositionType where=INSERT_AT_BACK, vcl_size_t position=0)
Superclass::OutputImagePixelType OutputImagePixelType
virtual const char * GetITKSourceVersion() const override
Control indentation during Print() invocation.
Definition: itkIndent.h:49
bool IsGPUAvailable()
Object Factory implemenatation for GPUMeanImageFilter.
GPU-enabled implementation of the MeanImageFilter.
GPUBoxImageFilter< TInputImage, TOutputImage, MeanImageFilter< TInputImage, TOutputImage > > Superclass