Image Component Library (ICL)
|
Encoder class for optimized encoding of images. More...
#include <ImageCompressor.h>
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::ImgBase * | uncompress (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 |
Encoder class for optimized encoding of images.
The ImageCompressor class allows for simple and for optimized serialization and desirealization of images
Right now, 3 different serialization modes are supported.
Only core::Img8u-images can be compressed. For all other formats, the compression mode "none" (with quality setting "none") has to be chosen.
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.
The ImageCompressor preserves an images meta data, however meta data is always binarized in an uncompressed manner.
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.
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.
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
icl::io::ImageCompressor::ImageCompressor | ( | const CompressionSpec & | spec = CompressionSpec("none") | ) |
Creates an image Compressor with given compression mode.
Destructor.
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
virtual CompressionSpec icl::io::ImageCompressor::getCompression | ( | ) | const [virtual] |
can be implemented for returning the current compression mode
Reimplemented in icl::io::GenericImageOutput.
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
virtual void icl::io::ImageCompressor::setCompression | ( | const CompressionSpec & | spec | ) | [virtual] |
string based interface for setting the compression mode
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
|
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
Data* icl::io::ImageCompressor::m_data [private] |
pimpl type
pimpl pointer
Reimplemented in icl::io::RSBImageOutput, icl::io::SharedMemoryPublisher, and icl::io::ZmqImageOutput.