DCT Image Compression
Worked through the JPEG pipeline by hand, then swept the quantization matrix to find the ideal quality factor.
JPEG is lossy compression. How much you can throw before it matters? Scaling the quantization matrix sweeps a quality factor from 0 to 2. Scoring each reconstruction against the original with SSIM gives a clean inverse curve. Naively maximizing SSIM per kilobyte says quality factor 0 is optimal, but that image is visibly wrecked. Instead reading the SSIM curve through diminishing returns puts the practical optimum between 0.4 and 0.6.


The full derivation and the matrices at every stage are in the paper: