histomicstk.preprocessing.augmentation

This package contains utility functions to augment images.

This is relevant in training convolutional neural network models. Refer to this study …

Tellez, David, Geert Litjens, Peter Bandi, Wouter Bulten, John-Melle Bokhorst, Francesco Ciompi, and Jeroen van der Laak. “Quantifying the effects of data augmentation and stain color normalization in convolutional neural networks for computational pathology.” arXiv preprint arXiv:1902.06543 (2019).

histomicstk.preprocessing.augmentation.perturb_stain_concentration(StainsFloat, W, I_0=None, mask_out=None, sigma1=0.9, sigma2=0.9)[source]

Perturb stain concentrations in SDA space and return augmented image.

This is an implementation of the method described in Tellez et al, 2018 (see below). The SDA matrix is perturbed by multiplying each channel independently by a value chosen from a random uniform distribution in the range [1 - sigma1, 1 + sigma1], then add a value chosen from another random uniform distribution in the range [-sigma2, sigma2].

Parameters:
  • StainsFloat (array_like) – An intensity image (m, n, 3) of deconvolved stains that is unbounded, suitable for reconstructing color images of deconvolved stains with color_convolution.

  • W (array_like) – A 3x3 complemented stain matrix.

  • I_0 (float or array_like, optional) – A float a 3-vector containing background RGB intensities. If unspecified, use the old OD conversion.

  • mask_out (array_like, default is None) – if not None, should be (m x n) boolean numpy array. This parameter ensures exclusion of non-masked areas from perturbing. This is relevant because elements like blood, sharpie marker, white space, etc cannot be simply modeled as a mix of two stains.

  • sigma1 (float) – parameter, see beginning of this docstring.

  • sigma2 (float) – parameter, see beginning of this docstring.

Returns:

Color augmented RGB image (m x n x 3)

Return type:

array_like

References

histomicstk.preprocessing.augmentation.rgb_perturb_stain_concentration(im_rgb, stain_unmixing_routine_params=None, **kwargs)[source]

Apply wrapper that calls perturb_stain_concentration() on RGB.

Parameters:
  • im_rgb (array_like) – An RGB image (m x n x 3) to color normalize

  • stain_unmixing_routine_params (dict) – kwargs to pass as-is to the color_deconvolution_routine().

  • kwargs (k,v pairs) – Passed as-is to perturb_stain_concentration()

Returns:

Color augmented RGB image (m x n x 3)

Return type:

array_like