This repository provide the core idea of Stain Mix-Up: Domanin Generalization for Histopathology Images as an image augmentation technique.
To address the issue of unseen color domain generalization in histopathological images, the stain mix-up generate a pseudo stain matrix by interpolating stain matrices between soruce and target domain. Hence, images augmented by reverting the source image concentration and the interploated stain matrix can increase variability of training data without shape/detail distortion, and thus increasing model robustness.
Chang, J.-R., Wu, M.-S., Yu, W.-H., Chen, C.-C., Yang, C.-K., Lin, Y.-Y., & Yeh, C.-Y. (2021). Stain mix-up: Unsupervised domain generalization for histopathology images. Medical Image Computing and Computer Assisted Intervention – MICCAI 2021, 117–126. https://doi.org/10.1007/978-3-030-87199-4_11
Copyright (C) 2021 aetherAI Co., Ltd. All rights reserved. Licensed under the CC BY-NC-SA 4.0 license (https://creativecommons.org/licenses/by-nc-sa/4.0/legalcode).
To install the package, users can simply clone the repository and pip install it.
$ git clone https://github.com/aetherAI/stain-mixup.git
$ cd stain_mixup
$ pip install .
NOTE The spams might have other dependencies.
sudo apt install liblapack-dev libblas-dev
- Get stain matrix. You can derive your stain matrix by different methods such as Vahadane or Macenko.
from stain_mixup.utils import get_stain_matrix
stain_matrix = get_stain_matrix(image)
Note: Larger/more images will generate a more stable stain matrix. We strongly recommend users to generate a stable stain matrix by refering to official spams.
- Convert image from the source domain to target domain.
from stain_mixup.augment import stain_mixup
...
augmented_image = stain_mixup(
image,
source_stain_matrix,
target_stain_matrix,
)
Jia-Ren Chang
Min-Shen Wu
Wei-Hsiang Yu
Chi-Chung Chen
Che-Ming Wu