Learning Better Lossless Compression Using Lossy Compression

Fabian Mentzer, Luc Van Gool, Michael Tschannen

Abstract

We leverage the powerful lossy image compression algorithm BPG to build a lossless image compression system. Specifically, the original image is first decomposed into the lossy reconstruction obtained after compressing it with BPG and the corresponding residual. We then model the distribution of the residual with a convolutional neural network-based probabilistic model that is conditioned on the BPG reconstruction, and combine it with entropy coding to losslessly encode the residual. Finally, the image is stored using the concatenation of the bitstreams produced by BPG and the learned residual coder. The resulting compression system achieves state-of-the-art performance in learned lossless full-resolution image compression, outperforming previous learned approaches as well as PNG, WebP, and JPEG2000.

Introduction

Lossless compression is a fundamental challenge in data storage, requiring the perfect reconstruction of an image with zero distortion. According to Shannon’s information theory, the efficiency of lossless compression is fundamentally limited by how accurately we can model the underlying probability distribution of the data. Traditional methods, such as PNG, rely on hand-crafted filters to predict pixel values, which often fails to capture complex spatial dependencies, leaving significant redundancy in the compressed file.

While modern deep learning approaches like PixelCNN offer superior modeling capabilities, they are often computationally prohibitive for full-resolution images due to their autoregressive nature—generating pixels one-by-one. This paper introduces a hybrid system that achieves state-of-the-art performance by combining a high-quality classical lossy compressor (BPG) with a deep neural network designed to model the residual information efficiently.

Proposed Method

The core of the proposed system is a "decompose-and-model" strategy. Instead of modeling the raw image pixels directly, the system first generates a high-quality lossy approximation and then focuses the neural network's capacity on the remaining details.

High-level overview of the lossless compression pipeline using BPG and a learned residual coder.

The Compression Pipeline

  1. Lossy Base (BPG): The input image $x$ is compressed using BPG (Better Portable Graphics), a codec based on HEVC. This produces a lossy reconstruction $x_l$.
  2. Residual Calculation: The difference between the original and the lossy version ($r = x - x_l$) is calculated. Because BPG is highly effective at capturing structural information, the residual $r$ is typically sparse, containing primarily fine textures and high-frequency noise.
  3. Residual Compressor (RC): A convolutional neural network (CNN) takes the lossy image $x_l$ as input to predict the conditional probability distribution of the residual, $p(r|x_l)$.
  4. Entropy Coding: The residual is then losslessly encoded using Arithmetic Coding (AC) based on the predicted distribution.

Architecture of the Residual Compressor

The Residual Compressor (RC) utilizes a sophisticated architecture to handle full-resolution images efficiently. It employs a hybrid U-Net/ResNet structure and incorporates Generalized Divisive Normalization (GDN) layers, which have been shown to be particularly effective in modeling the statistics of natural images.

Detailed architecture of the Residual Compressor (RC) featuring residual blocks and mixture model parameter estimation.

To represent the complex pixel distributions of the residual, the RC does not predict a single value. Instead, it outputs the parameters ($\mu, \sigma, \pi, \lambda$) for a mixture of five logistic distributions. This allows the model to express uncertainty and capture the multi-modal nature of residual errors.

Optimization Techniques

  • Q-Classifier (QC): A small auxiliary network predicts the optimal BPG quantization parameter ($Q$) for each image. This balances the bit budget between the lossy base and the residual coder.
  • $\tau$-Optimization: A post-training refinement step where the model's temperature (confidence) is fine-tuned for each specific image at encoding time, further reducing the final bitrate.

Key Insights

  • BPG as a Prior: By using BPG as a base, the neural network is provided with a strong prior. It does not need to learn the fundamental geometry of the scene from scratch; it only needs to learn the specific high-frequency details that BPG discards.
  • Residual Sparsity: The authors observe that for high-quality BPG settings, the vast majority of residual values fall within a very narrow range (e.g., -6 to 6). Modeling this sparse distribution is significantly easier and more efficient than modeling the full 0-255 range of raw pixels.
  • Bitrate Balancing: The system identifies a critical trade-off: if the BPG quality is too low, the residual becomes too complex for the CNN; if it is too high, the BPG bitstream itself becomes bloated. The Q-Classifier automates the discovery of this "sweet spot."

Experimental Results

The model was trained on 300,000 images from the Open Images dataset and evaluated across several benchmarks, including CLIC and DIV2K. The proposed method, referred to as RC, consistently achieved state-of-the-art results:

  • Compression Efficiency: On the Open Images validation set, it achieved 2.790 bits per subpixel (bpsp), outperforming the previous best learned method, L3C (2.991 bpsp), by over 7%.
  • Comparison to Standards: The system outperformed PNG by 44% and WebP by 9.2%. It also demonstrated superior generalization, beating JPEG2000 across diverse datasets.
  • Computational Performance: Decoding a 512x512 image takes approximately 418ms on an NVIDIA Titan XP. While slower than classical methods, it is significantly faster than autoregressive models and practical for high-end applications.

Conclusion

This work demonstrates that leveraging classical lossy codecs as a foundation for learned lossless compression is a highly effective strategy. By focusing the neural network's power on modeling the residual of a BPG reconstruction, the authors achieve a new state-of-the-art in compression efficiency. Future work may involve replacing BPG with a fully learned lossy component to enable end-to-end optimization of the entire pipeline.

Summary updated

BibTeX
@inproceedings{mentzer2020learning,
  author = {Fabian Mentzer and Luc Van Gool and Michael Tschannen},
  title = {{Learning Better Lossless Compression Using Lossy Compression}},
  booktitle = {IEEE/CVF Conference on Computer Vision and Pattern Recognition},
  year = {2020},
  url = {https://openreview.net/forum?id=ZMf4EUJ9Xx},
}
Figure