Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

On-the-fly lossless image compression

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.

Update: my platform is an FPGA

like image 749
geschema Avatar asked Apr 13 '10 07:04

geschema


1 Answers

PNG provides free, open-source, lossless image compression in a standard format using standard tools. PNG uses zlib as part of its compression. There is also a libpng. Unless your platform is very unusual, it should not be hard to port this code to it.

like image 138
Norman Ramsey Avatar answered Dec 02 '22 03:12

Norman Ramsey