torch_staintools.functional.conversion package

Submodules

torch_staintools.functional.conversion.lab module

torch_staintools.functional.conversion.lab.lab_to_rgb(image: Tensor) Tensor

A simple wrapper to the Kornia implementation of convert LAB from RGB.

Parameters:

image – BxCxHxW

Returns:

torch.Tensor in shape of BxCxHxW

torch_staintools.functional.conversion.lab.rgb_to_lab(image: Tensor) Tensor

A simple wrapper to the Kornia implementation of convert RGB to LAB.

TODO: add other backends (e.g., cv2?) if necessary.

Parameters:

image – Tensor (BxCxHxW)

Returns:

Tensor (BxCxHxW)

torch_staintools.functional.conversion.od module

torch_staintools.functional.conversion.od.od2rgb(OD: Tensor)

Convert Optical Density to RGB space

Cedric Walker’s adaptation from torchvahadane RGB = 255 * exp(-1*OD_RGB)

Parameters:

OD – OD

Returns:

RGB.

torch_staintools.functional.conversion.od.rgb2od(image: Tensor)

Convert RGB to Optical Density space.

Cedric Walker’s adaptation from torchvahadane RGB = 255 * exp(-1*OD_RGB) –> od_rgb = -1 * log(RGB / 255)

Parameters:

image – Image RGB. Input scale does not matter.

Returns:

Optical density RGB image.

Module contents