Search code examples
accessibilitycolor-spacewcag

What does "Maximum relative luminance" in WCAG 2.0 general flash definition refer to?


I'm trying to write video analysis software to check compliance with WCAG 2.0 seizure guidelines. But, in the definition of 'general flash', it states the following:

A general flash is defined as a pair of opposing changes in relative luminance of 10% or more of the maximum relative luminance (...)

I am confused about the usage of "maximum relative luminance". It's not specified in which context we are considering the maximum. Does it refer to 1.0 luminance? Or the maximum luminance achieved in the webpage? Or something else?

I couldn't find any clarification. I would just assume that it refers to 1.0 luminance, but, if that assumption were wrong, my code would produce false negatives in flash detection due to an incorrectly high threshold.

Sorry if I'm missing something obvious or if this is the wrong place to ask.


Solution

  • Maximum relative luminance is simply the maximum luminance using the equation at the end of this answer.

    The reason "maximum relative luminance" is used is that there are other colour spaces, but as this is web the RGB colour space is used. (so for example you could use the CMYK colour space and a different calculation would be used. However the end result is the same, 1 would be white and 0 would be black).

    The 10% maximum refers to the difference between the maximum luminance vs the minimum luminance (but 10% of the maximum luminance as the difference not 10% of the minimum as that would result in a smaller difference).

    So for example:-

    1. If the lightest value has a luminance of 0.9 then the minimum luminance for the darkest point is 0.81 (0.9 * 10% = 0.09, 0.9 - 0.09 = 0.81).
    2. Due to a second rule the following is acceptable despite being greater than a 10% variance - lightest value 0.99, darkest value 0.8 - this has a ~20% difference but the darkest value is at 0.8 relative luminance so it is OK.
    3. If the lightest value has a luminance of 0.9 but the darkest luminance is 0.72 then this would require that less than 3 flashes a second occur as the difference is 20% (1 - (0.9 / 0.72) = 0.2 or 20%)

    The second statement is ok due to the following note on the rules:

    A general flash is defined as a pair of opposing changes in relative luminance of 10% or more of the maximum relative luminance where the relative luminance of the darker image is below 0.80; and where "a pair of opposing changes" is an increase followed by a decrease, or a decrease followed by an increase

    There is a brilliant codepen that explains the relative luminance equation (points 1 to 4):

    https://codepen.io/bcdon/full/qBWwWyx

    Included as you have to include code with a codepen...this is the formula for Luminance using the RGB colour space.

     L = 0.2126 * R + 0.7152 * G + 0.0722 * B