FLIF-hub / FLIF

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

Progressive previews of raw RGGB #159

Open jonsneyers opened 8 years ago

jonsneyers commented 8 years ago

As it is now, encoding a .rggb to .flif and decoding it to .pnm already produces a half-resolution image where each pixel is simply the R G1 B from the original (discarding the G2 and doing no interpolation at all). All that needs to be done is scale the values up using some kind of curve. This mechanism could be good for quick raw previewing (scaled down decoding with -s4 etc also works). Some kind of metadata would have to be added to provide the proper color curves.

psykauze commented 8 years ago

I've made some test by decoding RGGB-fliffed files with the parameter -q50 and reordering planes (G1BG2-R => RG1B) and I've got some good visual results (but without "color correction", pictures are "green-ish). PSNR is higher than 40dB comparing to -q100.

Is the -q parameters has the same effect than splitting the file ? I will try to cut 100kB of each files and decode them to see what happens.

jonsneyers commented 8 years ago

Yes, -q is the same as splitting the file, only the percentage is not a percentage of file size, but a percentage of subpixels (where planes 0 and 3 get priority, which would normally be alpha and luma).

Basically all that is needed to get decent progressive previews is to include the channel multipliers in the metadata in some standardized way. Then it's just a matter of hacking the decoder to automatically apply these multipliers except when converting back to the original .rggb. For quick previewing no demosaicing has to happen, G can be set to the average of G1 and G2, and the highest resolution would be half-scale. That is fine -- you wouldn't use flif to actually cook your raw photographs, just to store them efficiently while viewflif can still display them reasonably well, reasonably fast.

That would give FLIF-compressed raw files an edge over black-box raw compressors which take the raw data and compress it using preprocessing and strong general-purpose compression. In order to render a preview, they would require either separate preview images (sidecar JPEG files or something), or slow full decoding + processing.