Skip to content

Instantly share code, notes, and snippets.

@KernelA
KernelA / rgb_hsi.h
Last active November 11, 2020 10:35 — forked from rzhukov/rgb_hsi.h
RGB to HSI and HSI to RGB color space conversion
inline void HSI2RGB(double h, double s, double i, double* r, double* g, double* b)
{
double x = i * (1 - s);
// For black, white and grayscale h is NaN. Conversion works incorrectly.
if(std::isnan(h))
{
*r = i;
*g = i;
*b = i;