Solar
Public Types | Public Member Functions | Protected Member Functions | Friends | List of all members
SolAR::datastructure::Image Class Reference

A 2D image.. More...

#include <Image.h>

Public Types

enum  DataType { TYPE_8U , TYPE_16U , TYPE_32U , TYPE_64U }
 
enum  ImageLayout {
  LAYOUT_RGB =0 , LAYOUT_BGR , LAYOUT_GREY , LAYOUT_RGBA ,
  LAYOUT_RGBX , LAYOUT_UNDEFINED
}
 
enum  ColorSpace { SPACE_RGB_709 =0 , SPACE_GREY , SPACE_UNDEFINED }
 
enum  PixelOrder { INTERLEAVED =0 , PER_CHANNEL }
 
enum  ImageEncoding { ENCODING_NONE =0 , ENCODING_JPEG , ENCODING_PNG }
 

Public Member Functions

 Image (enum ImageLayout pixLayout, enum PixelOrder pixOrder, DataType type)
 Image. More...
 
 Image (uint32_t width, uint32_t height, enum ImageLayout pixLayout, enum PixelOrder pixOrder, DataType type)
 Image. More...
 
 Image (void *imageData, uint32_t width, uint32_t height, enum ImageLayout pixLayout, enum PixelOrder pixOrder, DataType type, ImageEncoding encoding=ENCODING_NONE)
 Image built from a raw data pointer. More...
 
 ~Image ()=default
 ~Image
 
SRef< Imagecopy () const
 copy the current Image More...
 
void setSize (uint32_t width, uint32_t height)
 reserves new space depending on the image layers and bitspercomponent infos More...
 
void setSize (Sizei size)
 reserves new space depending on the image layers and bitspercomponent infos More...
 
uint32_t getBufferSize ()
 get bytes size of underlying storage
 
void * data ()
 never use this accessor to delete the underlying data !
 
const void * data () const
 never use this accessor to delete the underlying data !
 
SRef< ImageextractRegion (Rectanglei region)
 extracts a subregion for tiling for interleaved data representation only More...
 
SRef< ImageextractRegion (Rectanglei region, uint32_t channel)
 extracts a subregion for tiling for a single plane inside a multiplanar image More...
 
enum ImageLayout getImageLayout () const
 returns the image layout
 
enum PixelOrder getPixelOrder () const
 returns the pixel order
 
enum DataType getDataType () const
 returns the dataType
 
uint32_t getNbChannels () const
 returns the number of channels
 
uint32_t getNbBitsPerComponent () const
 returns the amount of bit per component
 
Sizei getSize () const
 returns the size of the image
 
uint32_t getWidth () const
 returns height of the image
 
uint32_t getHeight () const
 returns height of the image
 
uint32_t getStep () const
 
void setImageEncoding (enum ImageEncoding encoding)
 set encoding for the image
 
enum ImageEncoding getImageEncoding () const
 returns encoding of the image
 
void setImageEncodingQuality (uint8_t encodingQuality)
 set encoding quality for the image Must be set between 100 and 0: 100 for loseless compression, 0 to low quality and high compression rate
 
uint8_t getImageEncodingQuality () const
 returns encoding quality of the image
 
template<typename T >
T & getPixel (int row, int col)
 Get pixel value. More...
 
template<typename T >
const T & getPixel (int row, int col) const
 Get pixel value. More...
 
FrameworkReturnCode save (std::string imagePath) const
 Save the image in a file. More...
 
FrameworkReturnCode load (std::string imagePath)
 Load an image from a file. More...
 

Protected Member Functions

template<class Archive >
void save (Archive &ar, const unsigned int version) const
 
template<class Archive >
void load (Archive &ar, const unsigned int version)
 

Friends

class boost::serialization::access
 

Detailed Description

A 2D image..

This class provides an image abstraction for SolAR

Member Enumeration Documentation

◆ ColorSpace

Enumerator
SPACE_RGB_709 

means ColorSpace is RGB 709

SPACE_GREY 

means ColorSpace is GREY

◆ DataType

Enumerator
TYPE_8U 

each pixel part information is stored in one unsigned integer byte. For instance, an RGBA layer image is stored in 4 bytes, one byte per channel

TYPE_16U 

each pixel part information is stored in two unsigned integer bytes. For instance, an RGBA layer image is stored in 8 bytes, two bytes per channel

TYPE_32U 

each pixel part information is stored in four unsigned integer bytes. For instance, an RGBA layer image is stored in 16 bytes, four bytes per channel

TYPE_64U 

each pixel part information is stored in height unsigned integer bytes. For instance, an RGBA layer image is stored in 32 bytes, eight bytes per channel

◆ ImageLayout

Enumerator
LAYOUT_RGB 

means 3 channels per pixel : Red, Green, Blue

LAYOUT_BGR 

means 3 channels per pixel : Green,Red, Blue (this is opencv model)

LAYOUT_GREY 

means 1 channel per pixel : grey color

LAYOUT_RGBA 

means 4 channels per pixel : Red, Green, Blue and Alpha channel

LAYOUT_RGBX 

means 4 channels per pixel : Red, Green, Blue and transparency

◆ PixelOrder

Enumerator
INTERLEAVED 

means channels are interleaved. For instance for LAYOUT RGBA, pixels are stored RGBARGBARGBA and so on...

PER_CHANNEL 

means data buffer holds separately each image channel. For instance for an RGBA layout image, pixels are stored gathered by layer : RRRR....GGGG....BBBB....AAAA....

Constructor & Destructor Documentation

◆ Image() [1/3]

SolAR::datastructure::Image::Image ( enum ImageLayout  pixLayout,
enum PixelOrder  pixOrder,
DataType  type 
)

Image.

Parameters
pixLayoutdefined by ImageLayout
pixOrderdefined if the data are stored interleaved RGB,RGB or as a planar representation RRR,GGG,BBB
typedefined by DataType

◆ Image() [2/3]

SolAR::datastructure::Image::Image ( uint32_t  width,
uint32_t  height,
enum ImageLayout  pixLayout,
enum PixelOrder  pixOrder,
DataType  type 
)

Image.

Parameters
widthwidth of the image
heightheight of the image
pixLayoutdefined by ImageLayout
pixOrderdefined if the data are stored interleaved RGB,RGB or as a planar representation RRR,GGG,BBB
typedefined by DataType

◆ Image() [3/3]

SolAR::datastructure::Image::Image ( void *  imageData,
uint32_t  width,
uint32_t  height,
enum ImageLayout  pixLayout,
enum PixelOrder  pixOrder,
DataType  type,
ImageEncoding  encoding = ENCODING_NONE 
)

Image built from a raw data pointer.

Parameters
imageDatapointer to the raw data
widthwidth of the image
heightheight of the image
pixLayoutdefined by ImageLayout
pixOrderdefined if the data are stored interleaved RGB,RGB or as a planar representation RRR,GGG,BBB
typedefined by DataType
encodingimage encoding (PNG, JPG or NONE by default)

Member Function Documentation

◆ copy()

SRef< Image > SolAR::datastructure::Image::copy ( ) const

copy the current Image

Return values
ashared_ptr to the copy of the current Image

◆ extractRegion() [1/2]

SRef< Image > SolAR::datastructure::Image::extractRegion ( Rectanglei  region)

extracts a subregion for tiling for interleaved data representation only

Parameters
regiondefines the region to extract as a rectangle
channelassumes planar representation of the image

◆ extractRegion() [2/2]

SRef< Image > SolAR::datastructure::Image::extractRegion ( Rectanglei  region,
uint32_t  channel 
)

extracts a subregion for tiling for a single plane inside a multiplanar image

Parameters
regiondefines the regoion to extract as a rectangle
channelassumes planar representation of the image

◆ getPixel() [1/2]

template<typename T >
T & SolAR::datastructure::Image::getPixel ( int  row,
int  col 
)
inline

Get pixel value.

Parameters
[in]rowrow index.
[in]colcolumn index.
Returns
the pixel value

◆ getPixel() [2/2]

template<typename T >
const T & SolAR::datastructure::Image::getPixel ( int  row,
int  col 
) const
inline

Get pixel value.

Parameters
[in]rowrow index.
[in]colcolumn index.
Returns
the pixel value

◆ load()

FrameworkReturnCode SolAR::datastructure::Image::load ( std::string  imagePath)

Load an image from a file.

Parameters
[in]imagePathpath to the file with suffix .jpg, .jpeg or .png.
Returns
SUCCESS if the image is saved, _ERROR otherwise.

◆ save()

FrameworkReturnCode SolAR::datastructure::Image::save ( std::string  imagePath) const

Save the image in a file.

Parameters
[in]imagePathpath to the file with suffix .jpg, .jpeg or .png.
Returns
SUCCESS if the image is saved, _ERROR otherwise.

◆ setSize() [1/2]

void SolAR::datastructure::Image::setSize ( Sizei  size)

reserves new space depending on the image layers and bitspercomponent infos

Parameters
Sizesize of the image

◆ setSize() [2/2]

void SolAR::datastructure::Image::setSize ( uint32_t  width,
uint32_t  height 
)

reserves new space depending on the image layers and bitspercomponent infos

Parameters
widthwidth of the image
heightheight of the image

The documentation for this class was generated from the following files: