What does Colour-Vision Deficiency and Discriminability conclude, in numbers, about “Linear Light and Relative Luminance: What WCAG Contrast Computes and What It Leaves Out”?

Answer: The lower part of the table deserves more attention. Code 128 looks like "middle grey" and normalises to 0.5020, yet it carries only 0.2159 of the linear light of white, about a fifth. Half the linear light needs code 188, whose linear value is 0.5029. Code 119 has linear value 0.1845, a number that will keep returning: it lies very close to the luminance at which white and black labels both barely pass. Code 64 has linear value 0.0513, and code 11 only 0.0033.

Scope of the numbers: Marked boxes separate published evidence, runnable Python calculations (21 programs), classical sources and the author's hypotheses.

中文版

Data table

The numbers below are printed verbatim by the chapter's Python program and can be reproduced by running it. standard-library Python onlyprinted values that match the answer: 0.0033, 0.0513, 0.1845, 0.2159, 0.5020, 0.5029

8-bit codes between the two thresholds0
largest change in linear value over 256 codes0.0e+00
code 100.039, code 11 -> 0.043 (as fraction of 255)
code encoded linear (linear share of white)
00.0000 0.0000
110.0431 0.0033
640.2510 0.0513
1190.4667 0.1845
1280.5020 0.2159
1880.7373 0.5029
2551.0000 1.0000
code nearest half the light188 (0.5029)
code 128 carries only 0.2159 of white
Show the full program
# Chapter 2. p21: the sRGB transfer curve and the WCAG threshold change.
# Model: IEC 61966-2-1 sRGB decoding; WCAG 2.2 notes that its threshold
# 0.04045 replaced 0.03928 in May 2021. We check every 8-bit code with
# both thresholds and print where mid-grey sits in linear light.
import math


def lin(c):
    v = c / 255.0
    if v <= 0.04045:
        return v / 12.92
    return ((v + 0.055) / 1.055) ** 2.4


def rgb(h):
    h = h.lstrip("#")
    return tuple(lin(int(h[i:i + 2], 16)) for i in (0, 2, 4))


def lum(c):
    return math.fsum((0.2126 * c[0], 0.7152 * c[1], 0.0722 * c[2]))


def contrast(a, b):
    hi, lo = sorted((lum(a), lum(b)), reverse=True)
    return (hi + 0.05) / (lo + 0.05)

def lin_old(c):
    v = c / 255.0
    if v <= 0.03928:
        return v / 12.92
    return ((v + 0.055) / 1.055) ** 2.4


if __name__ == "__main__":
    diff = [abs(lin(c) - lin_old(c)) for c in range(256)]
    between = [c for c in range(256)
               if 0.03928 < c / 255.0 <= 0.04045]
    print("8-bit codes between the two thresholds: {}".format(len(between)))
    print("largest change in linear value over 256 codes: {:.1e}".format(
        max(diff)))
    print("code 10 -> {:.3f}, code 11 -> {:.3f} (as fraction of 255)"
          .format(10 / 255.0, 11 / 255.0))
    print("code   encoded  linear   (linear share of white)")
    for c in (0, 11, 64, 119, 128, 188, 255):
        print("{:4d}   {:7.4f}  {:7.4f}".format(c, c / 255.0, lin(c)))
    half = min(range(256), key=lambda c: abs(lin(c) - 0.5))
    print("code nearest half the light: {} ({:.4f})".format(half,
                                                           lin(half)))
    print("code 128 carries only {:.4f} of white".format(lin(128)))

Single source and citation

Fan, Y. (2026). Simulating Colour-Vision Deficiency and Colour Discriminability: Buttons and Charts as Seen by Red-Green Colour-Deficient Users (Version 1.0.0), Chapter 2: Linear Light and Relative Luminance: What WCAG Contrast Computes and What It Leaves Out. 5D Library. DOI pending

DOI pending · monograph page goes live after publication · 5DL-B-324 · v1.0.0 · CC-BY-NC-ND-4.0

BibTeX
@book{fan2026324,
  author    = {Fan, Yafu},
  title     = {Simulating Colour-Vision Deficiency and Colour Discriminability: Buttons and Charts as Seen by Red-Green Colour-Deficient Users},
  year      = {2026},
  publisher = {5D Library},
  edition   = {1.0.0},
  note      = {DOI pending}
}

Other chapter answers in this book