How Lossy & Lossless Compression Works

The essence of Image Compression is balancing Storage Space and Visual Quality. This page deeply analyzes how to leverage Mathematical Redundancy and Visual Perception Limits for extreme data reduction.

1. Entropy Coding & Statistical Redundancy

Lossless

Shannon Entropy defines the limit of data compression. Click blocks to change patterns:

Current Entropy: 0.000 bits/px
Stream: 16W

2. Perceptual Redundancy & Color Space

Lossy

The human eye is sensitive to Luma (Y) but insensitive to Chroma (Cb/Cr).

Y = 0.299R + 0.587G + 0.114B

3. Frequency Transform & Quantization

Core Algorithm

Discrete Cosine Transform (DCT) converts images to frequencies, then discards info via Quantization Steps.

High Fidelity
Quantization Strength (Q-Step) Level: 20
PSNR (Signal-to-Noise): 40.00 dB

Rate-Distortion Theory

Trade-off: How much detail can be kept at what size?

R-D Curve: The Algorithm Boundary

All Lossy Algorithms follow a rule: Lower Bitrate (Rate) means higher Distortion. Excellent encoders (like AV1) maintain high similarity at very low bitrates.

Low Bitrate (Blocky) High Bitrate (Sharp)

What is "Transparent Compression"?

When compressed image PSNR reaches about 35-45dB, the Human Visual System (HVS) can barely distinguish it from the original. This art of "tricking" the eye is the core of lossy compression.

SSIM (Structural Similarity) Index

Compared to traditional PSNR, SSIM measures image structure, luminance, and contrast. It aligns better with human subjective aesthetics than simple pixel error calculation.

Why not infinite compression?

Lossless compression is limited by Information Entropy. If data is completely random noise, its entropy is maxed out, and no algorithm can reduce it. Lossy compression can discard more, but if the Quantization Step is too large, the image collapses into solid color blocks.

Intra-prediction

Modern formats like WebP and HEIF introduce Intra-prediction from video coding. They try to predict the current block using surrounding pixels, recording only the "prediction error" (residual), which is more efficient than JPEG's full block recording.