Confirm that babl_space_get_rgb_luminance() should be used on linear values only
@ok We have this report gimp#3471 where luminance is different depending on whether we in linear or not (for the same color), e.g. scRGB vs, sRGB. I can see that babl_space_get_rgb_luminance()
returns the same RGB coefficients for both spaces.
In [2]: Babl.init()
In [3]: space = Babl.space("sRGB")
In [4]: space2 = Babl.space("scRGB")
In [5]: Babl.space_get_rgb_luminance(space)
Out[5]: (red_luminance=0.2224879400268659, green_luminance=0.7169038388792531, blue_luminance=0.060608257216285655)
In [6]: Babl.space_get_rgb_luminance(space2)
Out[6]: (red_luminance=0.2224879400268659, green_luminance=0.7169038388792531, blue_luminance=0.060608257216285655)
As a consequence, right now, we get different luminance values (which is wrong obviously since it's the same color simply expressed in different spaces), and even comparing luminance of 2 pixels give a different comparison result depending on whether we use linear or non-linear data (i.e. that a color which has a higher luminance in RGB has a lower one in R'G'B' which is obviously wrong too).
Should the returned luminance coefficients be different for both spaces? In which case, there might be a bug in babl.
Or simply should these coefficients only ever be used on linear data only? This second case might be the right one, reading some SO answer saying data must be linearized before computing luminance. Though I'd like confirmation.