go home Home | Main Page | Topics | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Namespace Members | Data Fields | Globals | Related Pages
itkGPUImage.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/*=========================================================================
19 *
20 * Copyright Insight Software Consortium
21 *
22 * Licensed under the Apache License, Version 2.0 (the "License");
23 * you may not use this file except in compliance with the License.
24 * You may obtain a copy of the License at
25 *
26 * http://www.apache.org/licenses/LICENSE-2.0.txt
27 *
28 * Unless required by applicable law or agreed to in writing, software
29 * distributed under the License is distributed on an "AS IS" BASIS,
30 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
31 * See the License for the specific language governing permissions and
32 * limitations under the License.
33 *
34 *=========================================================================*/
35#ifndef itkGPUImage_h
36#define itkGPUImage_h
37
38#include "itkImage.h"
40#include "itkVersion.h"
41#include "itkObjectFactoryBase.h"
42
43namespace itk
44{
62template <typename TPixel, unsigned int VImageDimension = 2>
63class ITK_TEMPLATE_EXPORT ITKOpenCL_EXPORT GPUImage : public Image<TPixel, VImageDimension>
64{
65public:
67
68 using Self = GPUImage;
69 using Superclass = Image<TPixel, VImageDimension>;
70 using Pointer = SmartPointer<Self>;
71 using ConstPointer = SmartPointer<const Self>;
72 using ConstWeakPointer = WeakPointer<const Self>;
73
74 itkNewMacro(Self);
75
77
78 itkStaticConstMacro(ImageDimension, unsigned int, VImageDimension);
79
80 using typename Superclass::PixelType;
81 using typename Superclass::ValueType;
82 using typename Superclass::InternalPixelType;
83 using typename Superclass::IOPixelType;
84 using typename Superclass::DirectionType;
85 using typename Superclass::SpacingType;
86 using typename Superclass::PixelContainer;
87 using typename Superclass::SizeType;
88 using typename Superclass::IndexType;
89 using typename Superclass::OffsetType;
90 using typename Superclass::RegionType;
91 using PixelContainerPointer = typename PixelContainer::Pointer;
92 using PixelContainerConstPointer = typename PixelContainer::ConstPointer;
93 using typename Superclass::AccessorType;
94
95 using AccessorFunctorType = DefaultPixelAccessorFunctor<Self>;
96
97 using NeighborhoodAccessorFunctorType = NeighborhoodAccessorFunctor<Self>;
98
100 template <typename UPixelType, unsigned int VUImageDimension = VImageDimension>
105
106 template <typename UPixelType, unsigned int VUImageDimension = VImageDimension>
108
109
111 void
112 Allocate(bool initialize = false) override;
113
114 void
116
117 void
118 Initialize() override;
119
120 void
121 FillBuffer(const TPixel & value);
122
123 void
124 SetPixel(const IndexType & index, const TPixel & value);
125
126 const TPixel &
127 GetPixel(const IndexType & index) const;
128
129 TPixel &
130 GetPixel(const IndexType & index);
131
132 const TPixel &
133 operator[](const IndexType & index) const;
134
135 TPixel &
136 operator[](const IndexType & index);
137
139 void
141
143 void
145
146 void
148
150 TPixel *
152
153 const TPixel *
154 GetBufferPointer() const override;
155
157 AccessorType
159 {
160 m_DataManager->SetGPUBufferDirty();
161 return Superclass::GetPixelAccessor();
162 }
163
164
166 const AccessorType
168 {
169 m_DataManager->UpdateCPUBuffer();
170 return Superclass::GetPixelAccessor();
171 }
172
173
175 NeighborhoodAccessorFunctorType
177 {
178 m_DataManager->SetGPUBufferDirty();
180 }
181
182
184 const NeighborhoodAccessorFunctorType
186 {
187 m_DataManager->UpdateCPUBuffer();
189 }
190
191
192 void
193 SetPixelContainer(PixelContainer * container);
194
196 PixelContainer *
198 {
199 m_DataManager->SetGPUBufferDirty();
200 return Superclass::GetPixelContainer();
201 }
202
203
204 const PixelContainer *
206 {
207 m_DataManager->UpdateCPUBuffer();
208 return Superclass::GetPixelContainer();
209 }
210
211
212 void
214 {
215 m_DataManager->SetCurrentCommandQueue(queueid);
216 }
217
218
219 int
221 {
222 return m_DataManager->GetCurrentCommandQueueId();
223 }
224
225
228
236 void
238 {
239 Superclass::DataHasBeenGenerated();
240
241 if (m_DataManager->IsCPUBufferDirty())
242 {
243 m_DataManager->Modified();
244 }
245 }
246
247
249 void
250 Graft(const DataObject * data) override;
251
252 void
253 GraftITKImage(const DataObject * data);
254
256 void
257 Modified() const override;
258
261 itkGetConstReferenceMacro(IndexToPhysicalPoint, DirectionType);
262 itkGetConstReferenceMacro(PhysicalPointToIndex, DirectionType);
263
264protected:
266 ~GPUImage() override = default;
267
268 void
269 PrintSelf(std::ostream & os, Indent indent) const override;
270
271private:
272 bool m_Graft{};
273
275};
276
277//------------------------------------------------------------------------------
278template <typename T>
279class ITK_TEMPLATE_EXPORT GPUTraits
280{
281public:
282 using Type = T;
283};
284
285template <typename TPixelType, unsigned int NDimension>
286class ITK_TEMPLATE_EXPORT GPUTraits<Image<TPixelType, NDimension>>
287{
288public:
289 using Type = GPUImage<TPixelType, NDimension>;
290};
291
292} // end namespace itk
293
294#ifndef ITK_MANUAL_INSTANTIATION
295# include "itkGPUImage.hxx"
296#endif
297
298#endif
SmartPointer< Self > Pointer
Templated n-dimensional image class for the GPU.
Definition itkGPUImage.h:64
void UpdateBuffers()
itk::GPUImage< UPixelType, VUImageDimension > RebindImageType
const NeighborhoodAccessorFunctorType GetNeighborhoodAccessor() const
void GraftITKImage(const DataObject *data)
void Graft(const DataObject *data) override
void Modified() const override
typename PixelContainer::ConstPointer PixelContainerConstPointer
Definition itkGPUImage.h:92
DefaultPixelAccessorFunctor< Self > AccessorFunctorType
Definition itkGPUImage.h:95
void UpdateCPUBuffer()
const TPixel & GetPixel(const IndexType &index) const
NeighborhoodAccessorFunctor< Self > NeighborhoodAccessorFunctorType
Definition itkGPUImage.h:97
void AllocateGPU()
TPixel * GetBufferPointer() override
const TPixel * GetBufferPointer() const override
void UpdateGPUBuffer()
const AccessorType GetPixelAccessor() const
const PixelContainer * GetPixelContainer() const
NeighborhoodAccessorFunctorType GetNeighborhoodAccessor()
PixelContainer * GetPixelContainer()
SmartPointer< const Self > ConstPointer
Definition itkGPUImage.h:71
void SetPixel(const IndexType &index, const TPixel &value)
void SetCurrentCommandQueue(int queueid)
ITK_DISALLOW_COPY_AND_MOVE(GPUImage)
void Allocate(bool initialize=false) override
TPixel & operator[](const IndexType &index)
void DataHasBeenGenerated() override
void Initialize() override
int GetCurrentCommandQueueId()
AccessorType GetPixelAccessor()
const TPixel & operator[](const IndexType &index) const
GPUDataManager::Pointer GetGPUDataManager() const
WeakPointer< const Self > ConstWeakPointer
Definition itkGPUImage.h:72
itkStaticConstMacro(ImageDimension, unsigned int, VImageDimension)
GPUImageDataManager< GPUImage >::Pointer m_DataManager
itkOverrideGetNameOfClassMacro(GPUImage)
Image< TScalarType, VImageDimension > Superclass
Definition itkGPUImage.h:69
void SetPixelContainer(PixelContainer *container)
typename PixelContainer::Pointer PixelContainerPointer
Definition itkGPUImage.h:91
void PrintSelf(std::ostream &os, Indent indent) const override
TPixel & GetPixel(const IndexType &index)
~GPUImage() override=default
void FillBuffer(const TPixel &value)
#define ITKOpenCL_EXPORT
itk::GPUImage< UPixelType, VUImageDimension > Type


Generated on 26-02-2026 for elastix by doxygen 1.16.1 (669aeeefca743c148e2d935b3d3c69535c7491e6) elastix logo