关于「感知均匀的颜色空间:从 sRGB 到 CIELAB、CIEDE2000 与 OKLab」,《跨站设计令牌与感知色彩》给出的定量结论是什么?
结论:第一条直觉是「码值的一半就是中灰」。码值 128 的灰,也就是 #808080,CIELAB 明度是 53.59,比明度的中点 50 亮了三个多单位;真正最接近明度 50 的灰是 #777777,码值 119,明度 50.03。原因是 sRGB 的码值不是线性光强,它经过了一条幂函数形状的曲线编码,下一节会逐步算出来。
数据口径:多站视觉漂移用令牌偏离数、色差与第一印象评分三个量描述,不合成总分;证据分为五级,每一次统一工程预先登记十项内容。 全部品牌、站点、颜色与评分都是虚构样本,全部计算由书中程序生成;涉及法规之处只写一般框架,不是法律意见。
对照数据表
下表数字由本章 Python 程序原样打印,可重新运行复现。 程序只用 Python 标准库与结论吻合的打印值: 119, 128, 50, 50.03, 53.59, 777777
| step-by-step for gold.500 #B8913F | |
| 1 8-bit codes R 184 G 145 B 63 | |
| 2 divided by 255 | 0.721569 0.568627 0.247059 |
| 3 linearised | 0.479320 0.283149 0.049707 |
| 4 XYZ (Y of white | 1) X 0.307898 Y 0.308000 Z 0.090248 |
| reference white Xn 0.9505 Yn 1.0000 Zn 1.0890 | |
| 5 ratios to white | 0.323932 0.308000 0.082873 |
| 6 f(ratio), cube root | 0.686781 0.675332 0.435984 |
| 7 L* | 116 fy - 16 = 62.3385 ; a* = 500 (fx - fy) = 5.7246 ; b* = 200 (fy - fz) = 47.8695 |
| C* | 48.2106 ; hue angle h = 83.18 deg |
| by hand | 0.675^3 = 0.3075 ; 0.6753^3 = 0.30796 ; so fy is a little above 0.6753 |
| by hand | 116 x 0.675332 = 78.3385 ; 0.686781 - 0.675332 = 0.011449 ; x 500 = 5.7245 |
| token hex L* a* b* C* h(deg) round-trip | |
| ink.950 #111114 | 5.15 0.64 -1.73 1.85 290.2 #111114 |
| ink.900 #1B1B20 | 9.96 1.35 -3.44 3.70 291.4 #1B1B20 |
| ink.700 #3A3A42 | 24.70 1.92 -4.92 5.28 291.3 #3A3A42 |
| ink.500 #6B6B76 | 45.56 2.36 -6.11 6.55 291.1 #6B6B76 |
| ink.300 #A4A4AD | 67.62 1.75 -4.64 4.96 290.7 #A4A4AD |
| ink.100 #E4E2DC | 89.88 -0.38 3.16 3.19 96.8 #E4E2DC |
| ink.050 #F7F5F0 | 96.56 -0.20 2.64 2.64 94.4 #F7F5F0 |
| white #FFFFFF | 100.00 0.00 0.00 0.00 0.0 #FFFFFF |
| gold.700 #7A5E2A | 41.70 5.18 33.51 33.91 81.2 #7A5E2A |
| gold.500 #B8913F | 62.34 5.72 47.87 48.21 83.2 #B8913F |
| gold.300 #DDC58E | 80.32 0.62 30.71 30.72 88.8 #DDC58E |
| wine.700 #8C2F39 | 33.78 40.16 15.51 43.05 21.1 #8C2F39 |
| wine.300 #EA8F92 | 68.91 34.79 13.17 37.20 20.7 #EA8F92 |
| cobalt.700 #1F5FA8 | 40.09 7.15 -44.85 45.42 279.1 #1F5FA8 |
| cobalt.300 #83B5F3 | 72.46 -0.26 -35.96 35.96 269.6 #83B5F3 |
查看完整验算程序
# Chapter 3. p30: sRGB hex -> linear -> XYZ (D65) -> CIELAB, every step printed, for the Hengyu primitives.
# Transfer function and matrix: IEC 61966-2-1 (sRGB), four-decimal matrix. Reference white = the row sums of
# that matrix, so #FFFFFF maps to exactly L* 100, a* 0, b* 0. CIELAB constants: CIE 15 (epsilon = 216/24389,
# kappa = 24389/27). The primitive colours are the fictional Hengyu token set of chapter 2 (programs p20-p24).
import math
M = ((0.4124, 0.3576, 0.1805),
(0.2126, 0.7152, 0.0722),
(0.0193, 0.1192, 0.9505))
WHITE = tuple(math.fsum(r) for r in M)
WHITE_D65_5DP = (0.95047, 1.0, 1.08883)
EPS, KAPPA = 216 / 24389, 24389 / 27
PRIMS = {
"ink.950": "#111114", "ink.900": "#1B1B20", "ink.700": "#3A3A42", "ink.500": "#6B6B76",
"ink.300": "#A4A4AD", "ink.100": "#E4E2DC", "ink.050": "#F7F5F0", "white": "#FFFFFF",
"gold.700": "#7A5E2A", "gold.500": "#B8913F", "gold.300": "#DDC58E",
"wine.700": "#8C2F39", "wine.300": "#EA8F92", "cobalt.700": "#1F5FA8", "cobalt.300": "#83B5F3",
"jade.600": "#2E7D5B", "jade.300": "#4EC894", "violet.700": "#6B4FA0", "violet.300": "#B7ABD8",
"red.600": "#C33A32", "red.400": "#F07A72",
}
def hex_to_rgb8(h):
return tuple(int(h[i:i + 2], 16) for i in (1, 3, 5))
def lin(c, cut=0.04045):
return c / 12.92 if c <= cut else ((c + 0.055) / 1.055) ** 2.4
def gam(c):
return 12.92 * c if c <= 0.0031308 else 1.055 * c ** (1 / 2.4) - 0.055
def xyz(rgb_lin):
return tuple(math.fsum(m * c for m, c in zip(row, rgb_lin)) for row in M)
def f(t):
return t ** (1 / 3) if t > EPS else (KAPPA * t + 16) / 116
def lab(h, white=WHITE):
x, y, z = xyz([lin(c / 255) for c in hex_to_rgb8(h)])
fx, fy, fz = f(x / white[0]), f(y / white[1]), f(z / white[2])
return 116 * fy - 16, 500 * (fx - fy), 200 * (fy - fz)
def lab_to_hex(L, a, b):
fy = (L + 16) / 116
fx, fz = fy + a / 500, fy - b / 200
def finv(t):
return t ** 3 if t ** 3 > EPS else (116 * t - 16) / KAPPA
X, Y, Z = finv(fx) * WHITE[0], finv(fy) * WHITE[1], finv(fz) * WHITE[2]
det = (M[0][0] * (M[1][1] * M[2][2] - M[1][2] * M[2][1])
- M[0][1] * (M[1][0] * M[2][2] - M[1][2] * M[2][0])
+ M[0][2] * (M[1][0] * M[2][1] - M[1][1] * M[2][0]))
inv = [[(M[(j + 1) % 3][(i + 1) % 3] * M[(j + 2) % 3][(i + 2) % 3]
- M[(j + 1) % 3][(i + 2) % 3] * M[(j + 2) % 3][(i + 1) % 3]) / det for j in range(3)]
for i in range(3)]
rgb = [math.fsum(inv[i][k] * v for k, v in enumerate((X, Y, Z))) for i in range(3)]
return "#" + "".join("%02X" % max(0, min(255, round(gam(c) * 255))) for c in rgb)
def main():
h = PRIMS["gold.500"]
r8 = hex_to_rgb8(h)
print("step-by-step for gold.500 %s" % h)
print(" 1 8-bit codes R %d G %d B %d" % r8)
nrm = [c / 255 for c in r8]
print(" 2 divided by 255 %.6f %.6f %.6f" % tuple(nrm))
li = [lin(c) for c in nrm]
print(" 3 linearised %.6f %.6f %.6f" % tuple(li))
X, Y, Z = xyz(li)
print(" 4 XYZ (Y of white = 1) X %.6f Y %.6f Z %.6f" % (X, Y, Z))
print(" reference white Xn %.4f Yn %.4f Zn %.4f" % WHITE)
ts = (X / WHITE[0], Y / WHITE[1], Z / WHITE[2])
print(" 5 ratios to white %.6f %.6f %.6f" % ts)
fs = [f(t) for t in ts]
print(" 6 f(ratio), cube root %.6f %.6f %.6f" % tuple(fs))
L, a, b = 116 * fs[1] - 16, 500 * (fs[0] - fs[1]), 200 * (fs[1] - fs[2])
print(" 7 L* = 116 fy - 16 = %.4f ; a* = 500 (fx - fy) = %.4f ; b* = 200 (fy - fz) = %.4f" % (L, a, b))
print(" C* = %.4f ; hue angle h = %.2f deg" % (math.hypot(a, b), math.degrees(math.atan2(b, a)) % 360))
print(" by hand: 0.675^3 = %.4f ; 0.6753^3 = %.5f ; so fy is a little above 0.6753"
% (0.675 ** 3, 0.6753 ** 3))
print(" by hand: 116 x 0.675332 = %.4f ; 0.686781 - 0.675332 = %.6f ; x 500 = %.4f"
% (116 * 0.675332, 0.686781 - 0.675332, 500 * (0.686781 - 0.675332)))
print()
print("token hex L* a* b* C* h(deg) round-trip")
worst = 0
for name, hx in PRIMS.items():
L, a, b = lab(hx)
back = lab_to_hex(L, a, b)
worst = max(worst, max(abs(x - y) for x, y in zip(hex_to_rgb8(hx), hex_to_rgb8(back))))
print("%-11s %s %6.2f %7.2f %7.2f %6.2f %6.1f %s"
% (name, hx, L, a, b, math.hypot(a, b), math.degrees(math.atan2(b, a)) % 360, back))
print("largest round-trip error over %d primitives: %d code(s)" % (len(PRIMS), worst))
print()
Lw, aw, bw = lab("#FFFFFF", WHITE_D65_5DP)
print("white #FFFFFF with Xn,Zn = 0.95047, 1.08883 instead of the matrix row sums:"
" L* %.4f a* %.4f b* %.4f" % (Lw, aw, bw))
diff = [v for v in range(256) if (v / 255 <= 0.03928) != (v / 255 <= 0.04045)]
print("8-bit codes whose branch differs between cut-off 0.03928 (WCAG 2.1 text) and 0.04045: %d"
% len(diff))
print("codes 10 and 11 as fractions: %.6f and %.6f" % (10 / 255, 11 / 255))
print()
grey = min(range(256), key=lambda v: abs(lab("#%02X%02X%02X" % (v, v, v))[0] - 50))
print("#808080 (code 128, half of 255) has L* %.2f" % lab("#808080")[0])
print("the grey closest to L* 50 is #%02X%02X%02X, code %d, L* %.2f"
% (grey, grey, grey, grey, lab("#%02X%02X%02X" % (grey, grey, grey))[0]))
for hx in ("#FFFF00", "#0000FF", "#00FF00", "#FF0000"):
L, a, b = lab(hx)
print("%s (HSL lightness 50%%) has L* %.2f a* %.2f b* %.2f" % (hx, L, a, b))
if __name__ == "__main__":
main()唯一数据源与引用
范雅福(Fan, Y.). (2026). 《跨三十站设计令牌代数、色彩感知均匀空间与品牌权威第一印象毫秒学》第 3 章「感知均匀的颜色空间:从 sRGB 到 CIELAB、CIEDE2000 与 OKLab」(版本 0.1.0). 5D Library. DOI 待发布
DOI 待发布 · 专著页正式发布后上线(本站暂无专著页) · 5DL-B-140 · v0.1.0 · CC-BY-NC-ND-4.0
BibTeX
@book{fan2026140,
author = {Fan, Yafu},
title = {Design-Token Algebra across Thirty Sites, Perceptually Uniform Colour Spaces and the Millisecond Science of Brand-Authority First Impressions},
year = {2026},
publisher = {5D Library},
edition = {0.1.0},
note = {DOI pending}
}