ImFusion SDK 4.3
ClImage Class Reference

#include <ImFusion/CL/ClImage.h>

OpenCL image class. More...

+ Inheritance diagram for ClImage:

Detailed Description

OpenCL image class.

Public Types

enum  ClAccessMode { READ_WRITE = 0 , READ_ONLY = 1 , WRITE_ONLY = 2 }
 OpenCL access type. More...
 
enum  ClType { IMAGE = 0 , BUFFER = 1 }
 OpenCL storage type. More...
 
enum  ClTransferMode { COPY = 0 , SHARE = 1 }
 OpenCL transfer mode. More...
 
enum  SpecialOrder {
  R = 0x10B0 , A = 0x10B1 , RG = 0x10B2 , RA = 0x10B3 ,
  RGB = 0x10B4 , RGBA = 0x10B5 , BGRA = 0x10B6 , ARGB = 0x10B7 ,
  INTENSITY = 0x10B8 , LUMINANCE = 0x10B9 , Rx = 0x10BA , RGx = 0x10BB ,
  RGBx = 0x10BC
}
 
enum  SpecialType {
  SNORM_INT8 = 0x10D0 , SNORM_INT16 = 0x10D1 , UNORM_INT8 = 0x10D2 , UNORM_INT16 = 0x10D3 ,
  UNORM_SHORT_565 = 0x10D4 , UNORM_SHORT_555 = 0x10D5 , UNORM_INT_101010 = 0x10D6 , SIGNED_INT8 = 0x10D7 ,
  SIGNED_INT16 = 0x10D8 , SIGNED_INT32 = 0x10D9 , UNSIGNED_INT8 = 0x10DA , UNSIGNED_INT16 = 0x10DB ,
  UNSIGNED_INT32 = 0x10DC , HALF_FLOAT = 0x10DD , FLOAT = 0x10DE
}
 
- Public Types inherited from Image
enum  Type {
  BYTE = static_cast<int>(PixelType::Byte) , UBYTE = static_cast<int>(PixelType::UByte) , SHORT = static_cast<int>(PixelType::Short) , USHORT = static_cast<int>(PixelType::UShort) ,
  INT = static_cast<int>(PixelType::Int) , UINT = static_cast<int>(PixelType::UInt) , FLOAT = static_cast<int>(PixelType::Float) , DOUBLE = static_cast<int>(PixelType::Double) ,
  HFLOAT = static_cast<int>(PixelType::HFloat)
}
 Pixel/voxel data type, equivalent to OpenGL defines. More...
 
enum  Location {
  NONE = 0 , MEMORY = 1 , OPENGL = 2 , OPENCL = 3 ,
  CUSTOM = 6
}
 Location where the data resides. More...
 

Public Member Functions

 ClImage (ClType ct, ClAccessMode ca, const ImageDescriptor &desc, void *data=nullptr, unsigned int specialOrder=0, unsigned int specialType=0, ClEnvironment *env=nullptr)
 Creates an OpenCL image from an image descriptor.
 
 ClImage (ClType ct, ClAccessMode ca, const MemImage &image, unsigned int specialOrder=0, unsigned int specialType=0, ClEnvironment *env=nullptr)
 Creates an OpenCL from another image in memory.
 
 ClImage (ClType ct, ClAccessMode ca, const GlImage &image, ClTransferMode cm, ClEnvironment *env=nullptr)
 Creates and transfers an OpenCL image from an OpenGL texture.
 
 ClImage (ClType ct, ClAccessMode ca, const ClImage &image, ClTransferMode cm, ClEnvironment *env=nullptr)
 Creates and transfers an OpenCL image from another one.
 
 ClImage (ClAccessMode ca, const ClImage &image, unsigned int offset, unsigned int size, ClEnvironment *env=nullptr)
 Create sub-buffer of OpenCL Buffer. Only works when source image is OpenCL buffer. Warning: Does not update width, height and slices.
 
 ClImage (ClAccessMode ca, const ClImage &image, unsigned int offset, unsigned int size, int width, int height, int slices, int channels, ClEnvironment *env=0)
 Create sub-buffer of OpenCL Buffer. Only works when source image is OpenCL buffer.
 
bool isValid () const
 
ClType imageType () const
 
ClAccessMode imageAccess () const
 
bool update (const ClImage &image, bool blocking=true, const std::vector< ClEvent * > *waitEvents=nullptr, ClEvent **event=nullptr, const ClCommandQueue *commandQueue=nullptr)
 Updates the image content from memory.
 
bool update (const MemImage &image, bool blocking=true, const std::vector< ClEvent * > *waitEvents=nullptr, ClEvent **event=nullptr, const ClCommandQueue *commandQueue=nullptr)
 
template<typename T>
bool update (const std::vector< T > &data, bool blocking=true, const std::vector< ClEvent * > *waitEvents=nullptr, ClEvent **event=nullptr, const ClCommandQueue *commandQueue=nullptr)
 Update the image content from a vector.
 
template<typename T>
bool update (const T *data, bool blocking=true, const std::vector< ClEvent * > *waitEvents=nullptr, ClEvent **event=nullptr, const ClCommandQueue *commandQueue=nullptr)
 Update the image content from memory.
 
MemImagedownload (bool blocking=true, const std::vector< ClEvent * > *waitEvents=nullptr, ClEvent **event=nullptr, const ClCommandQueue *commandQueue=nullptr) const
 Downloads the image into memory.
 
bool download (MemImage &image, bool blocking=true, const std::vector< ClEvent * > *waitEvents=nullptr, ClEvent **event=nullptr, const ClCommandQueue *commandQueue=nullptr) const
 
bool download (void *data, unsigned int size=0, unsigned int offset=0, bool blocking=true, const std::vector< ClEvent * > *waitEvents=nullptr, ClEvent **event=nullptr, const ClCommandQueue *commandQueue=nullptr) const
 
bool acquireGlObject () const
 
bool releaseGlObject () const
 
Location location () const override
 Specifies that the image is an OpenCL memory object.
 
void * memory () const
 
template<typename T>
getMemoryInfo (unsigned int name, int *ret=0) const
 
template<typename T>
std::vector< T > getMemoryInfoVector (unsigned int name, int *ret=0) const
 
template<typename T>
getImageInfo (unsigned int name, int *ret=0) const
 
template<typename T>
std::vector< T > getImageInfoVector (unsigned int name, int *ret=0) const
 
- Public Member Functions inherited from Image
 Image (const ImageDescriptor &desc)
 Create a new Image with the given descriptor.
 
 Image (const Image &other)=default
 
Imageoperator= (const Image &other)=default
 
 Image (Image &&other) noexcept=default
 
Imageoperator= (Image &&other) noexcept=default
 
const ImageDescriptordescriptor () const
 Return the image descriptor.
 
void configure (const Properties *p) override
 Configure the image descriptor from properties.
 
void configuration (Properties *p) const override
 Store image descriptor into properties.
 
void setShift (double val)
 Sets the intensity shift value.
 
void setScale (double val)
 Sets the intensity scale value.
 
void setSpacing (double sx, double sy, double sz=1.0)
 Specify pixel/voxel spacing with two or three scalar values.
 
void setSpacing (double sx, double sy, double sz, bool isMetric)
 Convenience function for specifying spacing and metric flag at the same time.
 
void setSpacing (const vec3 &s)
 Specify pixel/voxel spacing using a 3-vector.
 
void setSpacing (const vec3 &s, bool metric)
 Convenience function for specifying spacing and metric flag at the same time.
 
void setMetric (bool val)
 Set data to be metric.
 
double storageToOriginal (double value) const
 Applies the image's shift and scale in order to convert value from storage pixel value domain to original pixel value domain.
 
double originalToStorage (double value) const
 Applies the image's shift and scale in order to convert value from original pixel value domain to storage pixel value domain.
 
PixelType pixelType () const
 Returns the data type of the image.
 
Type type () const
 Returns the data type of the image.
 
int width () const
 Returns the width of the image.
 
int height () const
 Returns the height of the image.
 
int slices () const
 Returns the number of 3D slices of the image.
 
int channels () const
 Returns the number of channels of the image.
 
double shift () const
 Returns the intensity shift.
 
double scale () const
 Returns the intensity scale.
 
vec3 spacing () const
 Returns pointer to the pixel/voxel spacing values.
 
bool isMetric () const
 Returns true if data is metric.
 
vec3 extent () const
 Returns the physical size of the image as a vector.
 
vec3i dimensions () const
 Returns the dimensions of the image in pixels as a vector.
 
vec3 pixelToImage (const vec3 &pixel) const
 Convert a 3D pixel/voxel position to image coordinates.
 
vec3 imageToPixel (const vec3 &world) const
 Convert 3D image coordinates to pixel/voxel position.
 
mat4 pixelToImageMatrix () const
 Returns a 4x4 matrix to transform from image pixel space to image space.
 
mat4 imageToPixelMatrix () const
 Returns a 4x4 matrix to transform from image space to image pixel space.
 
size_t index (int x, int y, int z=0, int c=0) const
 Returns a linear memory index for a pixel or voxel.
 
bool hasIndex (int x, int y, int z=0, int c=0) const
 Returns true if the pixel at (x,y,z) exists, false otherwise.
 
vec4i coord (size_t index) const
 Returns the pixel/voxel coordinate (x,y,z,c) for a given index.
 
size_t size () const
 Returns the size (number of elements) of the image.
 
int typeSize () const
 Return the nominal size in bytes of standard data types, zero if unknown.
 
bool isInteger () const
 Returns whether the image is of an integer data type.
 
bool isSigned () const
 Returns whether the image type supports negative values.
 
size_t byteSize () const
 Returns the size of the image in bytes.
 
int alignment () const
 Returns the byte alignment of an image line (up to 8)
 
int dimension () const
 Returns the spatial dimension of the image.
 
bool compatible (const Image &other, bool ignoreType=false, bool ignore3D=false, bool ignoreChannels=false) const
 Tells if this image is compatible to another one.
 
- Public Member Functions inherited from Configurable
virtual void configureDefaults ()
 Retrieve the properties of this object, replaces values with their defaults and sets it again.
 
void registerParameter (ParameterBase *param)
 Register the given Parameter or SubProperty, so that it will be configured during configure()/configuration().
 
void unregisterParameter (const ParameterBase *param)
 Remove the given Parameter or SubProperty from the list of registered parameters.
 
 Configurable (const Configurable &rhs)
 
 Configurable (Configurable &&rhs) noexcept
 
Configurableoperator= (const Configurable &)
 
Configurableoperator= (Configurable &&) noexcept
 

Protected Member Functions

void init (ClType ct, ClAccessMode ca, const Image &image, void *data, unsigned int specialOrder=0, unsigned int specialType=0)
 
bool updateInternal (const void *data, bool blocking=true, const std::vector< ClEvent * > *waitEvents=nullptr, ClEvent **event=nullptr, const ClCommandQueue *commandQueue=nullptr)
 
 ClImage (const ClImage &)
 
ClImageoperator= (const ClImage &)
 
- Protected Member Functions inherited from Image
template<typename T>
bool typeCompatible () const
 

Protected Attributes

ClEnvironmentm_env
 
ClType m_imageType
 
ClAccessMode m_imageAccess
 
std::unique_ptr< ImplData > m_d
 
- Protected Attributes inherited from Image
ImageDescriptor m_descriptor
 
- Protected Attributes inherited from Configurable
std::vector< Paramm_params
 List of all registered Parameter and SubProperty instances.
 

Additional Inherited Members

- Public Attributes inherited from Configurable
Signal signalParametersChanged
 Emitted whenever one of the registered Parameters' or SubPropertys' signalValueChanged signal was emitted.
 

Member Enumeration Documentation

◆ ClAccessMode

OpenCL access type.

Enumerator
READ_WRITE 

Read-write access.

READ_ONLY 

Read-only access.

WRITE_ONLY 

Write-only access.

◆ ClType

enum ClType

OpenCL storage type.

Enumerator
IMAGE 

Stored as an OpenCL image.

BUFFER 

Stored as an OpenCL buffer.

◆ ClTransferMode

OpenCL transfer mode.

Enumerator
COPY 

Deep-copy the data when applicable.

SHARE 

Use host pointer.

Member Function Documentation

◆ location()

Location location ( ) const
inlineoverridevirtual

Specifies that the image is an OpenCL memory object.

Reimplemented from Image.


The documentation for this class was generated from the following file:
Search Tab / S to search, Esc to close