FLIF-hub / FLIF

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

Halftone / dither patterns don't compress well #140

Open jonsneyers opened 8 years ago

jonsneyers commented 8 years ago

Repetitive patterns, in particular patterns that are the result of halftoning or color dithering (e.g. by starting from a GIF file or a high-resolution scan of a print), do not compress very well with FLIF's MANIAC encoding. Other examples are: game sprite sheets, rendered text.

LZ(W)-based methods like gzip, PNG and GIF can handle such repetitive patterns much better.

Further research is needed to figure out how to combine MANIAC with LZ to get a "best of both worlds" scheme. If combining the two methods is too tricky, then at least FLIF could get some kind of "fall-back" method for entropy coding for such images.

Having fall-back methods for entropy coding is a good idea anyway. One trivial but potentially useful fall-back method would be "don't compress". This would be useful e.g. when the image is pure noise. At the very least, FLIF should not be worse than raw PNM, which it currently is for pure noise.

jessetrana commented 6 years ago

As a slightly different way of tackling this problem, is there anything like the Burrows-Wheeler transform that would make sense as a transformation step? (https://en.wikipedia.org/wiki/Burrows%E2%80%93Wheeler_transform) Might keep from having to dig too deep into the actual pixel encoding?