fast::Image class

Image data.

Class for image data, represents an image which can be stored in multiple different locations such as OpenCL Image, Buffer, OpenGL texture and as a C++ pointer on the host.

Base classes

class SpatialDataObject
Abstract base class for all spatial data objects.

Public static functions

static auto createFromImage(Image::pointer image) -> std::shared_ptr<Image>
Create an image with same size and type as another image.
static auto createSegmentationFromImage(Image::pointer image) -> std::shared_ptr<Image>
template<class T>
static auto create(uint width, uint height, DataType type, uint nrOfChannels, ExecutionDevice::pointer device, std::unique_ptr<T> data) -> Image::pointer
template<class T>
static auto create(uint width, uint height, uint depth, DataType type, uint nrOfChannels, ExecutionDevice::pointer device, std::unique_ptr<T> data) -> Image::pointer
template<class T>
static auto create(VectorXui, DataType type, uint nrOfChannels, ExecutionDevice::pointer device, std::unique_ptr<T> ptr) -> Image::pointer
template<class T>
static auto create(uint width, uint height, DataType type, uint nrOfChannels, std::unique_ptr<T> ptr) -> Image::pointer
template<class T>
static auto create(uint width, uint height, uint depth, DataType type, uint nrOfChannels, std::unique_ptr<T> ptr) -> Image::pointer
template<class T>
static auto create(VectorXui, DataType type, uint nrOfChannels, std::unique_ptr<T> ptr) -> Image::pointer

Constructors, destructors, conversion operators

Image(Image::pointer image)
~Image()
Image() protected
template<class T>
Image(uint width, uint height, DataType type, uint nrOfChannels, ExecutionDevice::pointer device, std::unique_ptr<T> ptr) protected
template<class T>
Image(uint width, uint height, uint depth, DataType type, uint nrOfChannels, ExecutionDevice::pointer device, std::unique_ptr<T> ptr) protected
template<class T>
Image(VectorXui size, DataType type, uint nrOfChannels, ExecutionDevice::pointer device, std::unique_ptr<T> ptr) protected

Public functions

auto create(VectorXui size, DataType type, uint nrOfChannels) -> std::shared_ptr<Image>
auto create(uint width, uint height, DataType type, uint nrOfChannels) -> std::shared_ptr<Image>
auto create(uint width, uint height, uint depth, DataType type, uint nrOfChannels) -> std::shared_ptr<Image>
auto create(VectorXui size, DataType type, uint nrOfChannels, ExecutionDevice::pointer device, const void* const data) -> std::shared_ptr<Image>
auto create(uint width, uint height, DataType type, uint nrOfChannels, ExecutionDevice::pointer device, const void* const data) -> std::shared_ptr<Image>
auto create(uint width, uint height, uint depth, DataType type, uint nrOfChannels, ExecutionDevice::pointer device, const void* const data) -> std::shared_ptr<Image>
auto create(VectorXui size, DataType type, uint nrOfChannels, const void* const data) -> std::shared_ptr<Image>
auto create(uint width, uint height, DataType type, uint nrOfChannels, const void* const data) -> std::shared_ptr<Image>
auto create(uint width, uint height, uint depth, DataType type, uint nrOfChannels, const void* const data) -> std::shared_ptr<Image>
auto getOpenCLImageAccess(accessType type, OpenCLDevice::pointer) -> OpenCLImageAccess::pointer
auto getOpenCLBufferAccess(accessType type, OpenCLDevice::pointer) -> OpenCLBufferAccess::pointer
auto getImageAccess(accessType type) -> ImageAccess::pointer
auto getOpenGLTextureAccess(accessType type, OpenCLDevice::pointer, bool compress = false, bool getOwnership = false) -> OpenGLTextureAccess::pointer
auto getWidth() const -> int
auto getHeight() const -> int
auto getDepth() const -> int
auto getNrOfVoxels() const -> int
auto getSize() const -> Vector3ui
auto getDimensions() const -> uchar
auto getDataType() const -> DataType
auto getNrOfChannels() const -> int
auto getSpacing() const -> Vector3f
void setSpacing(Vector3f spacing)
void setSpacing(float x, float y, float z)
auto calculateMaximumIntensity() -> float
auto calculateMinimumIntensity() -> float
auto calculateAverageIntensity() -> float
auto calculateSumIntensity() -> float
auto calculateStandardDeviationIntensity() -> float
auto copy(ExecutionDevice::pointer device) -> Image::pointer
auto crop(VectorXi offset, VectorXi size, bool allowOutOfBoundsCropping = false, int croppingValue = 0) -> Image::pointer
void fill(float value)
auto isSegmentationType() const -> bool
auto getTransformedBoundingBox() const -> DataBoundingBox override
auto getBoundingBox() const -> DataBoundingBox override
void free(ExecutionDevice::pointer device) override
void freeAll() override

Protected functions

void setData(ExecutionDevice::pointer device, void* data)
void copyData(ExecutionDevice::pointer device, const void*const data)
void findDeviceWithUptodateData(ExecutionDevice::pointer& device, bool& isOpenCLImage)
void setAllDataToOutOfDate()
auto isInitialized() const -> bool
void updateOpenCLImageData(OpenCLDevice::pointer device)
void transferCLImageFromHost(OpenCLDevice::pointer device)
void transferCLImageToHost(OpenCLDevice::pointer device)
void updateOpenCLBufferData(OpenCLDevice::pointer device)
void transferCLBufferFromHost(OpenCLDevice::pointer device)
void transferCLBufferToHost(OpenCLDevice::pointer device)
void updateHostData()
auto hasAnyData() -> bool
auto getBufferSize() const -> uint
void calculateMaxAndMinIntensity()
void init(VectorXui, DataType type, uint nrOfChannels)
void init(uint width, uint height, DataType type, uint nrOfChannels)
void init(uint width, uint height, uint depth, DataType type, uint nrOfChannels)

Protected variables

std::unordered_map<OpenCLDevice::pointer, cl::Image*> mCLImages
std::unordered_map<OpenCLDevice::pointer, bool> mCLImagesIsUpToDate
std::unordered_map<OpenCLDevice::pointer, cl::Buffer*> mCLBuffers
std::unordered_map<OpenCLDevice::pointer, bool> mCLBuffersIsUpToDate
unique_pixel_ptr mHostData
bool mHostHasData
bool mHostDataIsUpToDate
uint m_GLtextureID
bool m_GLtextureUpToDate
uint mWidth
uint mHeight
uint mDepth
uchar mDimensions
DataType mType
uint mChannels
bool mIsInitialized
Vector3f mSpacing
float mMaximumIntensity
float mMinimumIntensity
float mSumIntensity
float mStdDevIntensity
unsigned long mMaxMinTimestamp
unsigned long mSumIntensityTimestamp
unsigned long mStdDevIntensityTimestamp
bool mMaxMinInitialized
bool mSumInitialized
bool mStdDevInitialized

Function documentation

static std::shared_ptr<Image> fast::Image::createFromImage(Image::pointer image)

Create an image with same size and type as another image.

Parameters
image to copy size and pixel spacing from

Setup an image object with the same size, data type and pixel spacing as the given image. Does not allocate any memory.

template<class T>
static Image::pointer fast::Image::create(uint width, uint height, DataType type, uint nrOfChannels, ExecutionDevice::pointer device, std::unique_ptr<T> data)

Parameters
width
height
type
nrOfChannels
device
data

Moves the 2D data pointer to the given device

template<class T>
static Image::pointer fast::Image::create(uint width, uint height, uint depth, DataType type, uint nrOfChannels, ExecutionDevice::pointer device, std::unique_ptr<T> data)

Parameters
width
height
depth
type
nrOfChannels
device
data

Moves the 3D pointer to the given device

template<class T>
static Image::pointer fast::Image::create(VectorXui, DataType type, uint nrOfChannels, ExecutionDevice::pointer device, std::unique_ptr<T> ptr)

Template parameters
T
Parameters
type
nrOfChannels
device
ptr

Moves the 2D/3D pointer to the given device

template<class T>
static Image::pointer fast::Image::create(uint width, uint height, DataType type, uint nrOfChannels, std::unique_ptr<T> ptr)

Parameters
width
height
type
nrOfChannels
ptr

Moves the 2D data pointer to the default device

template<class T>
static Image::pointer fast::Image::create(uint width, uint height, uint depth, DataType type, uint nrOfChannels, std::unique_ptr<T> ptr)

Parameters
width
height
depth
type
nrOfChannels
ptr

Moves the 3D data pointer to the default device

template<class T>
static Image::pointer fast::Image::create(VectorXui, DataType type, uint nrOfChannels, std::unique_ptr<T> ptr)

Template parameters
T
Parameters
type
nrOfChannels
ptr

Moves the 2D/3D data pointer to the default device

std::shared_ptr<Image> fast::Image::create(VectorXui size, DataType type, uint nrOfChannels)

Parameters
size
type
nrOfChannels

Setup a 2D/3D image object, but does not allocate any memory

std::shared_ptr<Image> fast::Image::create(uint width, uint height, DataType type, uint nrOfChannels)

Parameters
width
height
type
nrOfChannels

Setup a 2D image object, but does not allocate any memory

std::shared_ptr<Image> fast::Image::create(uint width, uint height, uint depth, DataType type, uint nrOfChannels)

Parameters
width
height
depth
type
nrOfChannels

Setup a 3D image object, but does not allocate any memory.

std::shared_ptr<Image> fast::Image::create(VectorXui size, DataType type, uint nrOfChannels, ExecutionDevice::pointer device, const void* const data)

Parameters
size
type
nrOfChannels
device
data

Copies 2D/3D data to given device

std::shared_ptr<Image> fast::Image::create(uint width, uint height, DataType type, uint nrOfChannels, ExecutionDevice::pointer device, const void* const data)

Parameters
width
height
type
nrOfChannels
device
data

Copies 2D data to given device

std::shared_ptr<Image> fast::Image::create(uint width, uint height, uint depth, DataType type, uint nrOfChannels, ExecutionDevice::pointer device, const void* const data)

Parameters
width
height
depth
type
nrOfChannels
device
data

Copies 3D data to given device

std::shared_ptr<Image> fast::Image::create(VectorXui size, DataType type, uint nrOfChannels, const void* const data)

Parameters
size
type
nrOfChannels
data

Copies 2D/3D data to default device

std::shared_ptr<Image> fast::Image::create(uint width, uint height, DataType type, uint nrOfChannels, const void* const data)

Parameters
width
height
type
nrOfChannels
data

Copies 2D data to default device

std::shared_ptr<Image> fast::Image::create(uint width, uint height, uint depth, DataType type, uint nrOfChannels, const void* const data)

Parameters
width
height
depth
type
nrOfChannels
data

Copies 3D data to default device

int fast::Image::getNrOfVoxels() const

Returns the number of pixels/voxels width*height*depth

Image::pointer fast::Image::copy(ExecutionDevice::pointer device)

Copy image and put contents to specific device

Image::pointer fast::Image::crop(VectorXi offset, VectorXi size, bool allowOutOfBoundsCropping = false, int croppingValue = 0)

Create a new image which is a cropped version of this image

void fast::Image::fill(float value)

Parameters
value

Fill entire image with a value

bool fast::Image::isSegmentationType() const

Checks wheter this image is of segmentation type (UINT8 and 1 channel)

void fast::Image::setData(ExecutionDevice::pointer device, void* data) protected

Parameters
device
data

Give data to appropriate device

void fast::Image::copyData(ExecutionDevice::pointer device, const void*const data) protected

Parameters
device
data

Copy data to appropriate device