Skip to content

ImageData

class ImageData : protected karabo::data::Hash

Helper class to store typical image data from color and monochrome cameras. Along the raw pixel values it also stores useful metadata (like encoding, bit depth, binning) and basic transformations (like flip, rotation, ROI). To make ImageData DAQ compliant, one needs to specify the image size and the datatype. The image size can be either 2 or 3D if it is a monochrome/color image.

IMAGEDATA_ELEMENT(data).key("data.image")
    .setDimensions(std::string("480,640,3"))
    .setType(data::Types::UINT16)
    .setEncoding(xms::Encoding::RGB)
    .commit();

Functions

Name Description
ImageData Constructor of an empty ImageData Take care to keep the object consistent if it is later filled with the set-methods.
ImageData Constructor from NDArray where the dimensions of the image data will be deduced from NDArray if encoding is indexable.
ImageData Constructor from NDArray with the possibility to specify other dimensions than NDArray, as needed for non-indexable formats like JPEG, TIFF, ... data : NDArray - note that the copy of the NDArray kept inside ImageData will refer to the same raw memory as this input dims : The dimensions of the image data - if 'empty' and encoding is indexable, will be deduced from data encoding : The encoding of the bytes - defaults to GRAY. If UNDEFINED, anything matching GRAY, RGB or RGBA will be identified as such. bitsPerPixel : The number of bits used in the original data. Can be smaller than 8 times the size in bytes of the type used in the NDArray 'data'. If zero (default) or negative, a value matching the NDArray type will be calculated (8, 16, ...).
getData Get a reference to the underlying image data structure.
getData Get a reference to the underlying image data structure.
setData Set image data.
getBitsPerPixel Get number of bits per pixel used to achieve the image data.
setBitsPerPixel Set number of bits per pixel used to achieve the image data.
isIndexable Returns true if the image data can be directly indexed.
getDimensions See 'setDimensions' for explanation.
setDimensions Say x = fasted changing, y = medium fast and z = slowest changing index then set the dimension like setDimensions(Dims(x,y,z)) Or in other words, if you think about width, height and depth use: setDimensions(Dims(width, height, depth); For 2D single images, leave away the depth dims : Dimensionality

Function Details

ImageData

ImageData()

Constructor of an empty ImageData

Take care to keep the object consistent if it is later filled with the set-methods.

ImageData(const karabo::data::NDArray& data, const EncodingType encoding = Encoding::GRAY, const int bitsPerPixel = 0)

Constructor from NDArray where the dimensions of the image data will be deduced from NDArray if encoding is indexable.

data : NDArray - note that the copy of the NDArray kept inside ImageData will refer to the same raw memory as this input

encoding : The encoding of the bytes - defaults to GRAY. If UNDEFINED, anything matching GRAY, RGB or RGBA will be identified as such.

bitsPerPixel : The number of bits used in the original data. Can be smaller than 8 times the size in bytes of the type used in the NDArray 'data'. If zero (default) or negative, a value matching the NDArray type will be calculated (8, 16, ...).

ImageData(const karabo::data::NDArray& data, const karabo::data::Dims& dims, const EncodingType encoding = Encoding::GRAY, const int bitsPerPixel = 0)

Constructor from NDArray with the possibility to specify other dimensions than NDArray, as needed for non-indexable formats like JPEG, TIFF, ...

data : NDArray - note that the copy of the NDArray kept inside ImageData will refer to the same raw memory as this input

dims : The dimensions of the image data - if 'empty' and encoding is indexable, will be deduced from data

encoding : The encoding of the bytes - defaults to GRAY. If UNDEFINED, anything matching GRAY, RGB or RGBA will be identified as such.

bitsPerPixel : The number of bits used in the original data. Can be smaller than 8 times the size in bytes of the type used in the NDArray 'data'. If zero (default) or negative, a value matching the NDArray type will be calculated (8, 16, ...).

getBitsPerPixel

int getBitsPerPixel() const

Get number of bits per pixel used to achieve the image data. Can be less than number of bits used per pixel in getData().

getData

karabo::data::NDArray& getData()

Get a reference to the underlying image data structure. Interpretation depends on ImageData::getEncoding().

const karabo::data::NDArray& getData() const

Get a reference to the underlying image data structure. Interpretation depends on ImageData::getEncoding().

getDimensions

karabo::data::Dims getDimensions() const

See 'setDimensions' for explanation.

Return : Dimension object

isIndexable

bool isIndexable() const

Returns true if the image data can be directly indexed.

setBitsPerPixel

void setBitsPerPixel(const int bitsPerPixel)

Set number of bits per pixel used to achieve the image data. Can be less than number of bits used per pixel in getData(), but not more (if a too large value is specified, it will e truncated).

setData

void setData(const karabo::data::NDArray& array)

Set image data. * Note that the copy stored inside ImageData will refer to the same memory as the input.

setDimensions

void setDimensions(const karabo::data::Dims& dims)

Say x = fasted changing, y = medium fast and z = slowest changing index then set the dimension like

``` setDimensions(Dims(x,y,z)) Or in other words, if you think about width, height and depth use:

``` setDimensions(Dims(width, height, depth); For 2D single images, leave away the depth

dims : Dimensionality