ITK  5.0.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 #ifndef itkGPUSmoothingRecursiveYvvGaussianImageFilter_h
20 #define itkGPUSmoothingRecursiveYvvGaussianImageFilter_h
21 
22 #ifdef GPU
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:
57  ITK_DISALLOW_COPY_AND_ASSIGN(GPUSmoothingRecursiveYvvGaussianImageFilter);
58 
60  using Self = GPUSmoothingRecursiveYvvGaussianImageFilter;
61  //typedef SmoothingRecursiveYvvGaussianImageFilter<TInputImage,TOutputImage>
62  // CPUSuperclass;
63  using Superclass = GPUImageToImageFilter< TInputImage, TOutputImage,
64  SmoothingRecursiveYvvGaussianImageFilter< TInputImage, TOutputImage > >;
65  using GPUSuperclass = GPUImageToImageFilter< TInputImage, TOutputImage,
66  SmoothingRecursiveYvvGaussianImageFilter< TInputImage, TOutputImage > >;
67  using Pointer = SmartPointer< Self >;
68  using ConstPointer = SmartPointer< const Self >;
69 
71  using InputImageType = TInputImage;
72  using OutputImageType = TOutputImage;
73  using PixelType = typename TInputImage::PixelType;
74  #ifdef WITH_DOUBLE
75  using RealType = typename NumericTraits< PixelType >::RealType;
76  using ScalarRealType = typename NumericTraits< PixelType >::ScalarRealType;
77  #else
78  using RealType = typename NumericTraits< PixelType >::FloatType;
79  using ScalarRealType = typename NumericTraits< PixelType >::FloatType;
80  #endif
81 
82  using GPUInputImage = typename itk::GPUTraits< TInputImage >::Type;
83  using GPUOutputImage = typename itk::GPUTraits< TOutputImage >::Type;
84 
86  itkTypeMacro(GPUSmoothingRecursiveYvvGaussianImageFilter,
87  GPUImageToImageFilter);
88 
90  static constexpr unsigned int ImageDimension = TInputImage::ImageDimension;
91 
93  using SigmaArrayType = FixedArray< ScalarRealType,
94  itkGetStaticConstMacro(ImageDimension) >;
95 
100  using InternalRealType = typename NumericTraits< PixelType >::FloatType;
101  using RealImageType = GPUImage< InternalRealType,
102  itkGetStaticConstMacro(ImageDimension) >;
103 
105  using OutputImagePointer = typename OutputImageType::Pointer;
106 
108  itkNewMacro(Self);
109 
114  void SetSigmaArray(const SigmaArrayType & sigmas);
115 
116  void SetSigma(ScalarRealType sigma);
117 
118  SigmaArrayType GetSigmaArray() const;
119 
120  ScalarRealType GetSigma() const;
121 
123  void SetNormalizeAcrossScale(bool normalizeInScaleSpace);
124 
125  itkGetConstMacro(NormalizeAcrossScale, bool);
126 
127  virtual void SetUp(ScalarRealType spacing);
128 
129 #ifdef ITK_USE_CONCEPT_CHECKING
130 
131  itkConceptMacro( InputHasNumericTraitsCheck,
132  ( Concept::HasNumericTraits< PixelType > ) );
133 
135 #endif
136 
138  itkGetOpenCLSourceFromKernelMacro(GPUSmoothingRecursiveYvvGaussianImageFilterKernel);
139  void SetInput(const TInputImage *input);
140  using Superclass::SetInput;
141 protected:
142  GPUSmoothingRecursiveYvvGaussianImageFilter();
143  virtual ~GPUSmoothingRecursiveYvvGaussianImageFilter() {}
144  void PrintSelf(std::ostream & os, Indent indent) const;
146 
148  void GPUGenerateData(void);
149 
155  virtual void GenerateInputRequestedRegion() throw( InvalidRequestedRegionError );
156 
157  // Override since the filter produces the entire dataset
158  void EnlargeOutputRequestedRegion(DataObject *output);
159 
160  void AllocateGPUCoefficients();
161 
162  std::ostringstream defines;
163 
164  ScalarRealType m_B1;
165  ScalarRealType m_B2;
166  ScalarRealType m_B3;
167  ScalarRealType m_B;
168  ScalarRealType *m_Bvalues;
169 
170  // Initialization matrix for anti-causal pass
171  ScalarRealType *m_CPUMatrix;
172 
173  using GPUDataPointer = GPUDataManager::Pointer;
174 
175  GPUDataPointer m_GPUMMatrixDataManager;
176  GPUDataPointer m_GPUBCoefficientsDataManager;
177  GPUDataPointer m_GPULocalDataManager;
178 
179 private:
180  void BuildKernel();
181 
183  bool m_NormalizeAcrossScale;
184 
185  int m_FilterGPUKernelHandle;
186  typename GPUInputImage::Pointer inPtr;
187  typename GPUOutputImage::Pointer otPtr;
188  typename GPUOutputImage::SizeType m_requestedSize;
190  SigmaArrayType m_Sigma;
191 };
192 } // end namespace itk
193 
194 #ifndef ITK_MANUAL_INSTANTIATION
195  #include "itkGPUSmoothingRecursiveYvvGaussianImageFilter.hxx"
196 #endif
197 
198 #endif //GPU
199 
200 #endif // itkGPUSmoothingRecursiveYvvGaussianImageFilter_h
Define numeric traits for std::vector.
class ITK_FORWARD_EXPORT DataObject
Definition: itkDataObject.h:41
itkGPUKernelClassMacro(GPUImageOpsKernel)
#define itkConceptMacro(name, concept)