scportrait.plotting.colorize

Contents

scportrait.plotting.colorize#

scportrait.plotting.colorize(im: ndarray, color: tuple[int, ...] = (1, 0, 0), clip_percentile: float = 0.0, normalize_image: bool = False)#

Create an RGB image from a single-channel image using a specified color.

Parameters:
  • im – A single-channel input image. If normalize_image = False, ensure that its values fall between [0, 1].

  • color – The color to use for the image. Defaults to (1, 0, 0).

  • clip_percentile – Percentile to clip the image at when rescaling. Defaults to 0.0 (min-max scaling).

  • normalize_image – Whether to rescale the image before colorizing.

Returns:

The colorized image.

Return type:

np.ndarray

Example

>>> import numpy as np
>>> from scportrait.plotting import colorize
>>> im = np.random.rand(64, 64)
>>> rgb = colorize(im, color=(0, 1, 0), normalize_image=True)