Efficient Masked Image Compression with Position-Indexed Self-Attention

Chengjie Dai, Tiantian Song, Hui Tang, Fangdong Chen, Bowei Yang, Guanghua SongarXiv 2025

TL;DR

Efficient Masked Image Compression (EMIC) is a novel framework designed for machine vision tasks that applies semantic masking before encoding, processing only the essential foreground patches of an image. By introducing a position-indexed self-attention mechanism, EMIC preserves the spatial relationships of these disjoint patches, slashing computational complexity (FLOPs) by nearly two-thirds while maintaining high accuracy for downstream tasks like object detection and instance segmentation.

What Problem Does This Paper Address?

Traditional image compression algorithms (like JPEG or standard neural codecs) are optimized for human eyes, focusing on preserving overall visual appeal. However, autonomous systems performing high-level vision tasks—such as object detection or instance segmentation—don't need to see the entire background; they only care about semantically meaningful objects.

While recent "semantic-structured" codecs attempt to address this by transmitting only object-related data, they typically apply masking after encoding the full image. Even if background regions are zeroed out beforehand, standard convolutional or transformer networks still waste significant computational resources processing those empty pixels because they expect a complete, structured 2D grid.

The authors of this paper tackle a fundamental challenge: How do you feed only the scattered, irregular patches of an object into a compression network from the very start without breaking the network's understanding of where those patches belong in 2D space?

Methods

The authors introduce EMIC (Efficient Masked Image Compression), a framework that discards background patches immediately after patch embedding, leaving an unordered sequence of visible patches to be encoded and decoded.

To make this work, they introduce several key innovations:

  • Position-Indexed Self-Attention (PISA): When background patches are removed, the remaining patches lose their spatial context. PISA solves this by tracking the original 2D raster indices of the visible patches. It uses these indices to compute a Manhattan distance decay matrix, which acts as a spatial prior to weight the self-attention mechanism. This ensures that patches close to each other in the original image retain a stronger attention bond.
  • Decomposed PISA (DPISA): To handle the massive computational overhead of global self-attention in early network stages, the authors separate attention into two steps: first at a macro "mask unit" level (16x16 patches), and then within those units at an "attention unit" level (2x2 patches).
  • Attention-Based Entropy Model: Standard hyperprior entropy models rely on convolutions to estimate bit distributions. Because EMIC's latent features represent non-adjacent spatial regions, standard convolutions fail. EMIC replaces them entirely with linear layers and position-indexed self-attention to compress hyperpriors effectively.
The framework of the EMIC masked image compression network.

Datasets

The model was trained and evaluated using two primary datasets:

  1. COCO: Used to evaluate downstream machine vision performance. The authors trained the model on the standard training set and tested it on a random sample of 500 validation images using YOLOv8l and Mask R-CNN (with an X101-FPN backbone) for object detection and instance segmentation.
  2. Kodak24: Consisting of 24 high-quality color images, this dataset was utilized to benchmark computational complexity, encoding/decoding speeds, and FLOPs under synthetic masking ratios (20%, 40%, 60%, and 80%).

Key Insights and Ideas

  • Shift Masking to the Front: The core "aha" moment is that shifting the semantic mask to the very beginning of the pipeline is the only way to achieve true computational savings. Masking late wastes encoder cycles; masking early saves them.
  • Geometry via Indexing: Unordered sequences of patches normally destroy inductive biases about image geometry. Re-injecting the original 2D coordinates via Manhattan distance calculations elegantly restores the principle that "nearby things are more related" without needing a rigid 2D pixel grid.
  • Convolutions are Grid-Bound: The realization that convolutional hyperpriors break on non-contiguous masked data highlights a hidden limitation of hybrid CNN-Transformer architectures, justifying EMIC's purely attention-driven entropy model.
Sampling the Manhattan distance decay matrix based on position indices.

Key Results

EMIC was compared against human-centric codecs (TCM, MLIC++, VTM) and the state-of-the-art semantic codec GIT-SSIC.

  • Massive Compute Savings: On the Kodak dataset, EMIC reduced computational complexity to 63.32 GFLOPs, roughly one-third of the 193.42 GFLOPs required by GIT-SSIC.
  • Faster Encoding: EMIC achieved the fastest encoding time among all compared learned models at 160ms (compared to GIT-SSIC's 240ms).
  • Maintained Accuracy: Despite processing far fewer pixels, EMIC achieved downstream task accuracy ([email protected]) comparable to GIT-SSIC across both YOLOv8 and Mask R-CNN architectures, while significantly outperforming human-targeted codecs at lower bitrates.
  • Preserved Visual Quality: Within the unmasked object regions, EMIC maintained high visual fidelity (measured via PSNR and MS-SSIM), ensuring the reconstructed patches remain perfectly viable for human-in-the-loop verification.

Limitations and Future Work

The authors do not include a dedicated limitations section, but a few dependencies are apparent from the text:

  • External Mask Dependency: EMIC assumes a semantic mask is already available or pre-computed by a downstream task toolbox. The computational overhead and latency of generating this initial mask are not factored into the core network's performance metrics.
  • Future Directions: A natural progression would involve exploring end-to-end frameworks where mask generation and masked patch compression are jointly optimized within a single, unified model.

Summary updated

BibTeX
@misc{dai2025efficient,
  author = {Chengjie Dai and Tiantian Song and Hui Tang and Fangdong Chen and Bowei Yang and Guanghua Song},
  title = {{Efficient Masked Image Compression with Position-Indexed Self-Attention}},
  year = {2025},
  eprint = {2504.12923},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2504.12923},
}
Figure