Back to Home

JPEG and visual neurophysiology: how the format deceives the eye

The article explains how the JPEG format is based on neurophysiological features of human vision: the ratio of rods and cones, peripheral color vision, V1 neuron activity and contrast sensitivity (CSF). Technical details of YCbCr, chroma subsampling 4:2:0, DCT and quantization with code examples are provided.

How JPEG models your vision: technical breakdown
Advertisement 728x90

How JPEG Tricks the Visual System: Engineering Rooted in Neurophysiology

JPEG is not just a compression format. It’s a three-dimensional model of human vision, encoded into an algorithm from 1992. It doesn’t optimize data for storage; it simulates what the eye sees, how the brain processes it, and where the visual system loses information. The result? Files that are 5–10 times smaller without any noticeable loss in perception. This effect isn’t achieved by simplifying the math—it’s achieved by precisely matching biological constraints: photoreceptor density, contrast sensitivity, and the spatial frequency selectivity of the cortex. Below is a technical breakdown of each stage in the JPEG pipeline through the lens of visual neurophysiology.

YCbCr: Separating Signals by Biological Significance

The first step in JPEG encoding is converting RGB to YCbCr. This isn’t a technical convenience; it’s a direct implementation of retinal anatomy. Humans have about 120 million rods (sensitive to brightness) and only 6–7 million cones (color receptors), a ratio of roughly 20:1. Consequently, the visual system can distinguish gradations of brightness much more accurately than shades of color.

The formula for calculating the Y channel is:

Google AdInline article slot
Y = 0.299 × R + 0.587 × G + 0.114 × B

These coefficients aren’t arbitrary: the 0.587 for green reflects the peak sensitivity of the human eye at around 555 nm—the yellow-green region of the spectrum, evolutionarily adapted for spotting ripe fruit against foliage. That’s why black-and-white images with these weights look voluminous and high-contrast, whereas uniform averaging (0.33R + 0.33G + 0.33B) produces a flat, “soapy” image.

In YCbCr, the Y channel contains all the critical information for perception—structure, contours, and textures. Cb and Cr are merely adjustments for color tone. They can be aggressively processed without risking perceptual quality.

Chroma Subsampling: Compressing Color Based on Peripheral Vision Anatomy

After conversion, chroma subsampling is applied—reducing the resolution of the color channels. The most common mode, 4:2:0, means one Cb block and one Cr block for every four Y blocks (2×2 pixels). In effect, 75% of the color information is discarded.

Google AdInline article slot

This directly corresponds to retinal anatomy: cones are concentrated in the fovea, while their density drops sharply toward the periphery. Spatial resolution for color vision is, on average, four times lower than for monochrome vision. JPEG doesn’t “lose” color—it preserves exactly as much as the visual system can discern in each local area of the image.

To verify this, simply open any JPEG in Photoshop, split it into YCbCr channels, and compare the visual quality of Y versus Cb/Cr: the latter will appear blurry and low-frequency—but when overlaid on Y, the brain automatically restores the image’s integrity. This isn’t a flaw in the format; it’s leveraging how the visual cortex works.

DCT and Quantization: A Frequency Map of Blind Spots

The Discrete Cosine Transform (DCT) breaks the image into 8×8 blocks and decomposes each block into 64 basis components—from low-frequency gradients to high-frequency edges, noise, and textures. This isn’t abstract: neurons in the primary visual cortex (V1) respond to oriented stripes with specific spatial frequencies—in effect, performing a biological approximation of DCT.

Google AdInline article slot

Next, the coefficients undergo quantization—division by values from a quantization table and rounding. The standard table for the Y channel has the following structure: minimal divisors in the upper-left corner (low frequencies, high sensitivity), maximal divisors in the lower-right (high frequencies, low sensitivity). This table isn’t an engineering guess; it’s an empirical map of contrast sensitivity (CSF) derived from psychovisual experiments on humans. The CSF peak occurs at 3–5 cycles per degree of visual angle; beyond ~60 cycles/degree, humans physically can’t distinguish details.

When you set quality=80 in Photoshop, you’re setting a threshold at which quantization affects only those frequencies below the perceptual threshold. At quality=5, the algorithm starts zeroing out even mid-range frequencies—those the brain actually uses to recognize shape and texture. Hence the sharp drop in perceived quality.

Experiment: Visualizing What the Eye Doesn’t Notice

To see exactly which components JPEG deems “invisible,” you can run a simple experiment: save the same image as a JPEG at different qualities, then calculate the difference between the original (PNG) and the compressed version.

from PIL import Image
import numpy as np

original = np.array(Image.open("photo.png")).astype(np.float32)

for q in [95, 80, 50, 20, 5]:
    Image.open("photo.png").save(f"q{q}.jpg", quality=q)
    compressed = np.array(Image.open(f"q{q}.jpg")).astype(np.float32)

    diff = original - compressed
    diff_visual = ((diff - diff.min()) / (diff.max() - diff.min()) * 255)
    Image.fromarray(diff_visual.astype(np.uint8)).save(f"diff_q{q}.png")

The results are striking:

  • At quality=95, the difference map is almost black—losses are confined to noise.
  • At quality=80, differences localize around contours, fine lines, and high-frequency textures (hair, fabrics)—exactly the components DCT places in high-frequency coefficients and that quantization zeroes out first.
  • At quality=5, the difference map becomes recognizable as a “grainy version of the original”—the algorithm has already gone beyond the bounds of CSF and started removing information essential for perceiving shape.

This isn’t a coding artifact—it’s a map of your own visual thresholds.

Quality 80: The Inflection Point on the CSF Curve

Why exactly 80—the de facto web standard? The graph showing file size versus SSIM (structural similarity index) as a function of quality reveals a clear inflection point around 80. Before that, increasing quality (SSIM) happens with only a small increase in file size. After that, file size doubles for a negligible gain in SSIM (less than 0.001).

This coincides with the shift from “cutting invisible frequencies” to “cutting visible ones.” Quantization at quality < 80 operates in the zone where CSF is near zero; at quality > 80, it operates in the zone where CSF rises sharply. Thus, the rule “quality=80” isn’t a magic number; it’s a practical approximation of the contrast-sensitivity threshold for a typical image viewed under standard conditions (30 cm, 1080p).

What Matters

  • JPEG doesn’t compress the “picture”; it models how the visual system works: rods/cones → Y/CbCr, peripheral color vision → chroma subsampling, neural frequency selectivity in V1 → DCT, contrast-sensitivity thresholds → quantization table.
  • The coefficients in the formula Y = 0.299R + 0.587G + 0.114B aren’t approximations—they’re a parameterized model of the human eye’s spectral sensitivity.
  • The 4:2:0 chroma subsampling mode matches the actual resolution ratio of monochrome to color vision (~4:1), not technical hardware limitations.
  • The quantization table isn’t a static template; it’s an empirical map of CSF derived from lab experiments on live subjects.
  • Quality=80 isn’t a “compromise”; it’s the point where the algorithm stops working in the zone of invisible losses and starts affecting components that are perceptible in the image.

— Editorial Team

Advertisement 728x90

Read Next