colourise_image¶
- colourise_image(img, cmap='viridis')[source]¶
If input img is single channel, colourise it.
- Parameters:
img (ndarray) – Single channel or RGB image as ndarray.
cmap (str) – Colormap to use, must be a valid matplotlib cmap string.
- Returns:
An RGB image.
- Return type:
img(ndarray)
Examples
>>> from tiatoolbox.utils.visualization import colourise_image >>> import numpy as np >>> # Generate a random example; replace with your own data >>> img = np.random.rand(255, 255) >>> # Example usage of colourise_image >>> coloured_image = colourise_image(img, 'viridis')