osc.viz.utils.array_to_pil

array_to_pil(img, cmap=None, scale_range=True)[source]

Array or tensor to PIL image. Works for both grayscale and RGB images.

Parameters
  • img (Union[ndarray, Tensor]) – [H W] or [H W C] image, dtype uint8 or float

  • cmap (Optional[str]) – colormap for grayscale images

  • scale_range – if True, rescale a grayscale image to cover the full color range

Return type

Image

Returns

A PIL image.