5D Library › Computational Aesthetics, Visual Saliency Maps and Cognitive Ergonomics in User Interface Design · 中文

Chapter 5 Seeing Clearly: Spatial-Frequency Channels, Contrast Sensitivity and WCAG

An element must first be seen before it can be noticed; a passage of text must first be legible before it can be understood. This chapter starts with how the visual system breaks an image down by spatial frequency, moves on to the contrast sensitivity function, and ends with the relative-luminance and contrast formulas of the web accessibility guidelines. Book 34 has already treated Weber’s law and psychophysical measurement, which are only recapped here where needed.

Spatial-frequency channels

Campbell and Robson (1968) applied Fourier analysis to the visibility of gratings (Campbell and Robson 1968). They measured contrast thresholds for sine-wave gratings and for complex gratings such as square and rectangular waves, and found that the thresholds of complex gratings could be predicted from the thresholds of their Fourier components: a square wave, for example, became visible when the amplitude of its fundamental reached the threshold of a sine grating of the same frequency, and only looked different from a sine grating when its third harmonic also reached threshold. From this they proposed that the visual system contains a number of relatively independent “channels”, each sensitive to a fairly narrow band of spatial frequencies.

The Fourier series of a square wave is enough to write the argument down: a square wave of contrast cc has a fundamental of amplitude 4c/π4c/\pi and a third harmonic of 4c/(3π)4c/(3\pi). If the channels detect independently, the square wave’s detection threshold is π/4\pi/4 times the sine threshold, while “looking square” requires the third harmonic to reach threshold at frequency 3f3f.

The contrast sensitivity function

Plotting the reciprocal of the threshold contrast of sine gratings against spatial frequency gives the contrast sensitivity function (CSF). The human CSF is band-pass: most sensitive at intermediate frequencies (a few cycles per degree) and less sensitive at both low and high frequencies. An analytic approximation often used in image compression is the formula of Mannos and Sakrison (1974) (Mannos and Sakrison 1974)

A(f)=2.6(0.0192+0.114f)e−(0.114f)1.1,A(f) = 2.6\,(0.0192 + 0.114f)\,e^{-(0.114f)^{1.1}},

with ff in cycles per degree. Part A of the program below finds its peak; Part B applies Campbell and Robson’s logic to compute two thresholds for a square wave (assuming a sine threshold of 0.5 % at the peak, an illustrative value); Part C converts on-screen text into visual angle and spatial frequency. Solomon and Pelli (1994) found that letter identification relies on a band of spatial frequencies of about 3 cycles per letter (Solomon and Pelli 1994); Legge and Bigelow’s 2011 review gives a “critical print size” of about 0.2 degrees of x-height for normally sighted readers, with maximum reading speed maintained between about 0.2 and 2 degrees of x-height (a factor of ten), which they call the “fluent range” (Legge and Bigelow 2011).

Calculation

# Spatial-frequency channels and the contrast sensitivity function (CSF).
# A: Mannos & Sakrison (1974) CSF, A(f) = 2.6 (0.0192 + 0.114 f) exp(-(0.114 f)^1.1),
#    f in cycles/degree, normalised to a peak of 1; peak frequency found numerically.
# B: Campbell & Robson (1968) logic: a square wave of contrast c has a fundamental of
#    amplitude 4c/pi and a third harmonic 4c/(3 pi). If each channel detects its own
#    frequency independently, the square wave is seen when its fundamental reaches the
#    sine threshold (ratio pi/4), and looks different from a sine wave once the third
#    harmonic reaches threshold at 3f. Absolute threshold: assumed 0.5 % at the peak.
# C: text as a stimulus: letters are identified through a band of about 3 cycles per
#    letter (Solomon & Pelli 1994); x-height compared with the critical print size of
#    about 0.2 deg (Legge & Bigelow 2011). Pixel = 1/96 inch (the CSS reference pixel
#    subtends about 0.0213 deg at 28 inches).
import math

def csf(f):
    return 2.6 * (0.0192 + 0.114 * f) * math.exp(-(0.114 * f) ** 1.1)

PEAK = max((csf(k / 1000), k / 1000) for k in range(1, 60001))
def S(f): return csf(f) / PEAK[0]                  # normalised sensitivity
T0 = 0.005                                         # assumed threshold contrast at peak

if __name__ == "__main__":
    print(f"A. CSF peak at {PEAK[1]:.2f} c/deg (raw value {PEAK[0]:.3f})")
    print("   f (c/deg)        0.5     1     2     4     8    16    32    48")
    print("   sensitivity  " + "".join(f"{S(f):6.2f}"
                                     for f in (.5, 1, 2, 4, 8, 16, 32, 48)))
    hi = next(k / 10 for k in range(int(PEAK[1] * 10), 2000) if S(k / 10) < T0)
    print(f"   threshold contrast passes 100 % (invisible) at about {hi:.0f} c/deg")
    print("B. square-wave grating, contrast thresholds (assumed 0.5 % at the peak)")
    print("   f      sine   square: seen  looks square")
    for f in (0.5, 1, 2, 4, 8, 12):
        ts = T0 / S(f)
        print(f"   {f:4.1f} {ts:7.3%} {ts * math.pi / 4:12.3%}"
              f" {T0 / S(3 * f) * 3 * math.pi / 4:12.3%}")
    print("C. text at 1/96-inch pixels (x-height 0.5 em; 3 cycles per letter height)")
    print("   distance  font  x-height  vs 0.2 deg critical size  letter band c/deg")
    for dist in (71.12, 50.0):                     # 28 in = CSS reference distance
        px = math.degrees(2.54 / 96 / dist)        # small-angle pixel size, degrees
        for size in (12, 16, 24):
            xh = 0.5 * size * px; band = 3 / (2 * xh)    # letter height ~ 2 x-heights
            print(f"   {dist:5.1f} cm {size:4d} px {xh:7.3f} deg {xh / 0.2:16.2f} x"
                  f" {band:16.1f}  S = {S(band):.2f}")
# A. CSF peak at 7.89 c/deg (raw value 0.981)
#    f (c/deg)        0.5     1     2     4     8    16    32    48
#    sensitivity    0.19  0.32  0.54  0.83  1.00  0.70  0.15  0.02
#    threshold contrast passes 100 % (invisible) at about 59 c/deg
# B. square-wave grating, contrast thresholds (assumed 0.5 % at the peak)
#    f      sine   square: seen  looks square
#     0.5  2.584%       2.029%       2.697%
#     1.0  1.552%       1.219%       1.673%
#     2.0  0.929%       0.730%       1.221%
#     4.0  0.605%       0.475%       1.314%
#     8.0  0.500%       0.393%       3.324%
#    12.0  0.558%       0.438%      12.168%
# C. text at 1/96-inch pixels (x-height 0.5 em; 3 cycles per letter height)
#    distance  font  x-height  vs 0.2 deg critical size  letter band c/deg
#     71.1 cm   12 px   0.128 deg             0.64 x             11.7  S = 0.91
#     71.1 cm   16 px   0.171 deg             0.85 x              8.8  S = 0.99
#     71.1 cm   24 px   0.256 deg             1.28 x              5.9  S = 0.96
#     50.0 cm   12 px   0.182 deg             0.91 x              8.2  S = 1.00
#     50.0 cm   16 px   0.243 deg             1.21 x              6.2  S = 0.97
#     50.0 cm   24 px   0.364 deg             1.82 x              4.1  S = 0.84

In Part A, the Mannos–Sakrison formula peaks at 7.89 cycles per degree; with the peak set to 1, sensitivity at 0.5 cycles per degree is only 0.19 and at 32 cycles per degree 0.15; under the assumed threshold, gratings above about 59 cycles per degree are invisible even at 100 % contrast. In Part B, at 1 cycle per degree the sine threshold is 1.552 %; a square wave is visible at 1.219 % (the ratio π/4\pi/4) but “looks square” only at 1.673 %; at 12 cycles per degree the third harmonic falls at 36 cycles per degree, where sensitivity is low, and the square wave is distinguishable from a sine wave only at 12.168 %—at high frequencies a square wave looks like a sine wave. Figure 4 (left) plots both threshold curves.

Part C applies these numbers to text. The CSS reference pixel is defined as subtending about 0.0213 degrees at a distance of about 28 inches (71.1 cm); on this basis, 12-pixel text (x-height taken as 0.5 em) has an x-height of 0.128 degrees, only 0.64 times the critical print size; 16 pixels give 0.171 degrees (0.85 times); 24 pixels give 0.256 degrees (1.28 times). At 50 cm, 16-pixel text has an x-height of 0.243 degrees, above the critical size. Estimating “3 cycles per letter height”, the spatial frequencies these texts require lie between 4 and 12 cycles per degree, close to the region of highest contrast sensitivity (sensitivity 0.84–1.00). This suggests that common body-text sizes at suitable viewing distances lie in the range of spatial frequencies the eye handles best, while 12-pixel text at the desktop reference distance falls below the critical print size—a conclusion that depends on viewing distance and on the font’s x-height ratio, which varies considerably between typefaces.

Relative luminance and contrast in WCAG

The Web Content Accessibility Guidelines (WCAG) 2.x define the contrast between text and background with a simple formula (W3C 2008, 2023). Each 8-bit sRGB channel value vv is first turned into c=v/255c = v/255 and then linearised:

clin={c/12.92,c≤t,(c+0.0551.055)2.4,c>t,c_{\text{lin}} = \begin{cases} c/12.92, & c \le t,\\[2pt] \left(\dfrac{c+0.055}{1.055}\right)^{2.4}, & c > t,\end{cases}

relative luminance is L=0.2126R+0.7152G+0.0722BL = 0.2126R + 0.7152G + 0.0722B (with R,G,BR, G, B the linearised values), and the contrast ratio is (L1+0.05)/(L2+0.05)(L_1 + 0.05)/(L_2 + 0.05), with L1L_1 the lighter. Level AA requires at least 4.5:1 for body text and 3:1 for large text; level AAA requires at least 7:1 for body text and 4.5:1 for large text.

The threshold tt comes in two versions. The original WCAG 2.0 text gives 0.03928; the international sRGB standard IEC 61966-2-1 uses 0.04045 (IEC 1999). In May 2021 WCAG changed its definition to 0.04045, noting that the change has no practical effect in the context of the guidelines (W3C 2023).

Calculation

# WCAG 2.x relative luminance and contrast ratio.
# L = 0.2126 R + 0.7152 G + 0.0722 B on linearised sRGB channels; a channel value
# c = v/255 is linearised as c/12.92 if c <= t, else ((c + 0.055)/1.055)^2.4.
# WCAG 2.0 printed t = 0.03928; IEC 61966-2-1 (and WCAG 2.x since May 2021) uses
# t = 0.04045. Contrast = (L1 + 0.05)/(L2 + 0.05). Thresholds: AA 4.5 (large 3),
# AAA 7 (large 4.5).
def lin(v, t=0.04045, top=255):
    c = v / top
    return c / 12.92 if c <= t else ((c + 0.055) / 1.055) ** 2.4

def lum(rgb, t=0.04045):
    return sum(k * lin(v, t) for k, v in zip((0.2126, 0.7152, 0.0722), rgb))

def ratio(a, b, t=0.04045):
    la, lb = sorted((lum(a, t), lum(b, t)), reverse=True)
    return (la + 0.05) / (lb + 0.05)

def hexrgb(h):
    return tuple(int(h[i:i + 2], 16) for i in (1, 3, 5))

if __name__ == "__main__":
    between = [v for v in range(256) if 0.03928 < v / 255 <= 0.04045]
    print(f"A. 8-bit values between the two thresholds: {between}")
    diffs = [abs(lin(v) - lin(v, 0.03928)) for v in range(256)]
    print(f"   (v = 10 -> {10 / 255:.5f}, v = 11 -> {11 / 255:.5f}); all 256 values"
          f" agree,\n   max difference {max(diffs):.1e}")
    d16 = [abs(lin(v, 0.04045, 65535) - lin(v, 0.03928, 65535)) for v in range(65536)]
    n16 = sum(d > 0 for d in d16)
    print(f"   16-bit channels: {n16} values differ, by at most {max(d16):.1e}"
          f" in linear light")
    print("B. pairs (foreground on background)          ratio   AA  AA-large  AAA")
    for fg, bg, note in (("#000000", "#FFFFFF", "black on white"),
                         ("#767676", "#FFFFFF", "grey 46 % on white"),
                         ("#777777", "#FFFFFF", "one step lighter"),
                         ("#FFFFFF", "#D9261C", "white on red button"),
                         ("#FFFFFF", "#0A66C2", "white on blue button"),
                         ("#FFFFFF", "#FF8C00", "white on orange button"),
                         ("#595959", "#F2F2F2", "dark grey on light grey")):
        r = ratio(hexrgb(fg), hexrgb(bg))
        ok = ["yes" if r >= t else "no" for t in (4.5, 3.0, 7.0)]
        print(f"   {fg} on {bg}  {note:24s} {r:5.2f}:1 {ok[0]:>4s} {ok[1]:>8s}"
              f" {ok[2]:>4s}")
    lo = min(v for v in range(256) if ratio((v, v, v), (0, 0, 0)) >= 4.5)
    hi = max(v for v in range(256) if ratio((v, v, v), (255, 255, 255)) >= 4.5)
    print(f"C. grey text passing AA: on white, values <= {hi} (#{hi:02X}{hi:02X}"
          f"{hi:02X}); on black, >= {lo}")
    mid = max(range(256), key=lambda v: min(ratio((v, v, v), (0, 0, 0)),
                                             ratio((v, v, v), (255, 255, 255))))
    print(f"   best worst-case grey: {mid} (#{mid:02X}{mid:02X}{mid:02X}),"
          f" {ratio((mid,) * 3, (0, 0, 0)):.2f}:1 against black,"
          f" {ratio((mid,) * 3, (255,) * 3):.2f}:1 against white")
# A. 8-bit values between the two thresholds: []
#    (v = 10 -> 0.03922, v = 11 -> 0.04314); all 256 values agree,
#    max difference 0.0e+00
#    16-bit channels: 76 values differ, by at most 7.6e-07 in linear light
# B. pairs (foreground on background)          ratio   AA  AA-large  AAA
#    #000000 on #FFFFFF  black on white           21.00:1  yes      yes  yes
#    #767676 on #FFFFFF  grey 46 % on white        4.54:1  yes      yes   no
#    #777777 on #FFFFFF  one step lighter          4.48:1   no      yes   no
#    #FFFFFF on #D9261C  white on red button       4.95:1  yes      yes   no
#    #FFFFFF on #0A66C2  white on blue button      5.69:1  yes      yes   no
#    #FFFFFF on #FF8C00  white on orange button    2.33:1   no       no   no
#    #595959 on #F2F2F2  dark grey on light grey   6.26:1  yes      yes   no
# C. grey text passing AA: on white, values <= 118 (#767676); on black, >= 117
#    best worst-case grey: 117 (#757575), 4.56:1 against black, 4.61:1 against white

Part A proves the point: no 8-bit integer value lies between the two thresholds—v=10v = 10 gives c=0.03922c = 0.03922, below both; v=11v = 11 gives c=0.04314c = 0.04314, above both—so all 256 values linearise identically, and so does the contrast of every 8-bit colour. Only with 16-bit channels do 76 values fall between the thresholds, differing by at most 7.6×10−77.6\times10^{-7} in linear light, which has no effect on judgements such as 4.5:1.

Part B lists some common colour pairs: grey #767676 on white is 4.54:1, just passing AA; one step lighter, #777777, is 4.48:1 and fails—the standard is a hard line at the threshold. White on a red button (#D9261C) is 4.95:1 and on a blue button (#0A66C2) 5.69:1, both passing AA; white on an orange button (#FF8C00) is only 2.33:1, failing even the 3:1 for large text. Part C shows that the lightest grey passing AA on white is 118 (#767676) and the darkest passing on black is 117; only greys 117 and 118 therefore pass AA against both black and white, 117 giving 4.56:1 against black and 4.61:1 against white. Figure 4 (right) plots the contrast of greys against white and against black.

Left: under the Mannos–Sakrison contrast sensitivity function and an assumed threshold of 0.5 % at the peak, the threshold contrast of a sine grating (solid) and the contrast at which a square wave “looks square” (dashed, third harmonic at threshold); the curves separate at high frequencies, where a square wave looks like a sine wave. Right: WCAG contrast of grey text (0–255) on white and on black; horizontal lines from bottom to top at 3:1, 4.5:1 and 7:1.

Evidence

The status and limits of the contrast formula. The WCAG 2.x contrast ratio is an auditable engineering definition, not a complete psychophysical model of legibility: it distinguishes size and weight only coarsely, through a single “large text” category (at least 18 point, or 14 point bold), and ignores spatial frequency (previous section) and polarity (dark text on a light background and light text on a dark background differ in legibility at the same ratio). APCA (the Advanced Perceptual Contrast Algorithm), proposed to address this, entered the WCAG 3 working drafts as exploratory content but was removed in 2023 for lack of working-group support; the editor’s draft as of April 2026 still states that “the contrast algorithm used in WCAG 3 is yet to be determined”, and WCAG 3 itself is years from completion (Roselli 2026). In the current compliance context, then, the WCAG 2.x 4.5:1 remains the standard in use; APCA can only be treated as an alternative under research.

Hypothesis · not established · Contrast and small text interact

The author’s hypothesis (not established): for small text with an x-height below the critical print size (about 0.2 degrees), raising contrast from 4.5:1 to 7:1 improves reading speed more than the same increase does for body text with an x-height of 0.3 degrees or more. What result would show it wrong: in a pre-registered reading-speed experiment, the confidence interval for the size × contrast interaction includes zero or points the other way.

Chapter summary

Campbell and Robson’s experiments support the existence of relatively independent spatial-frequency channels in vision: a square wave is visible when its fundamental reaches threshold and looks “square” only when its third harmonic does. The Mannos–Sakrison contrast sensitivity function peaks near 7.9 cycles per degree; the letter-identification band of common body-text sizes lies close to this region, while 12-pixel text at the desktop reference distance falls below the critical print size of about 0.2 degrees. The WCAG relative-luminance and contrast formulas are reproduced; the two thresholds 0.03928 and 0.04045 give identical results for 8-bit colour, as the program proves value by value. APCA has been removed from the WCAG 3 drafts, and WCAG 3’s contrast algorithm has not been decided.

References

Campbell, F. W., and J. G. Robson. 1968. “Application of Fourier Analysis to the Visibility of Gratings.” Journal of Physiology 197 (3): 551–66.
IEC. 1999. IEC 61966-2-1: Multimedia Systems and Equipment – Colour Measurement and Management – Part 2-1: Colour Management – Default RGB Colour Space – sRGB. International Electrotechnical Commission.
Legge, Gordon E., and Charles A. Bigelow. 2011. “Does Print Size Matter for Reading? A Review of Findings from Vision Science and Typography.” Journal of Vision 11 (5): Article 8, 1–22. https://doi.org/10.1167/11.5.8.
Mannos, James L., and David J. Sakrison. 1974. “The Effects of a Visual Fidelity Criterion on the Encoding of Images.” IEEE Transactions on Information Theory 20 (4): 525–36.
Roselli, Adrian. 2026. WCAG3 Contrast as of April 2026. Blog post, adrianroselli.com.
Solomon, Joshua A., and Denis G. Pelli. 1994. “The Visual Filter Mediating Letter Identification.” Nature 369: 395–97.
W3C. 2008. Web Content Accessibility Guidelines (WCAG) 2.0. W3C Recommendation, 11 December 2008.
W3C. 2023. Web Content Accessibility Guidelines (WCAG) 2.2. W3C Recommendation, 2023; relative-luminance definition with the note on the threshold change of May 2021.

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).