ITK  4.13.0
Insight Segmentation and Registration Toolkit
itkGPUSmoothingRecursiveYvvGaussianImageFilter.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 
19 #ifdef GPU
20 
21 #ifndef _ITK_GPU_SMOOTHING_RECURSIVE_YVV_GAUSSIAN_IMAGE_FILTER_H_
22 #define _ITK_GPU_SMOOTHING_RECURSIVE_YVV_GAUSSIAN_IMAGE_FILTER_H_
23 
24 #include "itkImage.h"
25 #include "itkPixelTraits.h"
26 #include "itkCommand.h"
27 #include "itkFixedArray.h"
29 #include "itkOpenCLUtil.h"
31 
32 namespace itk
33 {
49 itkGPUKernelClassMacro(GPUSmoothingRecursiveYvvGaussianImageFilterKernel);
50 
51 template< typename TInputImage, typename TOutputImage = TInputImage >
52 class ITK_EXPORT GPUSmoothingRecursiveYvvGaussianImageFilter:
53  public GPUImageToImageFilter< TInputImage, TOutputImage,
54  SmoothingRecursiveYvvGaussianImageFilter< TInputImage, TOutputImage > >
55 {
56 public:
58  typedef GPUSmoothingRecursiveYvvGaussianImageFilter Self;
59  //typedef SmoothingRecursiveYvvGaussianImageFilter<TInputImage,TOutputImage>
60  // CPUSuperclass;
61  typedef GPUImageToImageFilter< TInputImage, TOutputImage,
62  SmoothingRecursiveYvvGaussianImageFilter< TInputImage, TOutputImage > > Superclass;
63  typedef GPUImageToImageFilter< TInputImage, TOutputImage,
64  SmoothingRecursiveYvvGaussianImageFilter< TInputImage, TOutputImage > > GPUSuperclass;
65  typedef SmartPointer< Self >
66  Pointer;
68  ConstPointer;
69 
71  typedef TInputImage InputImageType;
72  typedef TOutputImage OutputImageType;
73  typedef typename TInputImage::PixelType PixelType;
74  #ifdef WITH_DOUBLE
75  typedef typename NumericTraits< PixelType >::RealType RealType;
76  typedef typename NumericTraits< PixelType >::ScalarRealType ScalarRealType;
77  #else
78  typedef typename NumericTraits< PixelType >::FloatType RealType;
79  typedef typename NumericTraits< PixelType >::FloatType ScalarRealType;
80  #endif
81 
82  typedef typename itk::GPUTraits< TInputImage >::Type GPUInputImage;
83  typedef typename itk::GPUTraits< TOutputImage >::Type GPUOutputImage;
84 
86  itkTypeMacro(GPUSmoothingRecursiveYvvGaussianImageFilter,
87  GPUImageToImageFilter);
88 
90  itkStaticConstMacro(ImageDimension, unsigned int,
91  TInputImage::ImageDimension);
92 
94  typedef FixedArray< ScalarRealType,
95  itkGetStaticConstMacro(ImageDimension) > SigmaArrayType;
96 
101  typedef typename NumericTraits< PixelType >::FloatType InternalRealType;
102  typedef GPUImage< InternalRealType,
103  itkGetStaticConstMacro(ImageDimension) > RealImageType;
104 
106  typedef typename OutputImageType::Pointer OutputImagePointer;
107 
109  itkNewMacro(Self);
110 
115  void SetSigmaArray(const SigmaArrayType & sigmas);
116 
117  void SetSigma(ScalarRealType sigma);
118 
119  SigmaArrayType GetSigmaArray() const;
120 
121  ScalarRealType GetSigma() const;
122 
124  void SetNormalizeAcrossScale(bool normalizeInScaleSpace);
125 
126  itkGetConstMacro(NormalizeAcrossScale, bool);
127 
128  virtual void SetUp(ScalarRealType spacing);
129 
130 #ifdef ITK_USE_CONCEPT_CHECKING
131 
132  itkConceptMacro( InputHasNumericTraitsCheck,
133  ( Concept::HasNumericTraits< PixelType > ) );
134 
136 #endif
137 
139  itkGetOpenCLSourceFromKernelMacro(GPUSmoothingRecursiveYvvGaussianImageFilterKernel);
140  void SetInput(const TInputImage *input);
141  using Superclass::SetInput;
142 protected:
143  GPUSmoothingRecursiveYvvGaussianImageFilter();
144  virtual ~GPUSmoothingRecursiveYvvGaussianImageFilter() {}
145  void PrintSelf(std::ostream & os, Indent indent) const;
147 
149  void GPUGenerateData(void);
150 
156  virtual void GenerateInputRequestedRegion() throw( InvalidRequestedRegionError );
157 
158  // Override since the filter produces the entire dataset
159  void EnlargeOutputRequestedRegion(DataObject *output);
160 
161  void AllocateGPUCoefficients();
162 
163  std::ostringstream defines;
164 
165  ScalarRealType m_B1;
166  ScalarRealType m_B2;
167  ScalarRealType m_B3;
168  ScalarRealType m_B;
169  ScalarRealType *m_Bvalues;
170 
171  // Initialization matrix for anti-causal pass
172  ScalarRealType *m_CPUMatrix;
173 
174  typedef GPUDataManager::Pointer GPUDataPointer;
175 
176  GPUDataPointer m_GPUMMatrixDataManager;
177  GPUDataPointer m_GPUBCoefficientsDataManager;
178  GPUDataPointer m_GPULocalDataManager;
179 private:
180  ITK_DISALLOW_COPY_AND_ASSIGN(GPUSmoothingecursiveYvvGaussianImageFilter);
181 
182  void BuildKernel();
183 
185  bool m_NormalizeAcrossScale;
186 
187  int m_FilterGPUKernelHandle;
188  typename GPUInputImage::Pointer inPtr;
189  typename GPUOutputImage::Pointer otPtr;
190  typename GPUOutputImage::SizeType m_requestedSize;
192  SigmaArrayType m_Sigma;
193  int telltale; //TODO: REMOVE
194 };
195 } // end namespace itk
196 
197 #ifndef ITK_MANUAL_INSTANTIATION
198  #include "itkGPUSmoothingRecursiveYvvGaussianImageFilter.hxx"
199 #endif
200 
201 #endif //_ITK_GPU_SMOOTHING_RECURSIVE_YVV_GAUSSIAN_IMAGE_FILTER_H_
202 #endif //GPU
class ITK_FORWARD_EXPORT DataObject
Definition: itkDataObject.h:40
itkGPUKernelClassMacro(GPUImageOpsKernel)
#define itkConceptMacro(name, concept)