PathoPainter: Augmenting Histopathology Segmentation via Tumor-aware Inpainting

Hong Liu, Haosen Yang, Evi M. C. Huijben, Mark Schuiveling, Ruisheng Su, Josien P. W. Pluim, Mitko Veta

TL;DR

PathoPainter is a novel data augmentation framework that improves histopathology tumor segmentation by treating data synthesis as a tumor-aware inpainting task. By conditioning a latent diffusion model on regional tumor embeddings from different images and filtering out low-quality synthetic regions, it generates highly diverse, perfectly aligned image-mask pairs that significantly boost segmentation performance in data-scarce environments.

What Problem Does This Paper Address?

Training deep learning models to accurately segment tumors in histopathology requires pixel-precise annotations on gigapixel Whole Slide Images (WSIs). Acquiring these annotations is incredibly labor-intensive, often requiring hours of expert pathologist time for a single slide.

While data augmentation using generative models is a promising solution, existing methods fall short. Generating entire images from scratch (e.g., style-conditioned models) frequently causes misalignments between the newly generated image and its original ground-truth mask. On the other hand, unconditioned inpainting methods tend to overfit the training data, failing to capture the intricate variations in appearance, texture, and staining characteristic of real tissue. PathoPainter addresses these challenges by ensuring strict image-mask alignment while introducing controlled biological diversity.

Methods

Illustration of various synthetic methods compared to PathoPainter.

PathoPainter reformulates image-mask pair generation by utilizing a conditional Latent Diffusion Model (LDM) split into distinct training and inference workflows:

  • Background Preservation: During training, the model uses a mask to isolate and encode only the non-tumor background features, ensuring that the surrounding healthy tissue structure remains completely unaltered and realistic.
  • Regional Tumor Conditioning: To guide the tumor generation process, the authors employ a self-supervised pretrained (SSP) vision transformer (HIPT) combined with mask pooling. This extracts a precise 1D embedding representing the specific characteristics of the tumor region.
  • Cross-Image Embedding Sampling: During inference, instead of using the original image's tumor embedding, PathoPainter randomly samples a tumor embedding from a different image within the same tumor type (categorized via K-means clustering). This allows the model to paint a completely new tumor texture onto an existing background.
  • Uncertain Region Filtering: Local inaccuracies in synthetic data can harm downstream models. To mitigate this, the authors introduce a self-adaptive filtering strategy: any synthetic tumor pixel that a segmentation model pretrained on real data fails to classify correctly (false negatives) is marked as "uncertain" and excluded from the training loss computation.
Overview of the PathoPainter framework showing training and inference pipelines.

Datasets

The authors evaluated PathoPainter across three distinct histopathology datasets under simulated low-data regimes:

  1. DCIS (Ductal Carcinoma in Situ): A breast cancer dataset consisting of 116 WSIs. Experiments were conducted using small subsets of 8 and 20 WSIs.
  2. CATCH (Pan-tumor Canine Cutaneous Cancer Histology): A canine skin cancer dataset containing 350 WSIs across 7 tumor types. Subsets of 7 and 14 WSIs were used for evaluation.
  3. CAMELYON16: A prominent human breast cancer metastasis challenge dataset. Subsets of 10 and 20 WSIs were sampled for training.

Key Insights and Ideas

  • Inpainting Over Full-Image Generation: Keeping the real background intact inherently solves the layout and mask misalignment problem. While full-image generators struggle to match complex cellular boundaries to a static mask, inpainting forces the model to respect existing boundaries.
  • Borrowing Textures for Plausible Diversity: Swapping tumor embeddings across different patients or slides allows the model to synthesize novel combinations of tumor morphologies and background environments without breaking biological plausibility.
  • Leveraging Pretrained Models as Automated Quality Control: The realization that local synthesis errors can be identified by checking where a real-data-trained model struggles allows for automated data cleaning, ensuring the downstream segmentor is not confused by bad synthetic examples.

Key Results

PathoPainter consistently outperformed existing state-of-the-art synthesis methods (such as DiffTumor and STEDM) across all datasets and training scales:

  • CAMELYON16: Incorporating PathoPainter synthetic data into a 20-WSI training set boosted the Swin-Unet segmentation Intersection over Union (IoU) score from 75.69% to 77.69%.
  • DCIS: In an ultra-sparse setting of just 8 WSIs, IoU improved from 62.33% to 63.67%.
  • CATCH: On 14 WSIs, performance increased from 84.77% to 85.82%.

Qualitatively, the generated tumor regions blended seamlessly into their surroundings while introducing realistic variations, such as darker H&E staining and denser tumor textures, which effectively regularized the downstream segmentation models.

Limitations and Future Work

The authors do not explicitly detail limitations in a dedicated section. However, a clear dependency exists within their framework: the self-adaptive filtering strategy relies on a segmentation model pretrained on the available real dataset. In extremely low-data regimes where the initial real dataset is too small to train a baseline model with baseline competency, the filtering mechanism's ability to accurately identify false negatives might degrade. Future work could explore leveraging broader foundation models to make this filtering step entirely independent of the target dataset's scale.

Summary updated

BibTeX
@inproceedings{liu2025pathopainter,
  author = {Hong Liu and Haosen Yang and Evi M. C. Huijben and Mark Schuiveling and Ruisheng Su and Josien P. W. Pluim and Mitko Veta},
  title = {{PathoPainter: Augmenting Histopathology Segmentation via Tumor-aware Inpainting}},
  booktitle = {International Conference on Medical Image Computing and Computer-Assisted Intervention},
  year = {2025},
  doi = {10.1007/978-3-032-05325-1\_39},
}
Figure