Stain Normalizer¶
Digital pathology images can present strong color differences due to diverse acquisition techniques (e.g., scanners, laboratory equipment and procedures)
The stain_normalizer
module collects methods to transfer the staining style of an image (target) to another image (source).
Stain normalization is often adopted as data standardization procedure in deep learning model training.
The MacenkoStainNormalizer implements the stain normalization method proposed by Macenko et al. 1.
The ReinhardStainNormalizer implements the Reinhard’s stain normalization 2.
Usage¶
The stain normalization methods can be used to transfer the staining’s appearance of any histology image. First, we need to establish the image to be used as a style reference, and the image to be transformed accordingly:
from histolab.stain_normalizer import ReinhardStainNormalizer
from PIL import Image
target_image = Image.open("/path/target/img/img2.png")
target_image
source_image = Image.open("/path/img/to/normalize/img1.png")
source_image
The chosen stain normalization method must be first fit on the target image and then applied to the source image:
normalizer = ReinhardStainNormalizer()
normalizer.fit(target_image)
normalized_img = normalizer.transform(source_image)
normalized_img