ITK 6.0.0
Insight Toolkit
 
Loading...
Searching...
No Matches
itkGPUSmoothingRecursiveYvvGaussianImageFilter.h
Go to the documentation of this file.
1/*=========================================================================
2 *
3 * Copyright NumFOCUS
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 * https://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"
30# include "itkGPUImageToImageFilter.h"
31
32namespace itk
33{
48
49itkGPUKernelClassMacro(GPUSmoothingRecursiveYvvGaussianImageFilterKernel);
50
51template <typename TInputImage, typename TOutputImage = TInputImage>
52class ITK_EXPORT GPUSmoothingRecursiveYvvGaussianImageFilter
53 : public GPUImageToImageFilter<TInputImage,
54 TOutputImage,
55 SmoothingRecursiveYvvGaussianImageFilter<TInputImage, TOutputImage>>
56{
57public:
58 ITK_DISALLOW_COPY_AND_MOVE(GPUSmoothingRecursiveYvvGaussianImageFilter);
59
61 using Self = GPUSmoothingRecursiveYvvGaussianImageFilter;
62 // typedef SmoothingRecursiveYvvGaussianImageFilter<TInputImage,TOutputImage>
63 // CPUSuperclass;
64 using Superclass = GPUImageToImageFilter<TInputImage,
65 TOutputImage,
66 SmoothingRecursiveYvvGaussianImageFilter<TInputImage, TOutputImage>>;
67 using GPUSuperclass = GPUImageToImageFilter<TInputImage,
68 TOutputImage,
69 SmoothingRecursiveYvvGaussianImageFilter<TInputImage, TOutputImage>>;
70 using Pointer = SmartPointer<Self>;
71 using ConstPointer = SmartPointer<const Self>;
72
74 using InputImageType = TInputImage;
75 using OutputImageType = TOutputImage;
76 using PixelType = typename TInputImage::PixelType;
77# ifdef WITH_DOUBLE
78 using RealType = typename NumericTraits<PixelType>::RealType;
79 using ScalarRealType = typename NumericTraits<PixelType>::ScalarRealType;
80# else
81 using RealType = typename NumericTraits<PixelType>::FloatType;
82 using ScalarRealType = typename NumericTraits<PixelType>::FloatType;
83# endif
84
85 using GPUInputImage = typename itk::GPUTraits<TInputImage>::Type;
86 using GPUOutputImage = typename itk::GPUTraits<TOutputImage>::Type;
87
89 itkOverrideGetNameOfClassMacro(GPUSmoothingRecursiveYvvGaussianImageFilter);
90
92 static constexpr unsigned int ImageDimension = TInputImage::ImageDimension;
93
95 using SigmaArrayType = FixedArray<ScalarRealType, Self::ImageDimension>;
96
100
101 using InternalRealType = typename NumericTraits<PixelType>::FloatType;
102 using RealImageType = GPUImage<InternalRealType, Self::ImageDimension>;
103
105 using OutputImagePointer = typename OutputImageType::Pointer;
106
108 itkNewMacro(Self);
109
114 void
115 SetSigmaArray(const SigmaArrayType & sigmas);
116
117 void
118 SetSigma(ScalarRealType sigma);
119
120 SigmaArrayType
121 GetSigmaArray() const;
122
123 ScalarRealType
124 GetSigma() const;
125
127 void
128 SetNormalizeAcrossScale(bool normalizeInScaleSpace);
129
130 bool
131 GetNormalizeAcrossScale() const override
132 {
133 return m_NormalizeAcrossScale;
134 }
135
136 virtual void
137 SetUp(ScalarRealType spacing);
138
139 itkConceptMacro(InputHasNumericTraitsCheck, (Concept::HasNumericTraits<PixelType>));
141 itkGetOpenCLSourceFromKernelMacro(GPUSmoothingRecursiveYvvGaussianImageFilterKernel);
142 void
143 SetInput(const TInputImage * input) override;
144 using Superclass::SetInput;
145
146protected:
147 GPUSmoothingRecursiveYvvGaussianImageFilter();
148 ~GPUSmoothingRecursiveYvvGaussianImageFilter() override = default;
149 void
150 PrintSelf(std::ostream & os, Indent indent) const override;
151
153 void
154 GPUGenerateData() override;
155
161 void
162 GenerateInputRequestedRegion() noexcept override;
163
164 // Override since the filter produces the entire dataset
165 void
166 EnlargeOutputRequestedRegion(DataObject * output) override;
167
168 void
169 AllocateGPUCoefficients();
170
171 std::ostringstream defines;
172
173 ScalarRealType m_B1;
174 ScalarRealType m_B2;
175 ScalarRealType m_B3;
176 ScalarRealType m_B;
177 ScalarRealType * m_Bvalues;
178
179 // Initialization matrix for anti-causal pass
180 ScalarRealType * m_CPUMatrix;
181
182 using GPUDataPointer = GPUDataManager::Pointer;
183
184 GPUDataPointer m_GPUMMatrixDataManager;
185 GPUDataPointer m_GPUBCoefficientsDataManager;
186 GPUDataPointer m_GPULocalDataManager;
187
188private:
189 void
190 BuildKernel();
191
193 bool m_NormalizeAcrossScale;
194
195 int m_FilterGPUKernelHandle;
196 typename GPUInputImage::Pointer inPtr;
197 typename GPUOutputImage::Pointer otPtr;
198 typename GPUOutputImage::SizeType m_requestedSize;
200 SigmaArrayType m_Sigma;
201};
202} // end namespace itk
203
204# ifndef ITK_MANUAL_INSTANTIATION
205# include "itkGPUSmoothingRecursiveYvvGaussianImageFilter.hxx"
206# endif
207
208#endif // GPU
209
210#endif // itkGPUSmoothingRecursiveYvvGaussianImageFilter_h
#define itkConceptMacro(name, conceptType)
Compile-time check that a template argument satisfies an itk::Concept.
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....