Image Component Library (ICL)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Classes | Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes
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::OpenCVVideoWriter icl::io::RSBImageOutput icl::io::SharedMemoryPublisher icl::io::ZmqImageOutput

List of all members.

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

Protected Member Functions

Header uncompressHeader (const icl8u *compressedData, int len)
 only decodes an image header
Header createHeader (const core::ImgBase *image, bool skipMetaData)
 creates a header for a given image (not data will be null)

Private Member Functions

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

Private Attributes

Data * m_data
 pimpl type

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, 3 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.

Region of Interest (ROI)

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 + header size of 37 + N bytes (N is meta data size)
for JPEG data, 2x the raw image data is allocated


Constructor & Destructor Documentation

Creates an image Compressor with given compression mode.

Destructor.


Member Function Documentation

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

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

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

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

internal utlity function

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

internal utlity function

can be implemented for returning the current compression mode

Reimplemented in icl::io::GenericImageOutput.

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

not supported for jpeg data

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.

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

decodes the given byte segment

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

only decodes an image header

not supported for jpeg data


Member Data Documentation

pimpl type

pimpl pointer

Reimplemented in icl::io::RSBImageOutput, icl::io::SharedMemoryPublisher, and icl::io::ZmqImageOutput.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines