Efficient Trimmed Convolutional Arithmetic Encoding for Lossless Image Compression

Mu Li, Shuhang Gu, David Zhang, Wangmeng Zuo

Abstract

Arithmetic coding is an essential class of coding techniques. One key issue of arithmetic encoding method is to predict the probability of the current coding symbol from its context, i.e., the preceding encoded symbols, which usually can be executed by building a look-up table (LUT). However, the complexity of LUT increases exponentially with the length of context. Thus, such solutions are limited to modeling large context, which inevitably restricts the compression performance. Several recent deep neural network-based solutions have been developed to account for large context, but are still costly in computation. The inefficiency of the existing methods are mainly attributed to that probability prediction is performed independently for the neighboring symbols, which actually can be efficiently conducted by shared computation. To this end, we propose a trimmed convolutional network for arithmetic encoding (TCAE) to model large context while maintaining computational efficiency. As for trimmed convolution, the convolutional kernels are specially trimmed to respect the compression order and context dependency of the input symbols. Benefited from trimmed convolution, the probability prediction of all symbols can be efficiently performed in one single forward pass via a fully convolutional network. Furthermore, to speed up the decoding process, a slope TCAE model is presented to divide the codes from a 3D code map into several blocks and remove the dependency between the codes inner one block for parallel decoding, which can 60x speed up the decoding process. Experiments show that our TCAE and slope TCAE attain better compression ratio in lossless gray image compression, and can be adopted in CNN-based lossy image compression to achieve state-of-the-art rate-distortion performance with real-time encoding speed.

Introduction

Arithmetic coding is a cornerstone of data compression, where efficiency hinges on accurately predicting the probability of a symbol based on its preceding context. Traditionally, this prediction is handled via Look-Up Tables (LUTs). However, LUTs face an exponential explosion in complexity as context size increases, limiting their effectiveness for complex data.

While Deep Neural Networks (DNNs), such as PixelCNN, can model significantly larger contexts, they are often computationally prohibitive. These models typically predict symbols serially, one-by-one, creating a massive bottleneck that prevents real-time application. The core issue is that previous DNN methods perform probability prediction independently for neighboring symbols, ignoring the potential for shared computation.

Methods

The proposed Trimmed Convolutional Arithmetic Encoding (TCAE) addresses these inefficiencies by enabling a fully convolutional network (FCN) to process an entire image's probability predictions in a single forward pass.

Trimmed Convolution

Standard convolutions aggregate information from all surrounding pixels, which violates the causality requirement of arithmetic coding (where future pixels cannot be used to predict the current one). To solve this, TCAE introduces "trimmed" convolutions. By applying a binary mask to the convolutional kernels, the network is restricted to seeing only previously encoded symbols.

Illustration of Trimmed Convolution for code and feature maps.

As shown in the figure above, different masks are defined for the input layer and hidden layers. This ensures that the "context" for any given coding bit or feature only includes valid, previously processed information. This allows the model to leverage standard, highly-optimized GPU convolution operations to perform causal modeling across an entire volume simultaneously.

Slope TCAE for Parallel Decoding

While TCAE speeds up encoding, decoding remains naturally serial because each symbol depends on its immediate neighbors. To overcome this, the authors introduced Slope TCAE. This variant divides a 3D code map into diagonal "slope" blocks.

Scanning order and dependency structure in Slope TCAE.

By assuming that symbols within a single diagonal block are independent, the model can decode an entire block in parallel. This breaks the strict pixel-by-pixel dependency chain, trading a negligible amount of compression efficiency for a massive increase in decoding speed.

Results and Discussion

The performance of TCAE and Slope TCAE was evaluated using the Kodak PhotoCD dataset after training on 10,000 ImageNet images.

Compression Performance

In lossless gray image compression, TCAE achieved an average compression ratio of 2.00, outperforming standard methods like JPEG2000-LS (1.79) and PNG (1.61). When integrated into CNN-based lossy compression frameworks, it achieved state-of-the-art rate-distortion performance, providing higher image quality at lower bitrates than JPEG and JPEG 2000.

Computational Efficiency

The primary advantage of TCAE is its speed:

  • Encoding: TCAE is 7–20x faster than previous state-of-the-art CNN-based entropy encoders.
  • Decoding: Slope TCAE achieved a 60x speedup over the standard TCAE and was 25x faster than previous CNN encoders, enabling near real-time performance.

Conclusion

TCAE represents a significant step forward in making deep-learning-based arithmetic coding practical. By utilizing trimmed convolutions and the slope-based parallelization strategy, the model captures large-scale context dependencies without the traditional serial bottleneck. While Slope TCAE introduces a minor compression penalty due to its independence assumptions, the resulting 60x speedup makes it a viable candidate for real-time high-performance image compression systems.

Summary updated

BibTeX
@misc{li2018efficient,
  author = {Mu Li and Shuhang Gu and David Zhang and Wangmeng Zuo},
  title = {{Efficient Trimmed Convolutional Arithmetic Encoding for Lossless Image Compression}},
  year = {2018},
  eprint = {1801.04662},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1801.04662},
}
Figure