go home Home | Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Namespace Members | Data Fields | Globals | Related Pages
itkGPUResampleImageFilter.h
Go to the documentation of this file.
1/*=========================================================================
2 *
3 * Copyright UMC Utrecht and contributors
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 itkGPUResampleImageFilter_h
19#define itkGPUResampleImageFilter_h
20
21#include "itkResampleImageFilter.h"
22
27#include "itkGPUTransformBase.h"
29
30namespace itk
31{
33itkGPUKernelClassMacro(GPUResampleImageFilterKernel);
34
46template <typename TInputImage,
47 typename TOutputImage,
48 typename TInterpolatorPrecisionType = float,
49 typename TTransformPrecisionType = TInterpolatorPrecisionType>
50class ITK_EXPORT GPUResampleImageFilter
51 : public GPUImageToImageFilter<
52 TInputImage,
53 TOutputImage,
54 ResampleImageFilter<TInputImage, TOutputImage, TInterpolatorPrecisionType, TTransformPrecisionType>>
55{
56public:
58
62 ResampleImageFilter<TInputImage, TOutputImage, TInterpolatorPrecisionType, TTransformPrecisionType>;
64 using Pointer = SmartPointer<Self>;
65 using ConstPointer = SmartPointer<const Self>;
66
68 itkNewMacro(Self);
69
72
74 itkStaticConstMacro(InputImageDimension, unsigned int, TInputImage::ImageDimension);
75 itkStaticConstMacro(OutputImageDimension, unsigned int, TOutputImage::ImageDimension);
76
78 using InputImageType = TInputImage;
79 using OutputImageType = TOutputImage;
80 using GPUInputImage = typename GPUTraits<TInputImage>::Type;
81 using GPUOutputImage = typename GPUTraits<TOutputImage>::Type;
82 using InterpolatorPrecisionType = TInterpolatorPrecisionType;
83
85 using InterpolatorType = typename CPUSuperclass::InterpolatorType;
86 using TransformType = typename CPUSuperclass::TransformType;
87 using ExtrapolatorType = typename CPUSuperclass::ExtrapolatorType;
88 using InputImageRegionType = typename CPUSuperclass::InputImageRegionType;
89 using OutputImageRegionType = typename CPUSuperclass::OutputImageRegionType;
90 using SizeType = typename CPUSuperclass::SizeType;
91 using IndexType = typename CPUSuperclass::IndexType;
92
93 using OutputImagePixelType = typename GPUSuperclass::OutputImagePixelType;
94
99
105
108
110 void
112
114 void
116
118 void
119 SetTransform(const TransformType * _arg) override;
120
123 itkSetMacro(RequestedNumberOfSplits, unsigned int);
124 itkGetConstMacro(RequestedNumberOfSplits, unsigned int);
125
126protected:
128 ~GPUResampleImageFilter() override = default;
129 void
130 PrintSelf(std::ostream & os, Indent indent) const override;
131
132 void
133 GPUGenerateData() override;
134
135 // Supported GPU transform types
144
146 void
147 SetArgumentsForPreKernelManager(const typename GPUOutputImage::Pointer & output);
148
150 void
151 SetArgumentsForLoopKernelManager(const typename GPUInputImage::Pointer & input,
152 const typename GPUOutputImage::Pointer & output);
153
155 void
156 SetTransformParametersForLoopKernelManager(const std::size_t transformIndex);
157
159 void
160 SetArgumentsForPostKernelManager(const typename GPUInputImage::Pointer & input,
161 const typename GPUOutputImage::Pointer & output);
162
164 void
165 SetBSplineTransformCoefficientsToGPU(const std::size_t transformIndex);
166
169 GetTransformType(const int & transformIndex) const;
170
172 bool
174
176 int
178
180 bool
181 GetKernelIdFromTransformId(const std::size_t & index, std::size_t & kernelId) const;
182
185 GetGPUBSplineBaseTransform(const std::size_t transformIndex);
186
187private:
188 GPUInterpolatorBase * m_InterpolatorBase{};
189 GPUTransformBase * m_TransformBase{};
190
191 GPUDataManagerPointer m_InputGPUImageBase{};
192 GPUDataManagerPointer m_OutputGPUImageBase{};
193 GPUDataManagerPointer m_FilterParameters{};
194 GPUDataManagerPointer m_DeformationFieldBuffer{};
195 unsigned int m_RequestedNumberOfSplits{};
196
197 using TransformHandle = std::pair<int, bool>;
198 using TransformsHandle = std::map<GPUTransformTypeEnum, TransformHandle>;
199
200#if 0
201 class TransformKernelHelper
202 {
203 GPUTransformTypeEnum m_TransformType;
204 std::string m_TransformTypeAsString;
205 std::: size_t m_TransformKernelHandle;
206 bool m_Compiled;
207 TransformKernelHelper()
208 {
209 m_TransformType = GPUResampleImageFilter::Else;
210 m_TransformTypeAsString = "Else";
211 m_TransformKernelHandle = 0; // ??
212 m_Compiled = false;
213 }
214
215
216 };
217
218 std::vector< TransformKernelHelper > m_SupportedTransformKernels{};
219#endif
220
221 std::vector<std::string> m_Sources{};
222 std::size_t m_SourceIndex{};
223
224 std::size_t m_InterpolatorSourceLoadedIndex{};
225 std::size_t m_TransformSourceLoadedIndex{};
226
227 bool m_InterpolatorIsBSpline{};
228 bool m_TransformIsCombo{};
229
230 std::size_t m_FilterPreGPUKernelHandle{};
231 TransformsHandle m_FilterLoopGPUKernelHandle{};
232 std::size_t m_FilterPostGPUKernelHandle{};
233
234 // GPU kernel managers
235 GPUKernelManagerPointer m_PreKernelManager{};
236 GPUKernelManagerPointer m_LoopKernelManager{};
237 GPUKernelManagerPointer m_PostKernelManager{};
238};
239
240} // end namespace itk
241
242#ifndef ITK_MANUAL_INSTANTIATION
243# include "itkGPUResampleImageFilter.hxx"
244#endif
245
246#endif /* itkGPUResampleImageFilter_h */
GPU base class for the BSplineTransform.
GPU version of BSplineInterpolateImageFunction.
typename GPUCoefficientImageType::Pointer GPUCoefficientImagePointer
class to abstract the behaviour of the GPU filters.
Templated n-dimensional image class for the GPU.
Definition itkGPUImage.h:64
Base class fro all GPU interpolators.
GPU version of ResampleImageFilter.
GPUBSplineBaseTransformType * GetGPUBSplineBaseTransform(const std::vcl_size_t transformIndex)
SmartPointer< const Self > ConstPointer
~GPUResampleImageFilter() override=default
TInterpolatorPrecisionType InterpolatorPrecisionType
bool HasTransform(const GPUTransformTypeEnum type) const
typename GPUDataManager::Pointer GPUDataManagerPointer
const GPUTransformTypeEnum GetTransformType(const int &transformIndex) const
typename GPUTraits< TOutputImage >::Type GPUOutputImage
void GPUGenerateData() override
bool GetKernelIdFromTransformId(const std::vcl_size_t &index, std::vcl_size_t &kernelId) const
typename GPUBSplineInterpolatorType::GPUDataManagerPointer GPUBSplineInterpolatorDataManagerPointer
void SetBSplineTransformCoefficientsToGPU(const std::vcl_size_t transformIndex)
void SetExtrapolator(ExtrapolatorType *_arg) override
void SetArgumentsForLoopKernelManager(const typename GPUInputImage::Pointer &input, const typename GPUOutputImage::Pointer &output)
typename GPUSuperclass::OutputImagePixelType OutputImagePixelType
void SetArgumentsForPreKernelManager(const typename GPUOutputImage::Pointer &output)
int GetTransformHandle(const GPUTransformTypeEnum type) const
std::map< GPUTransformTypeEnum, TransformHandle > TransformsHandle
void SetTransformParametersForLoopKernelManager(const std::vcl_size_t transformIndex)
typename CPUSuperclass::InputImageRegionType InputImageRegionType
void SetTransform(const TransformType *_arg) override
itkStaticConstMacro(OutputImageDimension, unsigned int, TOutputImage::ImageDimension)
itkStaticConstMacro(InputImageDimension, unsigned int, TInputImage::ImageDimension)
typename OpenCLKernelManager::Pointer GPUKernelManagerPointer
typename CPUSuperclass::OutputImageRegionType OutputImageRegionType
void PrintSelf(std::ostream &os, Indent indent) const override
void SetInterpolator(InterpolatorType *_arg) override
typename GPUBSplineInterpolatorType::GPUCoefficientImagePointer GPUBSplineInterpolatorCoefficientImagePointer
typename CPUSuperclass::IndexType IndexType
void SetArgumentsForPostKernelManager(const typename GPUInputImage::Pointer &input, const typename GPUOutputImage::Pointer &output)
typename GPUBSplineInterpolatorType::GPUCoefficientImageType GPUBSplineInterpolatorCoefficientImageType
ITK_DISALLOW_COPY_AND_MOVE(GPUResampleImageFilter)
typename CPUSuperclass::InterpolatorType InterpolatorType
typename CPUSuperclass::SizeType SizeType
typename CPUSuperclass::TransformType TransformType
typename CPUSuperclass::ExtrapolatorType ExtrapolatorType
ResampleImageFilter< TInputImage, TOutputImage, TInterpolatorPrecisionType, TTransformPrecisionType > CPUSuperclass
typename GPUTraits< TInputImage >::Type GPUInputImage
Base class for all GPU transforms.
itkGPUKernelClassMacro(GPUBSplineTransformKernel)


Generated on 2024-07-17 for elastix by doxygen 1.11.0 (9b424b03c9833626cd435af22a444888fbbb192d) elastix logo