Medical Imaging Interaction Toolkit  2023.12.00
Medical Imaging Interaction Toolkit
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
mitkOclImage.h
Go to the documentation of this file.
1 /*============================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
13 #ifndef mitkOclImage_h
14 #define mitkOclImage_h
15 
16 #define GPU_DATA 0
17 #define CPU_DATA 1
18 
19 #define MAX_DIMS 20
20 
21 #include <mitkImage.h>
22 #include "MitkOpenCLExports.h"
23 
24 #include "mitkOclBaseData.h"
25 #include "mitkOclImageFormats.h"
26 #include "mitkOpenCLActivator.h"
27 
28 #include <mitkException.h>
29 
30 
31 #define SHORT_IM mitk::MakeScalarPixelType<short>()
32 #define FLOAT_IM mitk::MakeScalarPixelType<float>()
33 
34 namespace mitk {
35 
45 class MITKOPENCL_EXPORT OclImage : public OclBaseData
46 {
47 public:
49  itkFactorylessNewMacro(Self);
50  itkCloneMacro(Self);
51 
53  virtual int TransferDataToGPU(cl_command_queue);
54 
56  virtual void* TransferDataToCPU(cl_command_queue);
57 
60  {
61  return m_Image;
62  }
63 
69  cl_mem GetGPUImage(cl_command_queue);
70 
72  cl_mem GetGPUBuffer()
73  {
74  return this->m_gpuImage;
75  }
76 
80  cl_mem CreateGPUImage(unsigned int, unsigned int, unsigned int, unsigned int);
81 
86  bool IsModified(int _type);
87 
88  using OclBaseData::Modified;
93  void Modified(int _type);
94 
97  void InitializeMITKImage();
98 
100  void InitializeByMitkImage(mitk::Image::Pointer _image);
101 
103  int GetDimension(int) const;
104 
106  int GetDimension() const
107  {
108  return this->m_dim;
109  }
110 
112  unsigned int* GetDimensions(){ return this->m_Dims; }
113 
115  float GetSpacing(int);
116 
118  void GetOffset(float*) const;
119 
122  void SetPixelType(const cl_image_format*);
123 
124  short GetBytesPerPixel() const
125  {
126  return this->m_BpE;
127  }
128 
133  const cl_image_format* GetPixelType() const
134  {
135  return &(this->m_proposedFormat);
136  }
137 
139  void SetDimensions(unsigned int* Dims);
140 
142  void SetDimension(unsigned short dim);
143 
144 protected:
146  OclImage();
147 
149  virtual ~OclImage();
150 
152  cl_mem m_gpuImage;
153 
155  cl_context m_context;
156 
158  unsigned int m_bufferSize;
159 
160 private:
161 
162  cl_image_format ConvertPixelTypeToOCLFormat();
163 
164  bool m_gpuModified;
165  bool m_cpuModified;
166 
168  Image::Pointer m_Image;
169 
170  unsigned short m_dim;
171 
172  unsigned int* m_Dims;
173 
174  unsigned short m_BpE;
175 
176  cl_int AllocateGPUImage();
177 
181  bool m_formatSupported;
182 
184  cl_image_format m_supportedFormat;
185 
187  cl_image_format m_proposedFormat;
188 };
189 
195 {
196 public:
198 };
199 
200 }
201 #endif
mitkException.h
mitk::Exception
An object of this class represents an exception of MITK. Please don't instantiate exceptions manually...
Definition: mitkException.h:45
mitk::OclImage
Class implementing the image format for GPU Image Processing.
Definition: mitkOclImage.h:45
mitk::OclImage::GetGPUBuffer
cl_mem GetGPUBuffer()
Definition: mitkOclImage.h:72
mitkOpenCLActivator.h
mitk::OclImage::m_bufferSize
unsigned int m_bufferSize
Definition: mitkOclImage.h:158
mitkOclImageFormats.h
mitkImage.h
mitk::ImageTypeIsNotSupportedByGPU
The ImageTypeIsNotSupportedByGPU class specialized exception class for unsupported image formats....
Definition: mitkOclImage.h:194
mitk::OclImage::GetDimensions
unsigned int * GetDimensions()
returns the pointer to the array of image sizes
Definition: mitkOclImage.h:112
mitk::OclImage::m_gpuImage
cl_mem m_gpuImage
Definition: mitkOclImage.h:152
itk::SmartPointer< Self >
mitk::OclImage::GetBytesPerPixel
short GetBytesPerPixel() const
Definition: mitkOclImage.h:124
mitk
Find image slices visible on a given plane.
Definition: RenderingTests.dox:1
mitkOclBaseData.h
mitk::OclImage::GetMITKImage
Image::Pointer GetMITKImage()
Returns the pointer to the referenced mitk::Image.
Definition: mitkOclImage.h:59
mitk::OclImage::GetDimension
int GetDimension() const
returns the dimensionality of the image
Definition: mitkOclImage.h:106
mitk::OclImage::GetPixelType
const cl_image_format * GetPixelType() const
Get the currently used pixel type.
Definition: mitkOclImage.h:133
mitk::OclImage::m_context
cl_context m_context
Definition: mitkOclImage.h:155
mitkExceptionClassMacro
#define mitkExceptionClassMacro(ClassName, SuperClassName)
Definition: mitkExceptionMacro.h:62
mitkClassMacro
#define mitkClassMacro(className, SuperClassName)
Definition: mitkCommon.h:36
mitk::OclBaseData
Definition: mitkOclBaseData.h:28