5D Library › 计算美学、视觉显著性图谱与人机界面认知工程 · English
第三章 什么先跳出来:视觉搜索与显著性图谱
第二章假设用户已经知道目标在哪里,只需要决定与指向。可是在一个新页面上,用户首先要找到目标。寻找的速度取决于目标与周围的东西有多不同:一个红色按钮在一片灰色中几乎立刻「跳出来」,一个与其他按钮只差一个字的链接则要逐个看过去。本章先讨论视觉搜索的经典结果,再用纯标准库实现伊蒂、科赫与尼布尔 1998 年的显著性模型,计算一个虚构页面上「最先被注意」的位置。
视觉搜索:特征、联合与引导
特雷斯曼与格拉德 1980 年的特征整合理论区分了两种搜索 (Treisman and Gelade 1980)。在特征搜索中,目标在一个基本特征上与干扰项不同(例如一群绿色字母中的一个红色字母),搜索时间几乎不随干扰项数目增加,好像目标「跳了出来」;在联合搜索中,目标只在特征的组合上与干扰项不同(例如绿 X 与红 O 之中的一个红 X),搜索时间随项目数线性增加,目标存在时的斜率约为目标不存在时的一半——这正是逐项检查、找到即停的串行搜索的特征。特雷斯曼据此认为,特征在早期并行地登记,而把特征「粘合」成物体需要注意逐个处理。
沃尔夫的引导搜索模型修正了这一二分 (Wolfe 1994):并行的特征处理不仅能让目标「跳出来」,还能为每个位置计算一个优先级,引导注意按优先级依次访问。目标与干扰项的特征差异越大,目标的优先级越可能排在前面,搜索斜率就越小;差异为零时退化为随机的串行搜索。在这个框架中,「跳出」与「串行」是一个连续谱的两端。
下面的程序是一个示意的模拟:每检查一个项目耗时 50 毫秒,基础时间 450 毫秒。特征搜索不依赖项目数;串行搜索按随机次序检查;引导搜索按带噪声的优先级检查,目标的优先级比干扰项高 个标准差。
推导
# Visual search time against set size (the author's simulation; parameters are
# illustrative). Feature search: the target differs in one feature and is found in
# parallel; RT = 450 ms + noise, independent of n. Serial self-terminating search
# (conjunction, Treisman & Gelade 1980): items inspected one by one at 50 ms each in
# random order; target-present RT slope ~25 ms/item, absent ~50 ms/item. Guided search
# (in the spirit of Wolfe 1994): items visited in order of a noisy priority
# (signal d' for the target), so the target tends to come early.
import random, statistics
def trial(rng, n, kind, present=True, dprime=1.5, per=50.0, base=450.0):
if kind == "feature":
return base + rng.gauss(0, 30)
if kind == "serial":
k = rng.randint(1, n) if present else n
else: # guided: rank of target by priority
t = rng.gauss(dprime, 1.0)
k = 1 + sum(rng.gauss(0, 1.0) > t for _ in range(n - 1)) if present else n
return base + per * k + rng.gauss(0, 30)
def slope(xs, ys):
mx, my = statistics.fmean(xs), statistics.fmean(ys)
sxx = sum((x - mx) ** 2 for x in xs)
return sum((x - mx) * (y - my) for x, y in zip(xs, ys)) / sxx
if __name__ == "__main__":
rng = random.Random(1980); sizes = (4, 8, 16, 32)
print("mean RT (ms), 400 trials per cell n = 4 8 16 32 slope")
for kind, present in (("feature", True), ("serial", True), ("serial", False),
("guided", True), ("guided", False)):
means = [statistics.fmean(trial(rng, n, kind, present) for _ in range(400))
for n in sizes]
lab = f"{kind} search, target {'present' if present else 'absent'}"
print(f" {lab:36s}" + "".join(f"{m:7.0f}" for m in means)
+ f" {slope(sizes, means):6.1f} ms/item")
print("guided search, target present, 2,000 trials per cell; expected slope")
print(" = 50 ms x P(a distractor outranks the target) = 50 Phi(-d'/sqrt 2)")
for d in (0.0, 0.5, 1.5, 3.0):
m = [statistics.fmean(trial(rng, n, "guided", True, d) for _ in range(2000))
for n in sizes]
th = 50 * statistics.NormalDist().cdf(-d / 2 ** 0.5)
print(f" d' = {d:3.1f}: simulated {slope(sizes, m):5.1f}, expected {th:5.1f}"
f" ms/item")
# mean RT (ms), 400 trials per cell n = 4 8 16 32 slope
# feature search, target present 448 451 452 451 0.0 ms/item
# serial search, target present 575 679 887 1247 23.9 ms/item
# serial search, target absent 647 851 1250 2051 50.1 ms/item
# guided search, target present 522 544 606 750 8.3 ms/item
# guided search, target absent 649 848 1253 2049 50.0 ms/item
# guided search, target present, 2,000 trials per cell; expected slope
# = 50 ms x P(a distractor outranks the target) = 50 Phi(-d'/sqrt 2)
# d' = 0.0: simulated 24.6, expected 25.0 ms/item
# d' = 0.5: simulated 18.1, expected 18.1 ms/item
# d' = 1.5: simulated 7.2, expected 7.2 ms/item
# d' = 3.0: simulated 0.8, expected 0.8 ms/item特征搜索的斜率为 0.0 毫秒/项;串行搜索在目标存在时为 23.9 毫秒/项,不存在时为 50.1 毫秒/项,比例约 1:2。引导搜索()在目标存在时只有 8.3 毫秒/项,目标不存在时仍要检查全部项目,斜率回到 50.0。后半部分验证了一个简单的关系:在这个模型中,目标存在时的期望斜率等于每项时间乘以「一个干扰项的优先级超过目标的概率」,即 。 时为 25 毫秒/项(随机串行), 时为 18.1, 时为 7.2, 时只有 0.8,模拟值与之一致。
对界面设计,这给出一个比「颜色要醒目」更精确的说法:一个元素能否被快速找到,取决于它在某个能并行计算的特征上与周围元素的差异有多大(相对于噪声),而这个差异是相对的——满页都是红色按钮时,红色就不再引导搜索。第 24 本讨论过波斯纳的定向网络与注意的捕获,这里只回顾:外源性的显著刺激能够自动吸引注意,但这种捕获受当前任务设定的调节。
伊蒂—科赫—尼布尔显著性模型
原文的结构
伊蒂、科赫与尼布尔 1998 年发表在《IEEE 模式分析与机器智能汇刊》第 20 卷第 11 期(1254–1259 页)的短文,把「哪里会先跳出来」写成了一个可以计算的模型 (Itti et al. 1998)。核对原文,模型的结构如下:
- 输入图像分为强度、颜色(红—绿、蓝—黄双拮抗)与方向(0°、45°、90°、135°,由加博尔金字塔得到)三类通道,每个通道建立九级二进高斯金字塔(第 0 级为原图,第 8 级缩小 256 倍)。
- 中央—周边差分:中心取第 级,周边取第 级,;把周边插值到中心的尺度后逐点相减取绝对值。这样每个通道得到 6 张图,合计强度 6 张、颜色 12 张、方向 24 张,共 42 张特征图。
- 归一化算子 :把图缩放到固定范围 ,求出全局最大值 与其他局部极大值的均值 ,再把整张图乘以 。只有一个突出峰的图被放大,有许多相近峰的图被抑制。
- 各类特征图在第 4 级相加得到强度、颜色、方向三张「醒目图」,各自归一化后取平均,,即显著性图。
- 胜者全得与返回抑制:显著性图驱动一个由积分—发放神经元组成的胜者全得网络;最先发放的位置成为注意焦点,随后该位置被局部抑制(返回抑制),注意转移到下一个最显著的位置。原文中注意焦点是半径为图像短边六分之一的圆盘,转移间隔在模拟时间中约 30–70 毫秒,被注意过的区域受抑制约 500–900 毫秒。
原文同样明确写出了模型的局限:只有在特征图中显式表示的特征才能产生「跳出」,特征的联合无法检测;没有自上而下的成分;模型产生的注意轨迹「不一定」与人眼的注视相似 (Itti et al. 1998)。
一个纯标准库的实现
下面的程序在一个 256×192 像素的虚构着陆页上实现这一模型。页面有导航栏、橙色标志、一张带「太阳」的主图、标题与正文(用条纹模拟文字)、一个「行动号召」按钮(CTA)和一个浅色次按钮,以及四张商品卡片。版式 A 中 CTA 为红色;版式 B 中 CTA 为灰色,其强度 与红色相同,只去掉了颜色差异。
与原文的差异逐项说明:(1)方向通道用四个方向的二阶差分的绝对值代替加博尔滤波器;(2)跨尺度相减用最近邻扩展,不用插值;(3)归一化中的局部极大值在 3×3 邻域中判定,乘子写成 (图已缩放到 );(4)胜者全得用「取最大值」代替积分—发放神经元,返回抑制用半径 2 个单元(16×12 网格,约为短边的六分之一)的圆盘。42 张特征图的数目与原文相同。
推导
# Itti-Koch-Niebur (1998) saliency, synthetic 256 x 192 landing page, standard
# library only. Nine dyadic Gaussian levels (0-8); centre c in {2,3,4}, surround
# s = c + d, d in {3,4}; 6 intensity, 12 colour, 24 orientation maps (42 in all);
# N(.) = scale to [0,1], multiply by (1 - mean of the other local maxima)^2; conspicuity
# maps summed at level 4; S = (N(I) + N(C) + N(O))/3. Simplifications: orientation =
# |oriented second difference| instead of Gabor filters, nearest-neighbour expansion,
# and an argmax WTA with disk-shaped inhibition of return (radius 1/6 of the smaller
# image side) instead of integrate-and-fire neurons. Layout A: red call-to-action
# (CTA) button; layout B: the same button in grey of equal intensity I = (r+g+b)/3.
import math # math.fsum: same float sums on Python 3.8-3.13
W, H = 256, 192
BOXES = [("nav bar", 0, 0, 256, 16, (.15, .15, .17)),
("logo", 8, 3, 40, 13, (.95, .55, .1)),
("hero photo", 8, 24, 124, 100, (.35, .55, .6)),
("sun in photo", 84, 34, 100, 50, (.98, .85, .2)),
("headline", 136, 28, 248, 36, None), ("body text", 136, 44, 248, 64, None),
("CTA button", 136, 76, 196, 92, (.85, .1, .1)),
("2nd button", 204, 76, 248, 92, (.9, .9, .9))]
BOXES += [(f"card {k + 1}", 8 + 62 * k, 116, 62 * k + 64, 180, (.93, .93, .93))
for k in range(4)]
THUMB = ((.75, .8, .85), (.85, .8, .75), (.8, .85, .78), (.82, .8, .86))
def page(cta):
img = [[(.97, .97, .97)] * W for _ in range(H)]
for name, x0, y0, x1, y1, col in BOXES:
col = cta if name == "CTA button" else col
for y in range(y0, y1):
for x in range(x0, x1):
if col:
img[y][x] = col
elif x % 7 < 4 and (name == "headline" or y % 7 < 4): # text strokes
img[y][x] = (.1, .1, .1) if name == "headline" else (.35, .35, .35)
for k in range(4): # card thumbnails and labels
for y in range(122, 160):
for x in range(14 + 62 * k, 58 + 62 * k):
img[y][x] = THUMB[k]
for y in range(166, 174):
for x in range(14 + 62 * k, 50 + 62 * k):
if x % 5 < 3:
img[y][x] = (.4, .4, .4)
return img
def down(m): # blur with [1 4 6 4 1]/16, then keep every 2nd pixel
h, w = len(m), len(m[0]); k = (1, 4, 6, 4, 1)
fs = math.fsum
rows = [[fs(k[j] * r[min(max(x + j - 2, 0), w - 1)] for j in range(5)) / 16
for x in range(0, w, 2)] for r in m]
return [[fs(k[j] * rows[min(max(y + j - 2, 0), h - 1)][x] for j in range(5)) / 16
for x in range(len(rows[0]))] for y in range(0, h, 2)]
def pyramid(m):
p = [m]
while len(p) < 9:
p.append(down(p[-1]))
return p
def diff(c, s, sign=1): # |c (-) s|: expand s to the size of c, subtract
fy, fx = len(s) / len(c), len(s[0]) / len(c[0])
return [[abs(c[y][x] - sign * s[int(y * fy)][int(x * fx)]) for x in range(len(c[0]))]
for y in range(len(c))]
def N(m):
mx = max(max(r) for r in m) or 1.0
m = [[v / mx for v in r] for r in m]; h, w = len(m), len(m[0]); peaks = []
for y in range(h):
for x in range(w):
v = m[y][x]
if 0 < v < 1 and all(v >= m[j][i] for j in range(max(y - 1, 0), min(y + 2, h))
for i in range(max(x - 1, 0), min(x + 2, w))):
peaks.append(v)
f = (1 - math.fsum(peaks) / len(peaks)) ** 2 if peaks else 1.0
return [[v * f for v in r] for r in m]
def to4(m): # average-pool any level to 16 x 12
f = len(m) // 12
return [[math.fsum(m[y * f + j][x * f + i] for j in range(f) for i in range(f)) / f**2
for x in range(16)] for y in range(12)]
def add(a, b):
return [[u + v for u, v in zip(r, q)] for r, q in zip(a, b)]
def orient(m, t): # oriented second difference, theta = 0/45/90/135
dy, dx = ((0, 1), (1, 1), (1, 0), (1, -1))[t]; h, w = len(m), len(m[0])
g = lambda y, x: m[min(max(y, 0), h - 1)][min(max(x, 0), w - 1)]
return [[abs(2 * g(y, x) - g(y - dy, x - dx) - g(y + dy, x + dx)) for x in range(w)]
for y in range(h)]
def saliency(img):
I = [[math.fsum(p) / 3 for p in r] for r in img]; imax = max(max(r) for r in I)
def opp(p, i):
if i < imax / 10:
return 0.0, 0.0
r, g, b = (v / i for v in p)
R, G, B = r - (g + b) / 2, g - (r + b) / 2, b - (r + g) / 2
Y = (r + g) / 2 - abs(r - g) / 2 - b
return max(R, 0) - max(G, 0), max(B, 0) - max(Y, 0)
op = [[opp(p, i) for p, i in zip(r, ri)] for r, ri in zip(img, I)]
PI = pyramid(I); PRG = pyramid([[o[0] for o in r] for r in op])
PBY = pyramid([[o[1] for o in r] for r in op])
PO = [[orient(PI[l], t) if l >= 2 else None for l in range(9)] for t in range(4)]
zero = [[0.0] * 16 for _ in range(12)]; Ib, Cb, Ob = zero, zero, [zero] * 4; n = 0
for c in (2, 3, 4):
for s in (c + 3, c + 4):
Ib = add(Ib, to4(N(diff(PI[c], PI[s]))))
rg, by = to4(N(diff(PRG[c], PRG[s], -1))), to4(N(diff(PBY[c], PBY[s], -1)))
Cb = add(Cb, add(rg, by))
Ob = [add(Ob[t], to4(N(diff(PO[t][c], PO[t][s])))) for t in range(4)]
n += 7 # 1 intensity + 2 colour + 4 orientation maps
Ob = [N(o) for o in Ob]; O = add(add(Ob[0], Ob[1]), add(Ob[2], Ob[3]))
S = add(add(N(Ib), N(Cb)), N(O))
return [[v / 3 for v in r] for r in S], n
def label(x, y): # level-4 cell -> page element under its centre
px, py = 16 * x + 8, 16 * y + 8
for name, x0, y0, x1, y1, _ in reversed(BOXES):
if x0 <= px < x1 and y0 <= py < y1:
return name
return "white space"
def scanpath(S, k=6, r=2):
S = [row[:] for row in S]; out = []
for _ in range(k):
v, y, x = max((S[y][x], y, x) for y in range(12) for x in range(16))
out.append((x, y, v))
for j in range(12):
for i in range(16):
if (i - x) ** 2 + (j - y) ** 2 <= r * r:
S[j][i] = 0.0
return out
if __name__ == "__main__":
for tag, cta in (("A, red CTA", (.85, .1, .1)), ("B, grey CTA", (.35, .35, .35))):
S, n = saliency(page(cta))
print(f"layout {tag}: {n} feature maps; saliency map 16 x 12 (level 4)")
if tag[0] == "A":
mx = max(max(r) for r in S)
for r in S:
print(" |" + "".join(" .:-=+*#%@"[min(int(v / mx * 10), 9)] for v in r)
+ "|")
path = scanpath(S, k=40)
for i, (x, y, v) in enumerate(path[:6], 1):
print(f" shift {i}: cell ({x:2d},{y:2d}) S = {v:.3f} {label(x, y)}")
first = next(i for i, (x, y, v) in enumerate(path, 1)
if label(x, y) == "CTA button")
print(f" the CTA button is first attended at shift {first}")
peak = {}
for y in range(12):
for x in range(16):
peak[label(x, y)] = max(peak.get(label(x, y), 0.0), S[y][x])
print(" peak S: " + ", ".join(f"{k} {peak[k]:.3f}" for k in
("CTA button", "logo", "hero photo", "body text", "card 1")))
# layout A, red CTA: 42 feature maps; saliency map 16 x 12 (level 4)
# |=*+=============|
# |-=--=====-------|
# |++====-++-------|
# |++==+--++-------|
# |=*++++++====----|
# |=*++++++*@@@*---|
# |-=======--==--::|
# |-:------::::::::|
# |:::::...:.......|
# |:::::...:.......|
# |:::.:...:...:...|
# |:.:::.:::.......|
# shift 1: cell (11, 5) S = 0.245 CTA button
# shift 2: cell ( 1, 0) S = 0.165 logo
# shift 3: cell ( 8, 5) S = 0.162 CTA button
# shift 4: cell ( 1, 5) S = 0.149 hero photo
# shift 5: cell ( 3, 4) S = 0.139 hero photo
# shift 6: cell ( 8, 2) S = 0.135 white space
# the CTA button is first attended at shift 1
# peak S: CTA button 0.245, logo 0.165, hero photo 0.149, body text 0.134, card 1 0.082
# layout B, grey CTA: 42 feature maps; saliency map 16 x 12 (level 4)
# shift 1: cell ( 1, 0) S = 0.274 logo
# shift 2: cell ( 2, 5) S = 0.183 hero photo
# shift 3: cell ( 6, 5) S = 0.176 hero photo
# shift 4: cell ( 4, 4) S = 0.172 hero photo
# shift 5: cell ( 7, 3) S = 0.159 hero photo
# shift 6: cell ( 1, 3) S = 0.158 hero photo
# the CTA button is first attended at shift 18
# peak S: CTA button 0.127, logo 0.274, hero photo 0.183, body text 0.146, card 1 0.090版式 A 的显著性图(以字符画显示,越密越显著)中,最亮的区域是 CTA 按钮所在的一行。模型的第一次注意转移落在 CTA 上(),第二次落在标志上(0.165),然后回到 CTA 的左端与主图。版式 B 中,CTA 的峰值降到 0.127,第一次转移落在橙色标志上(0.274),随后五次都在主图上;CTA 直到第 18 次转移才被注意到。两个版式唯一的差别是按钮的颜色,强度完全相同,所以这里的差别全部来自颜色通道:红色按钮在红—绿拮抗图中是唯一突出的峰,经 放大后主导了整张显著性图。图 3 画出了两张显著性图与前五次注意转移。
注
这个结果说明什么,不说明什么。 它说明:在这个模型中,一个在颜色上唯一突出的元素会被预测为最先注意的位置,而去掉颜色差异后,同一个元素可能排到十几位之后。它不说明用户会更快点击红色按钮,更不说明红色按钮转化更好。模型不知道用户要做什么,不读文字,也没有中央偏差;第四章会看到,这些因素在网页上往往比底层显著性更重要。「红色按钮比绿色按钮转化更好」之类的案例报告,在没有预注册与多重比较校正的情况下(第一章),不能作为证据。
显著性模型在网页上的表现
伊蒂—科赫模型之后出现了数十个显著性模型。博尔吉与伊蒂 2013 年的综述把近 65 个模型按 13 条标准分类比较 (Borji and Itti 2013),并讨论了一个反复出现的问题:在自然场景的自由观看中,单纯的「中央偏差」(把显著性图换成一个以图像中心为峰的高斯)常常就能达到与许多显著性模型相当的预测成绩。
网页与自然场景又有不同。沈成尧与赵琦 2014 年收集了 11 名观察者自由观看 149 个网页截图(每页 5 秒)的眼动数据,发现早期注视明显偏向页面中心与左上角,常常落在大号文字、标志、人脸与物体上;文字区域的注视比图片更难预测;在模型中加入人脸检测与位置偏差都能提高预测成绩 (Shen and Zhao 2014)。布舍尔、库特雷尔与莫里斯 2009 年记录了 20 名用户浏览 361 个网页的眼动,发现注意的分布随任务(信息觅食还是页面识别)与人口特征而变 (Buscher et al. 2009)。
证据
网页上的眼动与显著性(摘要)。 博尔吉与伊蒂 2013:综述约 65 个注意模型,讨论中央偏差、自上而下与自下而上的分离与评价指标 (Borji and Itti 2013)。沈与赵 2014:149 个网页、11 名观察者、每页 5 秒;早期注视偏向中心与左上,文字较难预测,加入人脸与位置先验可改进模型 (Shen and Zhao 2014)。布舍尔等 2009:20 名用户、361 个网页;注意分布依赖任务与人群 (Buscher et al. 2009)。这些研究的样本较小,网页与任务的选取也有限,结论应视为方向性的。
假说 · 尚未验证 · 颜色唯一性的边际作用
作者的假说(尚未确立): 在任务明确(「找到并点击购买按钮」)的电商页面上,把行动号召按钮从与页面同色调改为页面中唯一的高饱和颜色,能缩短首次注视该按钮的时间,但缩短的幅度在有明确任务时小于自由浏览时。什么样的结果能证明它是错的: 在事先登记的眼动实验中,「颜色 × 任务」交互作用的置信区间包含零,或者有任务时的缩短幅度不小于自由浏览时。
本章小结
视觉搜索的速度取决于目标在可并行计算的特征上与干扰项的相对差异:差异足够大时目标「跳出」,没有差异时退化为逐项搜索,引导搜索介于两者之间,模拟中的斜率与 的预测一致。伊蒂—科赫—尼布尔模型的结构(九级金字塔、、、42 张特征图、、胜者全得加返回抑制)核对无误;纯标准库的实现显示,在这个模型中,一个按钮的颜色唯一性可以把它从第 18 次注意转移提前到第 1 次。但模型只描述底层显著性,原文自己说明其轨迹不一定与人的注视相似;网页上的中央与左上偏差、任务、文字与人脸往往更重要。
参考文献
Fan, Y. (2026). Computational Aesthetics, Visual Saliency Maps and Cognitive Ergonomics in User Interface Design: From the Hick–Hyman Law and Spatial Frequency Channels to Saccadic Trajectory Modelling, Read Beside the Kaogongji and Classical Treatise on Architectural Methods [计算美学、视觉显著性图谱与人机界面认知工程] (Version 1.0.0). 5D Library. https://doi.org/10.5281/zenodo.23836258 · Licensed under Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International (CC BY-NC-ND 4.0).