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. 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::ImgBase * | uncompress (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... | |
Encoder class for optimized encoding of images.
The ImageCompressor class allows for simple and for optimized serialization and desirealization of images
Right now, 4 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
icl::io::ImageCompressor::ImageCompressor | ( | const CompressionSpec & | spec = CompressionSpec("none") | ) |
Creates an image Compressor with given compression mode.
icl::io::ImageCompressor::~ImageCompressor | ( | ) |
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
|
protected |
creates a header for a given image (not data will be null)
|
private |
internal utlity function
|
private |
internal utlity function
|
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 |
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
|
protected |
only decodes an image header
not supported for jpeg data
|
private |
pimpl type
pimpl pointer