← Explainer Library

Interactive Explainer

Perceptual Quality, Pixel by Pixel

PSNR has been the workhorse of image-quality measurement for forty years. SSIM, MS-SSIM, and LPIPS exist because it lies. Distort a reference image in five ways live, watch the metrics disagree, and see the classic "same PSNR, very different perceived quality" trap. Then FID and KID for generative models.

Prelude

Why "MSE was fine, actually" stopped being true

For most of image processing's history, two images were compared by mean squared error (MSE) or its log-scaled cousin PSNR. Compress a photograph; measure the MSE; report a number; ship. The procedure has the virtue of being differentiable, cheap, and uncontroversial.

It also has one catastrophic problem: the human visual system does not perceive error pixel-by-pixel. A constant brightness offset of 5/255 across an image is essentially invisible — yet contributes the same MSE as changing every tenth pixel by 50/255, which is glaringly obvious. Same MSE, two visual planets apart.

The reaction was a sequence of metrics that try to encode increasingly accurate models of what humans actually see: local structure (SSIM), multi-scale structure (MS-SSIM), mid-level perceptual features (LPIPS), and — for generative models where there is no reference — distribution-level metrics (FID, KID).

The single most useful intuition. PSNR cares about energy. SSIM cares about correlated structure. LPIPS cares about high-level perceptual content (edges, textures, parts). FID cares whether two image sets were drawn from the same distribution. They are not interchangeable, and the literature is littered with papers whose claims dissolve when you switch metric.
Step 1

PSNR — MSE in decibels

Given a reference image $x$ and a distorted copy $y$, with each pixel in $[0, L]$ (typically $L = 255$ or $L = 1$):

PSNR is just the negative log of MSE, normalised by the dynamic range. The decibel scale compresses several orders of magnitude into a single number you can compare across codecs. As a back-of-envelope:

These thresholds are indicative, not perceptual law. The same 30 dB image can look pristine if the error is uniform brightness, and like garbage if it is salt-and-pepper noise. The interactive cards below make this concrete.

PSNR's three honest virtues: it is convex in $y$, it admits a closed-form gradient, and it is what your codec publication will be compared on. Its three honest sins: uniform per-pixel weighting, blindness to spatial structure, and blindness to anything the human visual system actually exploits.

Step 2

SSIM — luminance, contrast, structure

Wang et al. (2004) made a small, brilliant observation: perceived similarity can be decomposed into three local comparisons — does brightness match, does contrast match, does the pattern match? Run each on a small sliding window, multiply, average.

On a window with local means $\mu_x, \mu_y$, local variances $\sigma_x^2, \sigma_y^2$, and local covariance $\sigma_{xy}$, define

The product $l \cdot c \cdot s$ collapses to the iconic single-line SSIM formula

with stabilisers $C_1 = (0.01 L)^2$, $C_2 = (0.03 L)^2$. Average over all windows to get the image-level SSIM. Range: $[-1, 1]$; identical images give $1$.

What this buys you:

Why a window matters. Compute the three terms on the whole image and you'd get a global summary that washes out local patterns. SSIM is essentially a Pearson-correlation filter that operates at the scale of an 8×8 or 11×11 patch — the scale at which human vision aggregates structure.
Step 3

MS-SSIM — and why one window isn't enough

A single 11×11 window has a single spatial frequency band of sensitivity. But human vision is multi-scale: an identical SSIM at 8×8 can correspond to two perceptually different images if one preserves coarse structure and the other preserves fine. Multi-Scale SSIM (Wang et al., 2003) computes SSIM at $M$ downsampled levels and combines them as a weighted product:

The weights $\alpha, \beta_j, \gamma_j$ were fitted on human-rated distortions. The headline benefit: MS-SSIM tracks subjective quality better than single-scale SSIM for blurring and compression, and it became the standard for image-compression evaluation.

Once you see this, you start asking the bigger question: if multi-scale structure is the right thing to compare, why define structure by hand? Could we let a network learn it?

Step 4

LPIPS — distance in a learned feature space

LPIPS (Zhang et al., 2018, "The Unreasonable Effectiveness of Deep Features as a Perceptual Metric") replaces hand-crafted structure with the activations of a pretrained image classifier. Run both images through, say, AlexNet or VGG-16; extract feature maps $\phi^{(\ell)}(x)$ and $\phi^{(\ell)}(y)$ at several layers; compute a per-channel learnt weighting and take the L2 distance.

The weights $w_\ell$ are trained on the BAPPS dataset: human raters were given two distorted versions of the same reference and asked which looked more like the original. LPIPS is the linear combination of per-layer feature distances that best agrees with those 2AFC choices.

Three things this gets you that SSIM does not:

What LPIPS is not. It is not a ground-truth perception model — it is a regression fit to a particular dataset of 2AFC judgments. It inherits the backbone's biases (ImageNet's texture-heavy worldview), and an image can be made to look bad to humans while keeping LPIPS small (adversarial perceptual attacks). Reporting LPIPS alongside PSNR + SSIM is more informative than any one of them alone.
Step 5

Live: distort a reference, watch the metrics

A small synthetic test image — gradient sky, a circle, a checkered patch, and a striped band. The left panel is the unmodified reference. The right panel is the same image after the distortion you choose. Watch how each metric responds.

The "Perceptual proxy" column is a hand-rolled stand-in for LPIPS: a multi-scale gradient-feature L2 distance. It is not LPIPS — a real LPIPS needs a pretrained CNN — but it captures the same spirit (distance in a feature space that weights edges and textures over flat regions).

noise std σ 0.10
reference
64 × 64, grayscale, [0, 1]
distorted
noise σ = 0.10
MSE lower is better
PSNR dB, higher is better
SSIM [0, 1], higher is better
Perceptual proxy LPIPS-style; lower is better

Things worth trying:

Step 6

The classic trap: same PSNR, different quality

This is the figure that launched a thousand SSIM citations (essentially Wang & Bovik's original 2002 demo). Below are five distorted versions of the same reference, each with their distortion strength tuned so that PSNR is approximately equal — yet they look obviously different, and SSIM and the perceptual proxy reflect that.

The brightness-shift card has the same MSE as the others — but to the eye it is almost indistinguishable from the reference, and SSIM reflects that. The block-quantised card looks the worst; its SSIM and perceptual proxy are the worst by a margin. PSNR cannot tell them apart.

The lesson. When a paper reports only PSNR, distrust the comparison. When a paper reports PSNR + SSIM + LPIPS together, you can begin to triangulate. When they all agree, you have a real result; when they disagree, the disagreement is the finding.
Step 7

When there is no reference: FID, KID, IS

PSNR, SSIM and LPIPS are full-reference metrics — they need a clean ground-truth image. For generative models (GANs, diffusion, VAEs) there is no reference for an individual sample; what we want is "did this model produce samples that collectively match the data distribution?". For that we go to distributional metrics.

FID quirks worth knowing. FID is biased downward as $N$ shrinks — always report it at a fixed sample size (typically 50k). FID is sensitive to image resolution and preprocessing; "FID = 8.4" without knowing the reference set and pipeline is uninterpretable. Different Inception checkpoints give different numbers. Always cite the FID computation library used.
Step 8

When to use what

Task Use Why
Lossless / near-lossless compression PSNR Differences are sub-perceptual; energy is the right summary, and PSNR is what your competitors will report.
Lossy compression, super-resolution PSNR + SSIM + LPIPS SSIM catches structural damage; LPIPS catches texture & mid-level perceptual changes; PSNR anchors the energy.
Denoising / deblurring PSNR + SSIM Distortions are local; structural-similarity is the metric the denoising literature converged on.
GAN / diffusion samples (unconditional) FID + KID + Precision/Recall No reference image; you need distribution-level metrics. FID alone is not enough — it hides mode collapse.
Conditional generation (img2img, edit) LPIPS + FID + a CLIP score LPIPS measures fidelity to the input; FID measures realism; a CLIP score measures alignment with the target caption / class.
Thermal / scientific imaging RMSE on physical units + SSIM Pixel values are calibrated measurements (temperature, depth); physical accuracy matters more than perceived prettiness, but SSIM still catches structural artefacts in reconstruction.
Diffusion training loss noise-MSE (the actual loss) Don't try to use SSIM/LPIPS as a training signal during diffusion training — they are non-convex, and MSE on the noise has the right variational properties.
Step 9

Sharp edges and lab-aligned notes

Step 10

Reading list