Pathology Image Compression with Pre-trained Autoencoders

Srikar Yellapragada, Alexandros Graikos, Kostas Triaridis, Zilinghan Li, Tarak Nath Nandi, Ravi K. Madduri, Prateek Prasanna, Joel H. Saltz, Dimitris Samaras

Abstract

The digitization of histopathology slides into Whole Slide Images (WSIs) has revolutionized medical machine learning but introduced a significant infrastructure burden. Standard compression techniques like JPEG often introduce artifacts that compromise the cellular details required for downstream AI analysis. This study proposes repurposing pre-trained autoencoders from Latent Diffusion Models (LDMs) to compress pathology images. By implementing decoder-only fine-tuning with a pathology-specific perceptual loss and a K-means clustering-based quantization strategy, the authors achieve superior compression rates compared to JPEG while maintaining high fidelity for diagnostic tasks. Results demonstrate that these highly compressed images perform almost identically to uncompressed originals on downstream diagnostic tasks.

Introduction

The transition to digital pathology has enabled the application of deep learning to large-scale histopathology datasets. However, a single pathology center can generate over a million slides annually, resulting in petabytes of data and substantial archival costs. While standard compression algorithms like JPEG are commonly used to mitigate storage requirements, they often fail to preserve the fine-grained morphological features—such as nuclear structure and texture—that are critical for automated diagnostic models. Aggressive JPEG compression introduces blocky artifacts and deforms cellular structures that downstream AI models rely on for tasks like cancer subtyping and segmentation.

Existing learned compression methods frequently struggle with generalization when applied outside their training distribution. This research investigates whether robust autoencoders (AEs) developed for internet-scale generative AI, such as Stable Diffusion, can be adapted to the medical domain to provide efficient, high-fidelity compression for pathology.

Methodology

The authors leverage pre-trained autoencoders from three prominent Latent Diffusion Models: Stable Diffusion 1.5 (SD-1.5), Stable Diffusion 3 (SD-3), and the Deep Compression Autoencoder (DC-AE-f32). To optimize these models for pathology, two primary innovations were introduced:

1. Decoder-Only Fine-Tuning

To maintain the generalizability of the latent space while specializing the output for medical textures, the authors froze the encoder and fine-tuned only the decoder. This process utilized a pathology-specific perceptual loss, calculated by minimizing the L1 distance between the embeddings of original and reconstructed images. These embeddings were extracted using UNI, a state-of-the-art pathology foundation model, ensuring that the reconstruction preserves biologically relevant features.

2. K-Means Clustering-Based Quantization

Standard 8-bit (int8) quantization often fails for AE latents, which tend to cluster near zero due to regularization during their original training. To address this, the authors employed K-means clustering to learn the actual distribution of the latent representations. By storing only the cluster indices, they achieved significant file size reductions without the severe artifacts associated with uniform rounding.

Experimental Setup

The models were fine-tuned using 24 million image patches from the TCGA dataset, covering breast, colon, and prostate tissues. Evaluation focused on two areas:

  • Reconstruction Fidelity: Measured using cosine similarity of embeddings from foundation models (UNI, Phicon-v2, and Gigapath) rather than traditional metrics like PSNR or SSIM, which often fail to capture biological validity.
  • Downstream Task Performance: Evaluated on slide-level subtyping (TCGA-BRCA), patch-level classification (NCT-CRC), and pixel-level semantic segmentation (BCSS and CRAG).

Results and Discussion

The proposed method demonstrated a clear advantage over traditional compression. The fine-tuned DC-AE-f32 model, combined with K-means quantization, compressed image patches to approximately 2 KB while maintaining a UNI embedding similarity of 0.906. In contrast, JPEG compression at a larger file size (5 KB) resulted in a significantly lower similarity score of 0.512.

In downstream applications, the utility of the compressed images was nearly indistinguishable from the originals:

  • Segmentation: On the CRAG dataset, images compressed via DC-AE-f32 (32 KB) achieved a Dice score of 87.20, compared to 87.16 for uncompressed images. JPEG-10 compression (93 KB) caused the Dice score to drop to 83.45.
  • Classification: For TCGA-BRCA subtyping, models trained on SD-1.5 reconstructions achieved 93.96% accuracy, nearly matching the 94.89% accuracy of uncompressed data.

Conclusion and Future Outlook

This research highlights the potential of repurposing generative AI components for specialized medical tasks. By adapting pre-trained autoencoders with domain-specific losses and intelligent quantization, the authors provide a pathway to drastically reduce the storage footprint of digital pathology without sacrificing the performance of AI-driven diagnostics.

The primary limitation remains computational speed, as neural network decompression is slower than standard JPEG. However, solving the storage bottleneck will vastly increase the availability of WSI data, which is critical for training the next generation of even larger, more capable pathology foundation models.

Summary updated

BibTeX
@inproceedings{yellapragada2025pathology,
  author = {Srikar Yellapragada and Alexandros Graikos and Kostas Triaridis and Zilinghan Li and Tarak Nath Nandi and Ravi K. Madduri and Prateek Prasanna and Joel H. Saltz and Dimitris Samaras},
  title = {{Pathology Image Compression with Pre-trained Autoencoders}},
  booktitle = {International Conference on Medical Image Computing and Computer-Assisted Intervention},
  year = {2025},
  doi = {10.1007/978-3-032-04937-7\_42},
}
Figure