go home Home | Main Page | Modules | 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;
70 using Pointer = SmartPointer<Self>;
71 using ConstPointer = SmartPointer<const Self>;
72 using ConstWeakPointer = WeakPointer<const Self>;
73
74 itkNewMacro(Self);
75
76 itkTypeMacro(GPUImage, Image);
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 & operator[](const IndexType & index) const;
133
134 TPixel & operator[](const IndexType & index);
135
137 void
139
141 void
143
144 void
146
148 TPixel *
150
151 const TPixel *
152 GetBufferPointer() const override;
153
155 AccessorType
157 {
158 m_DataManager->SetGPUBufferDirty();
159 return Superclass::GetPixelAccessor();
160 }
161
162
164 const AccessorType
166 {
167 m_DataManager->UpdateCPUBuffer();
168 return Superclass::GetPixelAccessor();
169 }
170
171
173 NeighborhoodAccessorFunctorType
175 {
176 m_DataManager->SetGPUBufferDirty();
178 }
179
180
182 const NeighborhoodAccessorFunctorType
184 {
185 m_DataManager->UpdateCPUBuffer();
187 }
188
189
190 void
191 SetPixelContainer(PixelContainer * container);
192
194 PixelContainer *
196 {
197 m_DataManager->SetGPUBufferDirty();
198 return Superclass::GetPixelContainer();
199 }
200
201
202 const PixelContainer *
204 {
205 m_DataManager->UpdateCPUBuffer();
206 return Superclass::GetPixelContainer();
207 }
208
209
210 void
212 {
213 m_DataManager->SetCurrentCommandQueue(queueid);
214 }
215
216
217 int
219 {
220 return m_DataManager->GetCurrentCommandQueueId();
221 }
222
223
226
234 void
236 {
237 Superclass::DataHasBeenGenerated();
238
239 if (m_DataManager->IsCPUBufferDirty())
240 {
241 m_DataManager->Modified();
242 }
243 }
244
245
247 void
248 Graft(const DataObject * data) override;
249
250 void
251 GraftITKImage(const DataObject * data);
252
254 void
255 Modified() const override;
256
259 itkGetConstReferenceMacro(IndexToPhysicalPoint, DirectionType);
260 itkGetConstReferenceMacro(PhysicalPointToIndex, DirectionType);
261
262protected:
264 ~GPUImage() override = default;
265
266 void
267 PrintSelf(std::ostream & os, Indent indent) const override;
268
269private:
270 bool m_Graft{};
271
273};
274
275//------------------------------------------------------------------------------
276template <typename T>
277class ITK_TEMPLATE_EXPORT GPUTraits
278{
279public:
280 using Type = T;
281};
282
283template <typename TPixelType, unsigned int NDimension>
284class ITK_TEMPLATE_EXPORT GPUTraits<Image<TPixelType, NDimension>>
285{
286public:
287 using Type = GPUImage<TPixelType, NDimension>;
288};
289
290} // end namespace itk
291
292#ifndef ITK_MANUAL_INSTANTIATION
293# include "itkGPUImage.hxx"
294#endif
295
296#endif
Templated n-dimensional image class for the GPU.
Definition itkGPUImage.h:64
void UpdateBuffers()
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)
Image< TPixel, 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


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