FLIF-hub / FLIF

Free Lossless Image Format
Other
3.72k stars 228 forks source link

use colour space conversion to significantly improve compression #141

Closed StephanBusch closed 8 years ago

StephanBusch commented 8 years ago

converting the RGB color space to YCbCr before applying MANIAC compression would significantly improve compression ratio on all images. The conversion is lossless which means you can recreate the RGB channels pixel-perfect.

Tilo Strutz wrote a paper about that in 2012: http://www1.hft-leipzig.de/strutz/Papers/strutz-2012-CSVT_preprint.pdf

In my own tests there were also huge gains when converting RGB to Lab colour space:

canon24-rgb.tif 53.780.338 bytes canon24-lab.tif 53.770.616 bytes canon24-rgb.tif.lzma 32.166.986 bytes canon24-lab.tif.lzma 27.696.351 bytes

sipa commented 8 years ago

FLIF uses a lossless approximation of the YIQ color space internally, which seems to be practically identical to the YCbCr you're referring to (I've actually suggested a few times changing the name of our YIQ color space to YCbCr...).

jonsneyers commented 8 years ago

The color transformation we're using is YCgCo (https://en.wikipedia.org/wiki/YCgCo), but we use Y, Co, -Cg (of course that sign doesn't matter), which is a (very) rough reversible approximation of YIQ (https://en.wikipedia.org/wiki/YIQ). The idea is that from those two chroma channels, Co is visually somewhat more important than Cg, and we're giving priority to Co in the compressed stream, which is good for progressive decoding.

jonsneyers commented 8 years ago

Closing since we're already doing this.