jwagner / analog-film-emulator

A web based analog film emulator/photo editor.
http://29a.ch/film-emulator/
256 stars 31 forks source link

Gamma encoded everywhere #4

Open Tegmen opened 8 years ago

Tegmen commented 8 years ago

Why do you always work with gamma encoded data? Is the performance difference that big?

For example line 182 in image-processing.js let plum = (pmax + pmin) / 2; should imo be let plum = pow(pow(pmax,gamma) + pow(pmin,gamma), 1/ gamma) / 2;

The same for dithering. Photoshop does its dithering also gamma encoded, which leads to artefacts, especially when working with already dithered images. One might think that the difference is not noticeable , but this shows the difference.

// leave values gamma encoded, results are practically nicer

what do you mean, "nicer"? RGB to grayscale conversion is imo much more accurate when done unencoded, as this project demonstrates. However, you cant use [0.2126,0.7152,0.0722] any more when with unencoded data. I came up with [0.2,0.52,0.28] for unencoded data. Its not ideal, but much better than all the conversions that use gamma encoded RGB values.

Great project btw!

jwagner commented 8 years ago

Oh, sorry for missing this for so long.

Why do you always work with gamma encoded data? Is the performance difference that big?

As far as I remember and from what the comment suggests I tried to do the adjustments both in gamma and linear space and preferred the gamma way the sliders behaved when operating on the gamma encoded data. But I'm not entirely sure anymore

Ditherlicious does it's dithering operations in linear space. But it also matters a lot more when dithering down to 1 bit rather than 8. :)