关于「CIELAB 与 CIEDE2000:把「看得出差别」写成一个数」,《色觉缺陷模拟与配色可辨性》给出的定量结论是什么?

结论:两个公式的分歧在中等阈值处最大。以五为阈值,CIE76 认为只有 0.068 的组合撞色,CIEDE2000 认为有 0.200,相差约三倍;以十为阈值,CIE76 为 0.264,CIEDE2000 为 0.555。以三为阈值,两者分别为 0.025 与 0.073。在很小的阈值一处,两者都不到百分之一;在很大的阈值二十处,两者分别为 0.672 与 0.919。最后一行说明,有 209 对组合在 CIE76 下相差十以上,按 CIEDE2000 却不到五:用 CIE76 做检查,这些组合会被判为「明显可分」,而它们在更接近人眼的公式下属于「很难分开」。

数据口径:书中参数为示意;全部计算由书中程序生成;模拟不对应任何具体的人,本书不对任何个人的色觉作判断,属于非个人化经营建议。 本书用色觉模拟与色差计算推翻这条推理。

English version

对照数据表

下表数字由本章 Python 程序原样打印,可重新运行复现。 程序只用 Python 标准库与结论吻合的打印值: 0.025, 0.068, 0.073, 0.200, 0.264, 0.555

deutan view, 9000 red/green pairs
thresholdshare CIE76share CIEDE2000
10.0040.009
20.0130.033
30.0250.073
50.0680.200
80.1730.421
100.2640.555
150.4890.791
200.6720.919
pairs with CIE76 >= 10 but CIEDE2000 < 5: 209
查看完整验算程序
# Chapter 4. p42: CIE76 against CIEDE2000, and the threshold you choose.
# Model: the red/green pairs of p13 (white labels >= 4.5:1) under the
# Machado 2009 deuteranopia simulation; the share of pairs below each
# threshold under both formulas. The thresholds are illustrative.
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)

# Machado, Oliveira and Fernandes 2009, Table 1, severity 1.0 (rows).
MACHADO = {
    "protan": ((0.152286, 1.052583, -0.204868),
               (0.114503, 0.786281, 0.099216),
               (-0.003882, -0.048116, 1.051998)),
    "deutan": ((0.367322, 0.860646, -0.227968),
               (0.280085, 0.672501, 0.047413),
               (-0.011820, 0.042940, 0.968881)),
    "tritan": ((1.255528, -0.076749, -0.178779),
               (-0.078411, 0.930809, 0.147602),
               (0.004733, 0.691367, 0.303900)),
}


def sim(c, kind):
    # applied to linear sRGB, then clipped to the display range
    if kind == "normal":
        return tuple(c)
    out = []
    for row in MACHADO[kind]:
        v = math.fsum(m * x for m, x in zip(row, c))
        out.append(min(1.0, max(0.0, v)))
    return tuple(out)

SRGB_XYZ = ((0.4124, 0.3576, 0.1805),
            (0.2126, 0.7152, 0.0722),
            (0.0193, 0.1192, 0.9505))


def xyz(c):
    return tuple(math.fsum(m * x for m, x in zip(row, c))
                 for row in SRGB_XYZ)


WHITE = xyz((1.0, 1.0, 1.0))


def _f(t):
    d = 6.0 / 29.0
    if t > d ** 3:
        return t ** (1.0 / 3.0)
    return t / (3.0 * d * d) + 4.0 / 29.0


def lab(c):
    fx, fy, fz = (_f(v / w) for v, w in zip(xyz(c), WHITE))
    return (116.0 * fy - 16.0, 500.0 * (fx - fy), 200.0 * (fy - fz))


def de00(p, q):
    # CIEDE2000 with kL = kC = kH = 1 (Sharma, Wu and Dalal 2005)
    l1, a1, b1 = p
    l2, a2, b2 = q
    cm = (math.hypot(a1, b1) + math.hypot(a2, b2)) / 2.0
    g = 0.5 * (1.0 - math.sqrt(cm ** 7 / (cm ** 7 + 25.0 ** 7)))
    a1p, a2p = (1.0 + g) * a1, (1.0 + g) * a2
    c1p, c2p = math.hypot(a1p, b1), math.hypot(a2p, b2)
    h1p = math.degrees(math.atan2(b1, a1p)) % 360.0 if c1p else 0.0
    h2p = math.degrees(math.atan2(b2, a2p)) % 360.0 if c2p else 0.0
    dl, dc = l2 - l1, c2p - c1p
    if c1p * c2p == 0.0:
        dhp = 0.0
    else:
        dhp = h2p - h1p
        if dhp > 180.0:
            dhp -= 360.0
        elif dhp < -180.0:
            dhp += 360.0
    dh = 2.0 * math.sqrt(c1p * c2p) * math.sin(math.radians(dhp / 2.0))
    lm, cmp_ = (l1 + l2) / 2.0, (c1p + c2p) / 2.0
    if c1p * c2p == 0.0:
        hm = h1p + h2p
    elif abs(h1p - h2p) <= 180.0:
        hm = (h1p + h2p) / 2.0
    elif h1p + h2p < 360.0:
        hm = (h1p + h2p + 360.0) / 2.0
    else:
        hm = (h1p + h2p - 360.0) / 2.0
    r = math.radians
    t = math.fsum((1.0, -0.17 * math.cos(r(hm - 30.0)),
                   0.24 * math.cos(r(2.0 * hm)),
                   0.32 * math.cos(r(3.0 * hm + 6.0)),
                   -0.20 * math.cos(r(4.0 * hm - 63.0))))
    dtheta = 30.0 * math.exp(-((hm - 275.0) / 25.0) ** 2)
    rc = 2.0 * math.sqrt(cmp_ ** 7 / (cmp_ ** 7 + 25.0 ** 7))
    sl = 1.0 + 0.015 * (lm - 50.0) ** 2 / math.sqrt(20.0 + (lm - 50.0) ** 2)
    sc = 1.0 + 0.045 * cmp_
    sh = 1.0 + 0.015 * cmp_ * t
    rt = -math.sin(2.0 * r(dtheta)) * rc
    x, y, z = dl / sl, dc / sc, dh / sh
    return math.sqrt(math.fsum((x * x, y * y, z * z, rt * y * z)))


def de76(p, q):
    return math.sqrt(math.fsum((u - v) ** 2 for u, v in zip(p, q)))


def hsv_code(h, s, v):
    # HSV (degrees, 0-1, 0-1) to 8-bit sRGB codes
    c = v * s
    hp = (h % 360.0) / 60.0
    x = c * (1.0 - abs(hp % 2.0 - 1.0))
    r, g, b = ((c, x, 0.0), (x, c, 0.0), (0.0, c, x),
               (0.0, x, c), (x, 0.0, c), (c, 0.0, x))[int(hp) % 6]
    m = v - c
    return tuple(int(round((u + m) * 255.0)) for u in (r, g, b))


def hexs(codes):
    return "#{:02X}{:02X}{:02X}".format(*codes)


def hue(c):
    r, g, b = (u / 255.0 for u in c)
    mx, mn = max(r, g, b), min(r, g, b)
    if mx == mn:
        return -1.0
    d = mx - mn
    if mx == r:
        h = ((g - b) / d) % 6.0
    elif mx == g:
        h = (b - r) / d + 2.0
    else:
        h = (r - g) / d + 4.0
    return 60.0 * h

W = (1.0, 1.0, 1.0)


def candidates():
    reds, greens = [], []
    for h in (350, 355, 0, 5, 10):
        for s in (0.70, 0.85, 1.00):
            for i in range(11):
                reds.append(hsv_code(h, s, 0.50 + 0.05 * i))
    for h in (100, 110, 120, 130, 140):
        for s in (0.70, 0.85, 1.00):
            for i in range(15):
                greens.append(hsv_code(h, s, 0.30 + 0.05 * i))
    keep = []
    for group in (reds, greens):
        ok = sorted({c for c in group
                     if contrast(tuple(lin(u) for u in c), W) >= 4.5})
        keep.append(ok)
    return keep


if __name__ == "__main__":
    reds, greens = candidates()
    d76, d00 = [], []
    for a in reds:
        la = lab(sim(tuple(lin(u) for u in a), "deutan"))
        for b in greens:
            lb = lab(sim(tuple(lin(u) for u in b), "deutan"))
            d76.append(de76(la, lb))
            d00.append(de00(la, lb))
    n = len(d00)
    print("deutan view, {} red/green pairs".format(n))
    print("threshold  share CIE76  share CIEDE2000")
    for t in (1, 2, 3, 5, 8, 10, 15, 20):
        print("{:9d}  {:11.3f}  {:15.3f}".format(
            t, len([x for x in d76 if x < t]) / n,
            len([x for x in d00 if x < t]) / n))
    big = len([1 for x, y in zip(d76, d00) if x >= 10 and y < 5])
    print("pairs with CIE76 >= 10 but CIEDE2000 < 5: {}".format(big))

唯一数据源与引用

范雅福(Fan, Y.). (2026). 《色觉缺陷模拟与配色可辨性、红绿色弱用户眼中的按钮与图表母典》第 4 章「CIELAB 与 CIEDE2000:把「看得出差别」写成一个数」(版本 1.0.0). 5D Library. DOI 待发布

DOI 待发布 · 专著页正式发布后上线(本站暂无专著页) · 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}
}

本书其他章节结论