![]() |
LibraryLink Utilities
3.0.1
Modern C++ wrapper over LibraryLink and WSTP
|
This is a class template, where template parameter T is the type of data elements. Image is derived from MArray.
Image<> classes automate creation and deletion of MImages. They are strongly typed (no void* to underlying memory) and almost all functions from <algorithms> can be used on Image.
| T | - type of underlying data |
Inheritance diagram for LLU::Image< T >:
Collaboration diagram for LLU::Image< T >:#include <Image.h>
Public Types | |
| using | value_type = T |
| Type of elements stored. More... | |
| using | iterator = value_type * |
| Iterator type. More... | |
| using | const_iterator = const value_type * |
| Constant iterator type. More... | |
| using | reverse_iterator = std::reverse_iterator< iterator > |
| Reverse iterator type. More... | |
| using | const_reverse_iterator = std::reverse_iterator< const_iterator > |
| Constant reverse iterator type. More... | |
| using | reference = value_type & |
| Reference type. More... | |
| using | const_reference = const value_type & |
| Constant reference type. More... | |
| using | Container = Argument::CType< Type > |
| The type of underlying LibraryLink structure (e.g. MTensor, MImage, etc.) will be called "Container". More... | |
Public Member Functions | |
| Image (mint w, mint h, mint channels, colorspace_t cs, bool interleavingQ) | |
| Constructs new 2D Image. More... | |
| Image (mint nFrames, mint w, mint h, mint channels, colorspace_t cs, bool interleavingQ) | |
| Constructs new 3D Image. More... | |
| Image (GenericImage im) | |
| Create new Image from a GenericImage. More... | |
| Image (MImage mi, Ownership owner) | |
| Constructs Image based on MImage. More... | |
| Image ()=default | |
| Default constructor - creates an empty wrapper. More... | |
| Image | clone () const |
| Clone this Image, performing a deep copy of the underlying MImage. More... | |
| template<typename U > | |
| Image< U > | convert (bool interleaved) const |
| Copy this image with type conversion and explicitly specified interleaving. More... | |
| template<typename U > | |
| Image< U > | convert () const |
| Copy this image with type conversion and other properties (dimensions, interleaving, color space, etc.) untouched. More... | |
| T | get (mint row, mint col, mint channel) const |
| Get channel value at specified position in 2D image. More... | |
| T | get (mint slice, mint row, mint col, mint channel) const |
| Get channel value at specified position in 3D image. More... | |
| void | set (mint row, mint col, mint channel, T newValue) |
| Set channel value at specified position in 2D image. More... | |
| void | set (mint slice, mint row, mint col, mint channel, T newValue) |
| Set channel value at specified position in 3D image. More... | |
| mint | rank () const noexcept |
| Get container rank. More... | |
| bool | empty () const noexcept |
| Check whether container is empty. More... | |
| mint | dimension (mint index) const |
Get dimension value at position index. More... | |
| const MArrayDimensions & | dimensions () const |
| Get a const reference to dimensions object. More... | |
| T & | operator[] (const std::vector< mint > &indices) |
| Get a reference to the data element at given position in a multidimensional container. More... | |
| const T & | operator[] (const std::vector< mint > &indices) const |
| Get a constant reference to the data element at given position in a multidimensional container. More... | |
| reference | operator[] (mint index) |
| Get a reference to the data element at given position. More... | |
| const_reference | operator[] (mint index) const |
| Get a constant reference to the data element at given position. More... | |
| T & | at (mint index) |
| Get a reference to the data element at given position with bound checking. More... | |
| const T & | at (mint index) const |
| Get a constant reference to the data element at given position with bound checking. More... | |
| T & | at (const std::vector< mint > &indices) |
| Get a reference to the data element at given position in a multidimensional container. More... | |
| const T & | at (const std::vector< mint > &indices) const |
| Get a constant reference to the data element at given position in a multidimensional container. More... | |
| value_type * | data () noexcept |
| Get raw pointer to underlying data. More... | |
| const value_type * | data () const noexcept |
| Get raw pointer to const underlying data. More... | |
| mint | size () const noexcept |
| Get total number of elements in the container. More... | |
| iterator | begin () noexcept |
| Get iterator at the beginning of underlying data. More... | |
| const_iterator | begin () const noexcept |
| Get constant iterator at the beginning of underlying data. More... | |
| const_iterator | cbegin () const noexcept |
| Get constant iterator at the beginning of underlying data. More... | |
| iterator | end () noexcept |
| Get iterator after the end of underlying data. More... | |
| const_iterator | end () const noexcept |
| Get constant iterator after the end of underlying data. More... | |
| const_iterator | cend () const noexcept |
| Get constant iterator after the end of underlying data. More... | |
| reverse_iterator | rbegin () noexcept |
| Get iterator at the beginning of underlying data. More... | |
| const_reverse_iterator | rbegin () const noexcept |
| Get constant iterator at the beginning of underlying data. More... | |
| const_reverse_iterator | crbegin () const noexcept |
| Get constant iterator at the beginning of underlying data. More... | |
| reverse_iterator | rend () noexcept |
| Get iterator after the end of underlying data. More... | |
| const_reverse_iterator | rend () const noexcept |
| Get constant iterator after the end of underlying data. More... | |
| const_reverse_iterator | crend () const noexcept |
| Get constant iterator after the end of underlying data. More... | |
| reference | front () |
| Get reference to the first element. More... | |
| const_reference | front () const |
| Get constant reference to the first element. More... | |
| reference | back () |
| Get reference to the last element. More... | |
| const_reference | back () const |
| Get constant reference to the last element. More... | |
| std::vector< value_type > | asVector () const |
| Copy contents of the data to a std::vector of matching type. More... | |
| GenericImage | convert (imagedata_t t, mbool interleavingQ) const |
| Convert this object to a new GenericImage of given datatype, optionally changing interleaving. More... | |
| GenericImage | convert (imagedata_t t) const |
| Convert this object to a new GenericImage of given datatype. More... | |
| colorspace_t | colorspace () const override |
| Get colorspace which describes how colors are represented as numbers. More... | |
| mint | rows () const override |
| Get number of rows. More... | |
| mint | columns () const override |
| Get number of columns. More... | |
| mint | slices () const override |
| Get number of slices. More... | |
| mint | channels () const override |
| Get number of channels. More... | |
| bool | alphaChannelQ () const override |
| Check if there is an alpha channel in the image. More... | |
| bool | interleavedQ () const override |
| Check if the image is interleaved. More... | |
| bool | is3D () const override |
| Check if the image is 3D. More... | |
| mint | getRank () const override |
| Get rank. More... | |
| mint | getFlattenedLength () const override |
| Get the total number of pixels in the image. More... | |
| imagedata_t | type () const override |
| Get the data type of the image. More... | |
| void * | rawData () const override |
| Get access to raw image data. More... | |
| Container | getContainer () const noexcept |
| Get internal container. More... | |
| Container | abandonContainer () const noexcept |
| Give a handle to internal container and stop owning it. More... | |
| mint | shareCount () const noexcept |
| Return share count of internal container, if present and 0 otherwise. More... | |
| void | pass (MArgument &res) const |
| Pass the internal container as result of a LibraryLink function. More... | |
| Ownership | getOwner () const noexcept |
| Get ownership information. More... | |
Protected Member Functions | |
| Container | cloneContainer () const |
| Clone the raw container, if it's present. More... | |
| void | disown () const noexcept |
| Disown internal container if present. More... | |
| void | free () const noexcept |
| Free internal container if present. More... | |
| void | reset (Container newCont, Ownership newOwnerMode=Ownership::Library) noexcept |
| Set a new internal container safely disposing of the old one. More... | |
|
inherited |
Constant iterator type.
|
inherited |
Constant reference type.
|
inherited |
Constant reverse iterator type.
|
inherited |
The type of underlying LibraryLink structure (e.g. MTensor, MImage, etc.) will be called "Container".
|
inherited |
Iterator type.
|
inherited |
Reference type.
|
inherited |
Reverse iterator type.
|
inherited |
Type of elements stored.
| LLU::Image< T >::Image | ( | mint | w, |
| mint | h, | ||
| mint | channels, | ||
| colorspace_t | cs, | ||
| bool | interleavingQ | ||
| ) |
| LLU::Image< T >::Image | ( | mint | nFrames, |
| mint | w, | ||
| mint | h, | ||
| mint | channels, | ||
| colorspace_t | cs, | ||
| bool | interleavingQ | ||
| ) |
Constructs new 3D Image.
| [in] | nFrames | - number of 2D frames/slices |
| [in] | w | - Image width (number of columns) |
| [in] | h | - Image height (number of rows) |
| [in] | channels | - number of channels |
| [in] | cs | - color space |
| [in] | interleavingQ | - whether Image data should be interleaved |
| ErrorName::ImageNewError | - if internal MImage creation failed |
|
explicit |
Create new Image from a GenericImage.
| [in] | im | - generic image to be wrapped into Image class |
| ErrorName::ImageTypeError | - if the Image template type T does not match the actual data type of the generic image |
|
inline |
Constructs Image based on MImage.
| [in] | mi | - LibraryLink structure to be wrapped |
| [in] | owner | - who manages the memory the raw MImage |
| ErrorName::ImageTypeError | - if template parameter T does not match MImage data type |
| ErrorName::ImageSizeError | - if constructor failed to calculate image dimensions properly |
|
default |
Default constructor - creates an empty wrapper.
|
inlinenoexceptinherited |
Give a handle to internal container and stop owning it.
Should be used with caution as it may potentially result with resource leak.
|
inlineoverridevirtualinherited |
Check if there is an alpha channel in the image.
Implements LLU::ImageInterface.
|
inlineinherited |
Copy contents of the data to a std::vector of matching type.
|
inherited |
Get a reference to the data element at given position in a multidimensional container.
| [in] | indices | - vector with coordinates of desired data element |
| indexError() | - if indices are out-of-bounds |
|
inherited |
Get a constant reference to the data element at given position in a multidimensional container.
| [in] | indices | - vector with coordinates of desired data element |
| indexError() | - if indices are out-of-bounds |
|
inherited |
Get a reference to the data element at given position with bound checking.
| [in] | index | - position of desired data element |
| indexError() | - if index is out-of-bounds |
|
inherited |
Get a constant reference to the data element at given position with bound checking.
| [in] | index | - position of desired data element |
| indexError() | - if index is out-of-bounds |
|
inlineinherited |
Get reference to the last element.
|
inlineinherited |
Get constant reference to the last element.
|
inlinenoexceptinherited |
Get constant iterator at the beginning of underlying data.
|
inlinenoexceptinherited |
Get iterator at the beginning of underlying data.
|
inlinenoexceptinherited |
Get constant iterator at the beginning of underlying data.
|
inlinenoexceptinherited |
Get constant iterator after the end of underlying data.
|
inlineoverridevirtualinherited |
Get number of channels.
Implements LLU::ImageInterface.
| Image< T > LLU::Image< T >::clone |
Clone this Image, performing a deep copy of the underlying MImage.
|
inlineprotectedinherited |
Clone the raw container, if it's present.
|
inlineoverridevirtualinherited |
Get colorspace which describes how colors are represented as numbers.
Implements LLU::ImageInterface.
|
inlineoverridevirtualinherited |
Get number of columns.
Implements LLU::ImageInterface.
| Image< U > LLU::Image< T >::convert | ( | bool | interleaved | ) | const |
|
inlineinherited |
Convert this object to a new GenericImage of given datatype.
| t | - destination data type |
|
inherited |
Convert this object to a new GenericImage of given datatype, optionally changing interleaving.
| t | - destination data type |
| interleavingQ | - whether the converted GenericImage should be interleaved or not |
|
inlinenoexceptinherited |
Get constant iterator at the beginning of underlying data.
|
inlinenoexceptinherited |
Get constant iterator after the end of underlying data.
|
inlinenoexceptinherited |
Get raw pointer to const underlying data.
|
inlinenoexceptinherited |
Get raw pointer to underlying data.
|
inlineinherited |
Get dimension value at position index.
|
inlineinherited |
Get a const reference to dimensions object.
|
inlineprotectednoexceptinherited |
Disown internal container if present.
|
inlinenoexceptinherited |
Check whether container is empty.
|
inlinenoexceptinherited |
Get constant iterator after the end of underlying data.
|
inlinenoexceptinherited |
Get iterator after the end of underlying data.
|
inlineprotectednoexceptinherited |
Free internal container if present.
|
inlineinherited |
Get reference to the first element.
|
inlineinherited |
Get constant reference to the first element.
|
inlineinherited |
Get channel value at specified position in 2D image.
| [in] | row | - pixel row (in Mathematica-style indexing - starting from 1) |
| [in] | col | - pixel column (in Mathematica-style indexing - starting from 1) |
| [in] | channel | - desired channel (in Mathematica-style indexing - starting from 1) |
| ErrorName::ImageIndexError | - if the specified coordinates are out-of-bound |
|
inlineinherited |
Get channel value at specified position in 3D image.
| [in] | slice | - slice index (in Mathematica-style indexing - starting from 1) |
| [in] | row | - pixel row (in Mathematica-style indexing - starting from 1) |
| [in] | col | - pixel column (in Mathematica-style indexing - starting from 1) |
| [in] | channel | - desired channel (in Mathematica-style indexing - starting from 1) |
| ErrorName::ImageIndexError | - if the specified coordinates are out-of-bound |
|
inlinenoexceptinherited |
Get internal container.
|
inlineoverridevirtualinherited |
Get the total number of pixels in the image.
Implements LLU::ImageInterface.
|
inlinenoexceptinherited |
Get ownership information.
|
inlineoverridevirtualinherited |
Get rank.
Implements LLU::ImageInterface.
|
inlineoverridevirtualinherited |
Check if the image is interleaved.
Implements LLU::ImageInterface.
|
inlineoverridevirtualinherited |
Check if the image is 3D.
Implements LLU::ImageInterface.
|
inlineinherited |
Get a reference to the data element at given position in a multidimensional container.
| [in] | indices | - vector with coordinates of desired data element |
|
inlineinherited |
Get a constant reference to the data element at given position in a multidimensional container.
| [in] | indices | - vector with coordinates of desired data element |
|
inlineinherited |
Get a reference to the data element at given position.
| [in] | index | - position of desired data element |
|
inlineinherited |
Get a constant reference to the data element at given position.
| [in] | index | - position of desired data element |
|
inlineinherited |
Pass the internal container as result of a LibraryLink function.
| res | - MArgument which will hold internal container of this MContainerBase |
|
inlinenoexceptinherited |
Get container rank.
|
inlineoverridevirtualinherited |
Get access to raw image data.
Use with caution.
Implements LLU::ImageInterface.
|
inlinenoexceptinherited |
Get constant iterator at the beginning of underlying data.
|
inlinenoexceptinherited |
Get iterator at the beginning of underlying data.
|
inlinenoexceptinherited |
Get constant iterator after the end of underlying data.
|
inlinenoexceptinherited |
Get iterator after the end of underlying data.
|
inlineprotectednoexceptinherited |
Set a new internal container safely disposing of the old one.
| newCont | - new internal container |
| newOwnerMode | - owner of the new container |
|
inlineoverridevirtualinherited |
Get number of rows.
Implements LLU::ImageInterface.
|
inlineinherited |
Set channel value at specified position in 2D image.
| [in] | row | - pixel row (in Mathematica-style indexing - starting from 1) |
| [in] | col | - pixel column (in Mathematica-style indexing - starting from 1) |
| [in] | channel | - desired channel (in Mathematica-style indexing - starting from 1) |
| [in] | newValue | - new channel value |
| ErrorName::ImageIndexError | - if the specified coordinates are out-of-bound |
|
inlineinherited |
Set channel value at specified position in 3D image.
| [in] | slice | - slice index (in Mathematica-style indexing - starting from 1) |
| [in] | row | - pixel row (in Mathematica-style indexing - starting from 1) |
| [in] | col | - pixel column (in Mathematica-style indexing - starting from 1) |
| [in] | channel | - desired channel (in Mathematica-style indexing - starting from 1) |
| [in] | newValue | - new channel value |
| ErrorName::ImageIndexError | - if the specified coordinates are out-of-bound |
|
inlinenoexceptinherited |
Return share count of internal container, if present and 0 otherwise.
|
inlinenoexceptinherited |
Get total number of elements in the container.
|
inlineoverridevirtualinherited |
Get number of slices.
Implements LLU::ImageInterface.
|
inlineoverridevirtualinherited |
Get the data type of the image.
imagedata_t) Implements LLU::ImageInterface.