Skip to content

Instantly share code, notes, and snippets.

@KernelA
KernelA / rgb-hsi.py
Last active May 4, 2019 19:51
NumPy direct and inverse conversion RGB to HSI
import numpy as np
def rgb2hsi(rgb: np.ndarray) -> np.ndarray:
"""Conversion RGB to HSI
h (hue) in [0; 2 pi], s (saturation) in [0; 1], i (intensity) in [0; 1].
If 'rgb' color is black, white or grayscale then h component is undefined (np.nan).
Description: