On-the-fly lossless image compression

Posted by geschema on Stack Overflow See other posts from Stack Overflow or by geschema
Published on 2010-04-13T07:40:58Z Indexed on 2010/04/13 7:42 UTC
Read the original article Hit count: 400

I have an embedded application where an image scanner sends out a stream of 16-bit pixels that are later assembled to a grayscale image. As I need to both save this data locally and forward it to a network interface, I'd like to compress the data stream to reduce the required storage space and network bandwidth.

Is there a simple algorithm that I can use to losslessly compress the pixel data?

I first thought of computing the difference between two consecutive pixels and then encoding this difference with a Huffman code. Unfortunately, the pixels are unsigned 16-bit quantities so the difference can be anywhere in the range -65535 .. +65535 which leads to potentially huge codeword lengths. If a few really long codewords occur in a row, I'll run into buffer overflow problems.

© Stack Overflow or respective owner

Related posts about embedded

Related posts about image-compression