I wish to exploit redundancy among a set of similar colored JPG
images. Set redundancy compression
has been used successfully for similar 8-bit grayscale
images. They basically find the MAX
and MIN
of a set of images and encode the original images as differences
with respect to either the MAX or MIN image, depending on whichever is the smaller difference. About 20-50% additional compression has been obtained for grayscale images using this approach besides normal compression tools like gzip or bzip. I do the following:
- Decompress the JPG images to RGB char buffers
- Compute the MIN and MAX char buffers
- Encode the difference char buffers as JPG images
The problem is that to retrieve the original image from the difference image, ideally I would need to encode the difference losslessly. But, there is no lossless
transformation from RGB->JPG in libjpeg and even at quality=1.0, because the difference coefficients are small (1~10), I end up losing almost all the information (almost all decoded data is 1~3).
To solve this, I tried using huffman encoding
of the difference char buffers.
- Encode the difference char buffers using Huffman encoding
The original JPG images are of size ~256 KB, the corresponding RGB buffer is ~7.8 MB and the huffman encoded difference images are of size ~2.2 MB. So, Huffman encoding does save lot of space w.r.t RGB buffers but the original JPG equivalents are much smaller.
- Any suggestions to store these difference buffers efficiently comparable in size to the 256 KB original
JPG
files ? - Is there a way to save these difference buffers with
low valued data coefficients
as JPG images without losing substantial information ?