Image Component Library (ICL)
Classes | Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
icl::io::ImageCompressor Class Reference

Encoder class for optimized encoding of images. More...

#include <ImageCompressor.h>

Inheritance diagram for icl::io::ImageCompressor:
icl::utils::Uncopyable icl::io::ImageOutput icl::io::FileWriter icl::io::GenericImageOutput icl::io::LibAVVideoWriter icl::io::OpenCVVideoWriter icl::io::RSBImageOutput icl::io::SharedMemoryPublisher icl::io::V4L2LoopBackOutput icl::io::ZmqImageOutput

Classes

struct  CompressedData
 most simple dyn-size array with given data and length More...
 
struct  CompressionSpec
 compression specification More...
 
struct  Header
 Compressed image header. More...
 

Public Member Functions

 ImageCompressor (const CompressionSpec &spec=CompressionSpec("none"))
 Creates an image Compressor with given compression mode. More...
 
 ~ImageCompressor ()
 Destructor. More...
 
virtual void setCompression (const CompressionSpec &spec)
 string based interface for setting the compression mode More...
 
virtual CompressionSpec getCompression () const
 can be implemented for returning the current compression mode More...
 
utils::Time pickTimeStamp (const icl8u *compressedData)
 this can help to find out wheter the data is new and must be encoded More...
 
const CompressedData compress (const core::ImgBase *image, bool skipMetaData=false)
 encodes a given image into the compressed code More...
 
const core::ImgBaseuncompress (const icl8u *compressedData, int len, core::ImgBase **dst=0)
 decodes the given byte segment More...
 

Protected Member Functions

Header uncompressHeader (const icl8u *compressedData, int len)
 only decodes an image header More...
 
Header createHeader (const core::ImgBase *image, bool skipMetaData)
 creates a header for a given image (not data will be null) More...
 
- Protected Member Functions inherited from icl::utils::Uncopyable
 Uncopyable ()
 Empty base constructor. More...
 

Private Member Functions

int estimateEncodedBufferSize (const core::ImgBase *image, bool skipMetaData)
 internal utlity function More...
 
int estimateRawDataSize (const core::ImgBase *image, bool skipMetaData)
 internal utlity function More...
 

Private Attributes

Data * m_data
 pimpl type More...
 

Detailed Description

Encoder class for optimized encoding of images.

The ImageCompressor class allows for simple and for optimized serialization and desirealization of images

Serialization Modes

Right now, 4 different serialization modes are supported.

Depth Support

Only core::Img8u-images can be compressed. For all other formats, the compression mode "none" (with quality setting "none") has to be chosen.

Serialization Structure

The serialized image consists of 3 parts: The Header information, which is exactly the binarized version of ImageCompressor::Header::Params. Optionally meta data, whose length can also be 0. And the actual compressed image data. The lengths of the meta data and the image data segements are defined by the header.

Image Meta Data

The ImageCompressor preserves an images meta data, however meta data is always binarized in an uncompressed manner.

ROI-Support

The image ROI is also compressed and later uncompressed. So if you compress an image with a non-full ROI, the uncompressed version will also be the whole image with a non-full ROI.

Benchmarks:

There are several factors, that have to be regarded: image size image fragmentation (b/w noise)

Both, the encoding /decoding steps should scale linearily with the image pixel count, while extremely vertical images provide in slower results. Also the image fragmentation is important for the en-/de-coding speed. Benchmarks were take on an Intel (R) Xeon E5530 @2.40GHz CPU, only single channel images were used.

Memory Consumption

In order to avoid run-time memory allocation, the run-length coder always ensures that enough bytes are available: I.e. 1 byte per image pixel

Constructor & Destructor Documentation

◆ ImageCompressor()

icl::io::ImageCompressor::ImageCompressor ( const CompressionSpec spec = CompressionSpec("none"))

Creates an image Compressor with given compression mode.

◆ ~ImageCompressor()

icl::io::ImageCompressor::~ImageCompressor ( )

Destructor.

Member Function Documentation

◆ compress()

const CompressedData icl::io::ImageCompressor::compress ( const core::ImgBase image,
bool  skipMetaData = false 
)

encodes a given image into the compressed code

JPEG compression does not yet meta data

◆ createHeader()

Header icl::io::ImageCompressor::createHeader ( const core::ImgBase image,
bool  skipMetaData 
)
protected

creates a header for a given image (not data will be null)

◆ estimateEncodedBufferSize()

int icl::io::ImageCompressor::estimateEncodedBufferSize ( const core::ImgBase image,
bool  skipMetaData 
)
private

internal utlity function

◆ estimateRawDataSize()

int icl::io::ImageCompressor::estimateRawDataSize ( const core::ImgBase image,
bool  skipMetaData 
)
private

internal utlity function

◆ getCompression()

virtual CompressionSpec icl::io::ImageCompressor::getCompression ( ) const
virtual

can be implemented for returning the current compression mode

Reimplemented in icl::io::GenericImageOutput.

◆ pickTimeStamp()

utils::Time icl::io::ImageCompressor::pickTimeStamp ( const icl8u compressedData)

this can help to find out wheter the data is new and must be encoded

not supported for jpeg data

◆ setCompression()

virtual void icl::io::ImageCompressor::setCompression ( const CompressionSpec spec)
virtual

string based interface for setting the compression mode

Parameters
spec(e.g. CompressionSpec("mode") with mode = rle, jpg, or none) the compression quality, which might depend on the set type (e.g. 1 Bit for binary rle, or 90 for 90% jpeg compression) Current valid compression modes are
  • "none" no compression (default, possible for all data types)
  • "rlen" run lenght encoding (quality can be 1, 4 or 6, it defines the number of bits, that are used for the value domain. Default value is 1, which is used for binary images)
  • "jpeg" jpeg encoding (quality is default jpeg quality 1% - 100%)

Reimplemented in icl::io::GenericImageOutput.

◆ uncompress()

const core::ImgBase* icl::io::ImageCompressor::uncompress ( const icl8u compressedData,
int  len,
core::ImgBase **  dst = 0 
)

decodes the given byte segment

◆ uncompressHeader()

Header icl::io::ImageCompressor::uncompressHeader ( const icl8u compressedData,
int  len 
)
protected

only decodes an image header

not supported for jpeg data

Member Data Documentation

◆ m_data

Data* icl::io::ImageCompressor::m_data
private

pimpl type

pimpl pointer


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