ITK  4.8.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 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 
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:
84 
85  virtual void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE;
86 
87  virtual void GPUGenerateData() ITK_OVERRIDE;
88 
89 private:
90  GPUMeanImageFilter(const Self &); //purposely not implemented
91  void operator=(const Self &); //purposely not implemented
92 
94 };
95 
102 {
103 public:
105  typedef ObjectFactoryBase Superclass;
108 
110  virtual const char* GetITKSourceVersion() const ITK_OVERRIDE
111  {
112  return ITK_SOURCE_VERSION;
113  }
114  const char* GetDescription() const ITK_OVERRIDE
115  {
116  return "A Factory for GPUMeanImageFilter";
117  }
119 
121  itkFactorylessNewMacro(Self);
122 
125 
127  static void RegisterOneFactory(void)
128  {
130 
132  }
133 
134 private:
135  GPUMeanImageFilterFactory(const Self&); //purposely not implemented
136  void operator=(const Self&); //purposely not implemented
137 
138 #define OverrideMeanFilterTypeMacro(ipt,opt,dm) \
139  { \
140  typedef Image<ipt,dm> InputImageType; \
141  typedef Image<opt,dm> OutputImageType; \
142  this->RegisterOverride( \
143  typeid(MeanImageFilter<InputImageType,OutputImageType>).name(), \
144  typeid(GPUMeanImageFilter<InputImageType,OutputImageType>).name(), \
145  "GPU Mean Image Filter Override", \
146  true, \
147  CreateObjectFunction<GPUMeanImageFilter<InputImageType,OutputImageType> >::New() ); \
148  }
149 
151  {
152  if( IsGPUAvailable() )
153  {
154  OverrideMeanFilterTypeMacro(unsigned char, unsigned char, 1);
155  OverrideMeanFilterTypeMacro(char, char, 1);
156  OverrideMeanFilterTypeMacro(float,float,1);
157  OverrideMeanFilterTypeMacro(int,int,1);
158  OverrideMeanFilterTypeMacro(unsigned int,unsigned int,1);
159  OverrideMeanFilterTypeMacro(double,double,1);
160 
161  OverrideMeanFilterTypeMacro(unsigned char, unsigned char, 2);
162  OverrideMeanFilterTypeMacro(char, char, 2);
163  OverrideMeanFilterTypeMacro(float,float,2);
164  OverrideMeanFilterTypeMacro(int,int,2);
165  OverrideMeanFilterTypeMacro(unsigned int,unsigned int,2);
166  OverrideMeanFilterTypeMacro(double,double,2);
167 
168  OverrideMeanFilterTypeMacro(unsigned char, unsigned char, 3);
169  OverrideMeanFilterTypeMacro(char, char, 3);
170  OverrideMeanFilterTypeMacro(float,float,3);
171  OverrideMeanFilterTypeMacro(int,int,3);
172  OverrideMeanFilterTypeMacro(unsigned int,unsigned int,3);
173  OverrideMeanFilterTypeMacro(double,double,3);
174  }
175  }
176 
177 };
178 
179 } // end namespace itk
180 
181 #ifndef ITK_MANUAL_INSTANTIATION
182 #include "itkGPUMeanImageFilter.hxx"
183 #endif
184 
185 #endif
class to abstract the behaviour of the GPU filters.
A base class for all the GPU filters working on a box neighborhood.
InputImageType::PixelType InputImagePixelType
#define ITK_SOURCE_VERSION
Definition: itkVersion.h:40
void operator=(const Self &)
itkGetOpenCLSourceFromKernelMacro(GPUMeanImageFilterKernel)
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
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
virtual void PrintSelf(std::ostream &os, Indent indent) const override
static const unsigned int OutputImageDimension
GPUImageToImageFilter< TInputImage, TOutputImage, MeanImageFilter< TInputImage, TOutputImage > > Superclass
SmartPointer< Self > Pointer
#define OverrideMeanFilterTypeMacro(ipt, opt, dm)
InputImageType::ConstPointer InputImageConstPointer
GPUMeanImageFilterFactory Self
const char * GetDescription() const override
SmartPointer< const Self > ConstPointer
virtual void GPUGenerateData() override
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.
static const unsigned int InputImageDimension