What the eye misses: contrast sensitivity and masking
A codec's lossy tools are aimed at what viewers are least likely to notice. Two properties of vision come up again and again in this course. Sensitivity to contrast varies with the size of the detail, and falls away for fine detail. And detail already in a picture can hide an error added on top of it, which is called masking.
Sensitivity depends on detail size
Contrast is how far a pattern's light and dark depart from its average. For the sine-wave gratings of the experiments below it is (brightest − darkest) / (2 × average), with all three as amounts of light, not pixel values. Contrast sensitivity is one over the smallest contrast a viewer can detect. Detail size is counted in cycles per degree: how many pairs of stripes fit in one degree of the visual field. The same picture has more cycles per degree from farther away.
Campbell and Robson (1968) measured two observers with sine-wave gratings. Under their conditions sensitivity was highest near 4 cycles per degree and fell for both finer and coarser stripes. In the picture above you may see the faintest visible stripes reach higher in the middle than at either edge, and the place may shift as you move toward or away from the screen. The exact boundary depends on the display and the viewing setup; the picture is not a vision test.
Hide the same error in two places
Two patches, each 160 pixels square: one flat gray, one an invented fur texture. Noise sets the size of a random error, and the same error, pixel for pixel, is added to both. Mean squared error is the average squared difference between a patch and its noisy copy. Variance is how much a patch's own pixels differ from their average; it is zero for the flat patch.
Drag Noise down to 0, then raise it slowly while comparing each patch with its noisy copy. Does the same added error become noticeable at the same setting on both backgrounds?
At Noise 8 the mean squared error is 21.8 in both patches. The measure cannot tell them apart, at this setting or any other. What differs is the patch underneath: the fur's variance is 501 against 0.
Legge and Foley (1980) measured the effect with gratings in place of fur. A grating of 2 cycles per degree needed more contrast to be detected on top of a second, high-contrast grating, most of all when the second grating's stripes were close to its own in size. With a very faint second grating the opposite happened, and detection got easier. Masking is not a rule that a busy area hides everything.
Which tools lean on which
| Idea from vision | Coding tool |
|---|---|
| Sensitivity varies with detail size | Quantization matrices |
| Color detail is resolved less finely | Chroma subsampling |
| Some errors are less visible on some backgrounds | Variance-based adaptive quantization |
A quantization matrix is only the mechanism for weighting frequencies; its weights decide the behavior. The variance-based adaptive quantization modes covered in this course use block energy, a relative of the variance above, as a rough guide to where error can go. High variance is not the same as masking: one hard edge has high variance and is not dense texture. Other perceptual choices need their own explanation and are not modeled by this noise experiment; x264's psychovisual term, for one, raises the cost of losing texture energy.
These tools can use simplified assumptions about perception. They do not guarantee that an error will be invisible for a particular picture, viewer, screen or distance.
What to carry forward
- Visibility depends on detail size as the eye sees it. That is cycles per degree, which changes with screen size and distance, not pixels.
- The same squared error can be easier or harder to see depending on what it lands on.
- Encoders can use frequency weighting and local activity as imperfect guides to visibility. They still have to trade error against coding cost.
Sources
Read 2026-11-14.
- F. W. Campbell and J. G. Robson, Application of Fourier analysis to the visibility of gratings, Journal of Physiology 197 (1968), read as extracted text: the definitions of contrast and contrast sensitivity, the two observers, and the sensitivity curve for sine-wave gratings in its figure 2. The picture on this page is not from the paper.
- G. E. Legge and J. M. Foley, Contrast masking in human vision, Journal of the Optical Society of America 70 (1980), read as extracted text: thresholds for a 2 cycles-per-degree grating against masking gratings of 1 to 4 cycles per degree, the rise at high masking contrast, the facilitation at very low masking contrast, and the dependence on the difference in frequency. The experiment uses gratings; it does not validate this page's fur and noise demo or measure codec artifacts.
- No encoder source was read for this page; it makes no claim about a particular encoder beyond what the linked pages establish.
- Not checked: how sensitivity changes with brightness, motion and color (the chroma subsampling page cites one abstract on color); masking by natural textures or by noise, which the demo only invites you to look at; any model of visibility used by a quality metric; psychovisual rate-distortion optimization.