Medical Imaging Interaction Toolkit  2016.11.0
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,
6 Division of Medical and Biological Informatics.
7 All rights reserved.
8 
9 This software is distributed WITHOUT ANY WARRANTY; without
10 even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE.
12 
13 See LICENSE.txt or http://www.mitk.org for details.
14 
15 ===================================================================*/
16 
17 #ifndef __mitkOclImage_h
18 #define __mitkOclImage_h
19 
20 #define GPU_DATA 0
21 #define CPU_DATA 1
22 
23 #define MAX_DIMS 20
24 
25 #include <mitkImage.h>
26 #include "MitkOpenCLExports.h"
27 
28 #include "mitkOclBaseData.h"
29 #include "mitkOclImageFormats.h"
30 #include "mitkOpenCLActivator.h"
31 
32 #include <mitkException.h>
33 
34 
35 #define SHORT_IM mitk::MakeScalarPixelType<short>()
36 #define FLOAT_IM mitk::MakeScalarPixelType<float>()
37 
38 namespace mitk {
39 
49 class MITKOPENCL_EXPORT OclImage : public OclBaseData
50 {
51 public:
53  itkFactorylessNewMacro(Self)
54  itkCloneMacro(Self)
55 
56 
57  virtual int TransferDataToGPU(cl_command_queue);
58 
60  virtual void* TransferDataToCPU(cl_command_queue);
61 
64  {
65  return m_Image;
66  }
67 
73  cl_mem GetGPUImage(cl_command_queue);
74 
76  cl_mem GetGPUBuffer()
77  {
78  return this->m_gpuImage;
79  }
80 
84  cl_mem CreateGPUImage(unsigned int, unsigned int, unsigned int, unsigned int);
85 
90  bool IsModified(int _type);
91 
96  void Modified(int _type);
97 
100  void InitializeMITKImage();
101 
103  void InitializeByMitkImage(mitk::Image::Pointer _image);
104 
106  int GetDimension(int) const;
107 
109  int GetDimension() const
110  {
111  return this->m_dim;
112  }
113 
115  unsigned int* GetDimensions(){ return this->m_Dims; }
116 
118  float GetSpacing(int);
119 
121  void GetOffset(float*) const;
122 
125  void SetPixelType(const cl_image_format*);
126 
127  short GetBytesPerPixel() const
128  {
129  return this->m_BpE;
130  }
131 
136  const cl_image_format* GetPixelType() const
137  {
138  return &(this->m_proposedFormat);
139  }
140 
142  void SetDimensions(unsigned int* Dims);
143 
145  void SetDimension(unsigned short dim);
146 
147 protected:
149  OclImage();
150 
152  virtual ~OclImage();
153 
155  cl_mem m_gpuImage;
156 
158  cl_context m_context;
159 
161  unsigned int m_bufferSize;
162 
163 private:
164 
165  cl_image_format ConvertPixelTypeToOCLFormat();
166 
167  bool m_gpuModified;
168  bool m_cpuModified;
169 
171  Image::Pointer m_Image;
172 
173  unsigned short m_dim;
174 
175  unsigned int* m_Dims;
176 
177  unsigned short m_BpE;
178 
179  cl_int AllocateGPUImage();
180 
184  bool m_formatSupported;
185 
187  cl_image_format m_supportedFormat;
188 
190  cl_image_format m_proposedFormat;
191 };
192 
198 {
199 public:
201 };
202 
203 }
204 #endif //__mitkOclImage_h
short GetBytesPerPixel() const
Definition: mitkOclImage.h:127
DataCollection - Class to facilitate loading/accessing structured data.
The ImageTypeIsNotSupportedByGPU class specialized exception class for unsupported image formats...
Definition: mitkOclImage.h:197
Class implementing the image format for GPU Image Processing.
Definition: mitkOclImage.h:49
unsigned int * GetDimensions()
returns the pointer to the array of image sizes
Definition: mitkOclImage.h:115
int GetDimension() const
returns the dimensionality of the image
Definition: mitkOclImage.h:109
An object of this class represents an exception of MITK. Please don't instantiate exceptions manually...
Definition: mitkException.h:49
#define mitkClassMacro(className, SuperClassName)
Definition: mitkCommon.h:44
#define mitkExceptionClassMacro(ClassName, SuperClassName)
Image::Pointer GetMITKImage()
Returns the pointer to the referenced mitk::Image.
Definition: mitkOclImage.h:63
const cl_image_format * GetPixelType() const
Get the currently used pixel type.
Definition: mitkOclImage.h:136
unsigned int m_bufferSize
Definition: mitkOclImage.h:161
cl_mem GetGPUBuffer()
Definition: mitkOclImage.h:76
cl_context m_context
Definition: mitkOclImage.h:158