njsmith / colorspacious

A powerful, accurate, and easy-to-use Python library for doing colorspace conversions
MIT License
169 stars 16 forks source link

Clarification of sRGB L_A calculation #3

Closed deanm closed 7 years ago

deanm commented 8 years ago

I know this was changed and considered a "serious bug" in 9a4d871, however I haven't managed to follow your calculation.

In "Colorimetry: Understanding the CIE System" (ISBN: 978-0-470-04904-4), page 294 states equation 11.A1:

The L_A is computed: L_A = (E_W/PI) * (Y_b/Y_W) where E_W = PI * L_W is the illuminance of reference white in lux unit; L_W the luminance of reference white in cd/m2 unit, Y_b the luminance factor of the background, and Y_W the luminance factor of the reference white.

Given the sRGB viewing environment stated here:

https://en.wikipedia.org/wiki/SRGB#Viewing_environment

Wouldn't that seem to be something more like 80 / 5 = 16?

This also happens to match the value stated in Table 16.3 on page 298 in "Color Appearance Models, 3rd Edition" (ISBN: 978-1-119-96703-3), which gives the "Viewing self-luminous display in office" L_A a value of 16 for an average surround.

Additional reference, p. 25, table 2.1 states a value of 15 for office (average surround).

http://www.springer.com/cda/content/document/cda_downloaddocument/9781441961891-c1.pdf

Thanks!

njsmith commented 8 years ago

That's... a really interesting question.

So I think the discrepancy here is that sRGB actually specifies two different luminance conditions: notice that in that table on wikipedia, there's the "viewing environment" luminance at 80 cd/m^2, and the "encoding ambient illuminance level" at 64 lux = 64/pi cd/m^2 ~= 20.4 cd/m^2.

It's not obvious which of these numbers CIECAM02 should be using. Currently, colorspacious uses the latter. This is independent of the "serious bug", which is that we were calculating L_A as 20.4 cd/m^2 * 5 ~= 100 instead of 20.4 cd/m^2 / 5 ~= 4. So that was definitely a bug that needed fixing independently of this issue :-).

However, I really don't understand the games that the sRGB standard is playing with "viewing" versus "encoding" conditions, and it could be that the you're right, and the 80 cd/m^2 value is the one that we ought to be using. The reason I did it this way is that Moroney (2002), when giving recommendations for how to use CIECAM97s, the precursor to CIECAM02, says:

"For example, the sRGB standard has an ambient illumination level of 64 lux or an L_A value of 4. Annex D in the sRGB standard provides a typical office ambient illumination of 350 lux or an L_A value of 22. [...]

"An example is useful to illustrate how surround is determined. For the sRGB specification, the ambient illumination level is 64 lux and the monitor white is 80 cd/m^2. Using equation 1 the surround luminance can be computed to be 20.4 cd/m^2..."

From this I think (but am not certain!) that what's going on is the sRGB spec assumes that we are looking at a monitor that outputs 80 cd/m^2, in a room whose lighting is otherwise 64 lux, and that it's the latter number we're supposed to use for computing L_A.

If this is wrong, then I'd very much like to know, though I'm not sure who to ask...

Note also that the parameters from the sRGB spec may or may not be a good fit for your particular setting. The 64 lux value definitely corresponds to a rather dim setting (I think it's supposed to simulate, like, watching a movie with the lights off and curtains closed), and if you'd rather do calculations assuming a "typical office environment" then you're free to use a different L_A regardless of what sRGB says. But I do want to know what sRGB says, because I think that's the only reasonable way for us to set our defaults, even if it turns out to be a bit weird.

njsmith commented 8 years ago

CC @KelSolaar

KelSolaar commented 8 years ago

80 cd.m^-2 is indeed the white point Luminance of the display and not Luminance of the background / surround.

KelSolaar commented 8 years ago

This page from ICC cites IEC 61966-2-1:1999 which should give you what you need: http://www.color.org/chardata/rgb/srgb.xalter

deanm commented 8 years ago

Perhaps I misunderstand, but I believe the formula used for L_A does use the luminance of the reference white:

https://en.wikipedia.org/wiki/CIECAM02#Parameter_decision_table

""" The absolute luminance of the adapting field, which is a quantity that will be needed later, should be measured with a photometer. If one is not available, it can be calculated using a reference white:

...

where Yb is the relative luminance of background, the Ew = πLW is the illuminance of the reference white in lux, LW is the absolute luminance of the reference white in cd/m2, and Yw is the relative luminance of the reference white in the adapting field. If unknown, the adapting field can be assumed to have average reflectance ("gray world" assumption): LA = LW / 5. """

So doesn't that lead to, LW = 80 (absolute luminance of reference white in cd/m2), Yb/YW = 1/5 ?

njsmith commented 8 years ago

sRGB defines two different reference whites: the reference white of the medium (the monitor itself), and the reference white of the viewing environment (the rest of the room).

So we have an unambiguous statement from Nathan Moroney (who chaired the committee that designed CIECAM02) saying that L_A should be calculated using the 20.4 cd/m^2 value, and an ambiguous statement from wikipedia that is open to interpretation, but that you interpret as saying it should use the 80 cd/m^2 value. Given that I can't really make a definitive statement myself, I'm open to the possibility that Nathan Moroney is wrong -- we all have off days, or maybe there's some obscure technical change that happened between CIECAM97s and CIECAM02! But it will need much more to convince me than this :-).