ITK  4.2.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< class TInputImage, class TOutputImage >
42 class ITK_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:
84 
85  virtual void PrintSelf(std::ostream & os, Indent indent) const;
86 
87  virtual void GPUGenerateData();
88 
89 private:
90  GPUMeanImageFilter(const Self &); //purposely not implemented
91  void operator=(const Self &); //purposely not implemented
92 
94 };
95 
102 {
103 public:
108 
110  virtual const char* GetITKSourceVersion() const {
111  return ITK_SOURCE_VERSION;
112  }
113  const char* GetDescription() const {
114  return "A Factory for GPUMeanImageFilter";
115  }
117 
119  itkFactorylessNewMacro(Self);
120 
123 
125  static void RegisterOneFactory(void)
126  {
128 
130  }
131 
132 private:
133  GPUMeanImageFilterFactory(const Self&); //purposely not implemented
134  void operator=(const Self&); //purposely not implemented
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 #if ITK_TEMPLATE_TXX
180 #include "itkGPUMeanImageFilter.hxx"
181 #endif
182 
183 #endif
184