![]() |
|
#include <image.h>
Public Member Functions | |
template<typename T > | |
Iterator< T > | Begin () |
Generic non-const Begin Iterator. More... | |
template<typename T > | |
Iterator< T > | End () |
Generic non-const End Iterator. More... | |
template<typename T > | |
ConstIterator< T > | Begin () const |
Generic const Begin Iterator. More... | |
template<typename T > | |
ConstIterator< T > | End () const |
Generic const End Iterator. More... | |
template<typename T > | |
ContiguousIterator< T > | ContiguousBegin () |
Contiguous non-const Begin Iterator. More... | |
template<typename T > | |
ContiguousIterator< T > | ContiguousEnd () |
Contiguous non-const End Iterator. More... | |
template<typename T > | |
ConstContiguousIterator< T > | ContiguousBegin () const |
Contiguous const Begin Iterator. More... | |
template<typename T > | |
ConstContiguousIterator< T > | ContiguousEnd () const |
Contiguous const End Iterator. More... | |
Image () | |
Default constructor. More... | |
Image (const std::vector< int > &dims, DataType elemtype, std::string channels, ColorType colortype, const std::vector< float > &spacings=std::vector< float >(), Device dev=Device::CPU) | |
Initializing constructor. More... | |
Image (const Image &img) | |
Copy constructor. More... | |
Image (Image &&img) | |
Move constructor. More... | |
Image & | operator= (const Image &rhs) |
Image & | operator= (Image &&rhs) |
void | To (Device dev) |
void | Create (const std::vector< int > &dims, DataType elemtype, std::string channels, ColorType colortype, const std::vector< float > &spacings=std::vector< float >(), Device dev=Device::CPU) |
Allocates new contiguous data if needed. More... | |
~Image () | |
Destructor. More... | |
bool | IsEmpty () const |
To check whether the Image contains data or not, regardless of the owning status. More... | |
bool | IsOwner () const |
To check whether the Image is owner of the data. More... | |
int | Channels () const |
Returns the number of channels. More... | |
int | Width () const |
Returns the width of Image. More... | |
int | Height () const |
Returns the height of Image. More... | |
uint8_t * | Ptr (const std::vector< int > &coords) |
Returns a non-const pointer to data at given coordinates. More... | |
const uint8_t * | Ptr (const std::vector< int > &coords) const |
Returns a const pointer to data at given coordinates. More... | |
void | Neg () |
In-place negation. More... | |
template<typename T > | |
void | Add (const T &rhs, bool saturate=true) |
In-place addition. More... | |
template<typename T > | |
void | Sub (const T &rhs, bool saturate=true) |
In-place subtraction. More... | |
template<typename T > | |
void | Mul (const T &rhs, bool saturate=true) |
In-place multiplication. More... | |
template<typename T > | |
void | Div (const T &rhs, bool saturate=true) |
In-place division. More... | |
template<typename T > | |
void | SetTo (T value) |
Set Image value to rhs. More... | |
void | ConvertTo (DataType dtype, bool saturate=true) |
Convert Image to another DataType. More... | |
Image | operator- () const |
Image & | operator+= (const Image &rhs) |
Image & | operator-= (const Image &rhs) |
Image & | operator *= (const Image &rhs) |
Image & | operator/= (const Image &rhs) |
Public Attributes | |
DataType | elemtype_ |
Type of Image pixels, must be one of the values available in DataType. More... | |
uint8_t | elemsize_ |
Size (in bytes) of Image pixels. More... | |
std::vector< int > | dims_ |
std::vector< int > | strides_ |
Vector of Image strides. More... | |
std::string | channels_ |
String which describes how Image planes are organized. More... | |
ColorType | colortype_ |
Image ColorType. More... | |
std::vector< float > | spacings_ |
Space between pixels/voxels. More... | |
uint8_t * | data_ |
Pointer to Image data. More... | |
size_t | datasize_ |
Size of Image data in bytes. More... | |
bool | contiguous_ |
Whether the image is stored contiguously or not in memory. More... | |
MetaData * | meta_ |
Pointer to Image MetaData. More... | |
HardwareAbstractionLayer * | hal_ |
Pointer to the HardwareAbstractionLayer employed by the Image. More... | |
Device | dev_ |
Identifier for the device on which the image data is. More... | |
Protected Member Functions | |
void | SetDefaultStrides () |
Sets default strides for contiguous memory layouts. More... | |
size_t | GetDefaultDatasize () |
Gets the default datasize for contiguous images. More... | |
void | SetDefaultDatasize () |
Sets the default datasize for contiguous images. More... | |
Friends | |
class | HardwareAbstractionLayer |
void | swap (Image &lhs, Image &rhs) |
Image | operator+ (Image lhs, const Image &rhs) |
Image | operator- (Image lhs, const Image &rhs) |
Image | operator * (Image lhs, const Image &rhs) |
Image | operator/ (Image lhs, const Image &rhs) |
Image class.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Generic non-const Begin Iterator.
This function gives you a non-const generic Begin Iterator that can be used both for contiguous and non-contiguous non-const Images. It is useful to iterate over a non-const Image. If the Image is contiguous prefer the use of ContiguousIterato which in most cases improve the performance.
|
inline |
Generic const Begin Iterator.
This function gives you a const generic Begin Iterator that can be used both for contiguous and non-contiguous const Images. It is useful to iterate over a const Image. If the Image is contiguous prefer the use of ConstContiguousIterator which in most cases improve the performance.
|
inline |
|
inline |
Contiguous non-const Begin Iterator.
This function gives you a contiguous non-const Begin Iterator that can be used only for contiguous Images. If the Image is contiguous it is preferable to the non-contiguous iterator since it has usually better performance.
|
inline |
|
inline |
Contiguous non-const End Iterator.
This function gives you a contiguous non-const End Iterator that can be used only for contiguous Images.
|
inline |
|
inline |
void ecvl::Image::Create | ( | const std::vector< int > & | dims, |
DataType | elemtype, | ||
std::string | channels, | ||
ColorType | colortype, | ||
const std::vector< float > & | spacings = std::vector< float >() , |
||
Device | dev = Device::CPU |
||
) |
Allocates new contiguous data if needed.
The Create method allocates Image data as specified by the input parameters. The procedures tries to avoid the allocation of new memory when possible. The resulting image will be contiguous in any case. Calling this method on an Image that does not own data will always cause a new allocation, and the Image will become the owner of the data.
[in] | dims | New Image dimensions. |
[in] | elemtype | New Image DataType. |
[in] | channels | New Image channels. |
[in] | colortype | New Image colortype. |
[in] | spacings | New Image spacings. Default is an empty vector. |
[in] | dev | Device on which the Image is stored. Default is Device::CPU. |
|
inline |
|
inline |
|
inline |
|
inlineprotected |
|
inline |
|
inline |
|
inline |
|
inline |
Image ecvl::Image::operator- | ( | ) | const |
|
inline |
Returns a non-const pointer to data at given coordinates.
|
inline |
|
inlineprotected |
|
inlineprotected |
Sets default strides for contiguous memory layouts.
This function sets the strides so that by incrementing the data pointer by strides_[0] it moves to the next element (increments dimension 0), strides_[1] moves to the next dimension, and so on. For example for "xyc" images, incrementing by strides_[0] increments the column, incrementing by strides_[1] increments the row, incrementing by strides_[2] moves to the next color plane.
Requires elemsize_ and dims_ to be correctly setup.
|
inline |
|
inline |
|
inline |
std::string ecvl::Image::channels_ |
String which describes how Image planes are organized.
A single character provides the information related to the corresponding channel. The possible values are:
ColorType ecvl::Image::colortype_ |
Image ColorType.
If this is different from ColorType::none, the channels_ string must contain a 'c' and the corresponding dimension must have the appropriate value. See ColorType for the possible values.
If colortype_ is ColorType::none, then the image should not have a 'c' in the channels_ string.
bool ecvl::Image::contiguous_ |
uint8_t* ecvl::Image::data_ |
Pointer to Image data.
If the Image is not the owner of data, for example when using Image views, this attribute will point to the data of another Image. The possession or not of the data depends on the HardwareAbstractionLayer.
Device ecvl::Image::dev_ |
std::vector<int> ecvl::Image::dims_ |
Vector of Image dimensions. Each dimension is given in pixels/voxels.
uint8_t ecvl::Image::elemsize_ |
DataType ecvl::Image::elemtype_ |
HardwareAbstractionLayer* ecvl::Image::hal_ |
Pointer to the HardwareAbstractionLayer employed by the Image.
It can be CpuHal or ShallowCpuHal. The former is responsible for allocating and deallocating data, when using the CpuHal the Image is the owner of data. When ShallowCpuHal is employed the Image does not own data and operations on memory are not allowed or does not produce any effect.
std::vector<float> ecvl::Image::spacings_ |
std::vector<int> ecvl::Image::strides_ |