SBDTypeColorConversion Class Reference

The SBDTypeColorConversion class provides functions to transform colors between different color spaces. More...

Conversions

static void toHCL (float *hcl, float *color)
 Converts sRGB color (as in SBColor) to HCL (cylindrical representation of CIE L*u*v* a.k.a. CIE LCh_uv) More...
 
static void fromHCL (float *color, float *hcl)
 Converts HCL color (cylindrical representation of CIE L*u*v* a.k.a. CIE LCh_uv) to sRGB color (as in SBColor) More...
 
static void HCLfromSRGB (float *hcl, float *rgb)
 Converts standard RGB (sRGB) color to HCL color (cylindrical representation of CIE L*u*v* a.k.a. CIE LCh_uv) More...
 
static void SRGBfromHCL (float *rgb, float *hcl)
 Converts HCL color (cylindrical representation of CIE L*u*v* a.k.a. CIE LCh_uv) to standard RGB (sRGB) color. More...
 
static void SRGBfromRGB (float *srgb, float *rgb)
 Converts linear RGB values to standard RGB (sRGB) values. More...
 
static void RGBfromSRGB (float *rgb, float *srgb)
 Converts standard RGB (sRGB) values to linear RGB values. More...
 
static void CIEXYZfromRGB (float *XYZ, float *rgb)
 Converts linear RGB to CIE XYZ with D65/2° standard illuminant. More...
 
static void RGBfromCIEXYZ (float *rgb, float *XYZ)
 Converts CIE XYZ with D65/2° standard illuminant to linear RGB. More...
 
static void CIEXYZfromSRGB (float *XYZ, float *rgb)
 Converts device independent standard RGB (sRGB) to CIE XYZ with D65/2° standard illuminant. More...
 
static void SRGBfromCIEXYZ (float *rgb, float *XYZ)
 Converts CIEXYZ with D65/2° standard illuminant to device independent standard RGB (sRGB) More...
 
static void CIEXYZfromCIELab (float *XYZ, float *lab)
 Converts CIE L*a*b* to CIE XYZ D65/2° More...
 
static void CIELabfromCIEXYZ (float *lab, float *XYZ)
 Converts CIE XYZ D65/2° to CIE L*a*b*. More...
 
static void CIEXYZfromCIELuv (float *XYZ, float *luv)
 Converts CIE L*u*v* to CIE XYZ D65/2° More...
 
static void CIELuvfromCIEXYZ (float *luv, float *XYZ)
 Converts CIE XYZ D65/2° to CIE L*u*v*. More...
 
static void CylindricalCIELabfromCIELab (float *hcl, float *lab)
 Converts CIE L*a*b* to CIE L*a*b* in cylindrical coordinates (a.k.a. CIE LCh_ab) More...
 
static void CIELabfromCylindricalCIELab (float *lab, float *hcl)
 Converts CIE L*a*b* in cylindrical coordinates (a.k.a. CIE LCh_ab) to CIE L*a*b*. More...
 
static void CylindricalCIELuvfromCIELuv (float *hcl, float *luv)
 Converts CIE L*u*v* to CIE L*u*v* in cylindrical coordinates (a.k.a. CIE LCh_uv) More...
 
static void CIELuvfromCylindricalCIELuv (float *luv, float *hcl)
 Converts CIE L*u*v* in cylindrical coordinates (a.k.a. CIE LCh_uv) to CIE L*u*v*. More...
 
static void CylindricalCIELabfromSRGB (float *hcl, float *rgb)
 Converts standard RGB (sRGB) to CIE L*a*b* in cylindrical coordinates a.k.a. (CIE LCh_ab) More...
 
static void SRGBfromCylindricalCIELab (float *rgb, float *hcl)
 Converts CIE L*a*b* in cylindrical coordinates (a.k.a. CIE LCh_ab) to standard RGB (sRGB) More...
 
static void CylindricalCIELuvfromSRGB (float *hcl, float *rgb)
 Converts standard RGB (sRGB) to CIE L*u*v* in cylindrical coordinates (a.k.a. CIE LCh_uv) More...
 
static void SRGBfromCylindricalCIELuv (float *rgb, float *hcl)
 Converts CIE L*u*v* in cylindrical coordinates (a.k.a. CIE LCh_uv) to standard RGB (sRGB) More...
 

Detailed Description

To use any function in this class, pass two pointers to float arrays (with 3 values) in a function: first one will contain the result, second one contains the input color data.

Example: float color_in_sRGB[3] = {1.0, 0.0, 0.0}; // red color in sRGB color space float color_in_HCL[3]; SBDTypeColorConversion::toHCL(color_in_HCL, color_in_sRGB);

Note that the conversion is not exact. For example, a converstion from sRGB to HCL and then back from HCL to sRGB will result in values that will slightly differ from the original ones by some numerical error due to approximations in conversion functions.

This class provides functions to transform between different color spaces.

Member Function Documentation

◆ CIELabfromCIEXYZ()

void SBDTypeColorConversion::CIELabfromCIEXYZ ( float *  lab,
float *  XYZ 
)
static

SBDTypeColorConversion::CIELabfromCIEXYZ - Converts CIE XYZ D65/2° to CIE L*a*b*.

Parameters
lab- CIE L*a*b* coordinates
XYZ- X, Y, Z input refer to a D65/2° standard illuminant. The CIE XYZ values must be scaled so that the Y of D65 ("white") is 1.0 (X,Y,Z = 0.95047, 1.0000, 1.08883)

◆ CIELabfromCylindricalCIELab()

void SBDTypeColorConversion::CIELabfromCylindricalCIELab ( float *  lab,
float *  hcl 
)
static

SBDTypeColorConversion::CIELabfromCIEPolarLab - Converts CIE L*a*b* in cylindrical coordinates (CIE LCh_ab) to CIE L*a*b*.

Parameters
lab- L*a*b* coordinates in the CIE L*a*b*
hcl- hue, chroma, and luminance values in the cylindrical CIEL*a*b* color space. Cylindrical CIE Lab: H: 0 ... 360; C: 0 ... 100; L: 0 ... 100

◆ CIELuvfromCIEXYZ()

void SBDTypeColorConversion::CIELuvfromCIEXYZ ( float *  luv,
float *  XYZ 
)
static

SBDTypeColorConversion::CIELuvfromCIEXYZ - Converts CIE XYZ D65/2° to CIE L*u*v*.

Parameters
luv- Resulting L*u*v* coordinates in the CIE L*u*v* color space.
XYZ- X, Y, Z input refer to a D65/2° standard illuminant. The CIE XYZ values must be scaled so that the Y of D65 ("white") is 1.0 (X,Y,Z = 0.95047, 1.0000, 1.08883).

◆ CIELuvfromCylindricalCIELuv()

void SBDTypeColorConversion::CIELuvfromCylindricalCIELuv ( float *  luv,
float *  hcl 
)
static

SBDTypeColorConversion::CIELuvfromCIEPolarLuv - Converts CIE L*u*v* in cylindrical coordinates (a.k.a. CIE LCh_uv) to CIE L*u*v*.

Parameters
luv- L*u*v* coordinates in the CIE L*u*v*
hcl- hue, chroma, and luminance values in the cylindrical CIEL*u*v* color space. Cylindrical CIE Luv: H: 0 ... 360; C: 0 ... 100; L: 0 ... 100

◆ CIEXYZfromCIELab()

void SBDTypeColorConversion::CIEXYZfromCIELab ( float *  XYZ,
float *  lab 
)
static

SBDTypeColorConversion::CIEXYZfromCIELab - Converts CIE L*a*b* to CIE XYZ D65/2°

Parameters
XYZ- X, Y, Z input refer to a D65/2° standard illuminant. The CIE XYZ values must be scaled so that the Y of D65 ("white") is 1.0 (X,Y,Z = 0.95047, 1.0000, 1.08883).
lab- L*a*b* coordinates in the CIE L*a*b* color space

◆ CIEXYZfromCIELuv()

void SBDTypeColorConversion::CIEXYZfromCIELuv ( float *  XYZ,
float *  luv 
)
static

SBDTypeColorConversion::CIEXYZfromCIELuv - Converts CIE L*u*v* to CIE XYZ D65/2°

Parameters
XYZ- X, Y, Z coordinates in the CIEXYZ color space, that refer to a D65/2° standard illuminant. The CIE XYZ values must be scaled so that the Y of D65 ("white") is 1.0 (X,Y,Z = 0.95047, 1.0000, 1.08883).
luv- L*u*v* coordinates in the CIE L*u*v* color space.

◆ CIEXYZfromRGB()

void SBDTypeColorConversion::CIEXYZfromRGB ( float *  XYZ,
float *  rgb 
)
static

SBDTypeColorConversion::CIEXYZfromRGB - Converts linear RGB to CIE XYZ with D65/2° standard illuminant.

Parameters
XYZ- X, Y and Z give the CIE chromaticies. X, Y, Z output refer to a D65/2° standard illuminant. The CIE XYZ values are scaled so that the Y of D65 ("white") is 1.0 (X,Y,Z = 0.95047, 1.0000, 1.08883) (chromaticity of the white point).
rgb- linear R, G, and B give the levels of red, green and blue as values in the interval [0.0, 1.0] (input range: 0 ÷ 1).

◆ CIEXYZfromSRGB()

void SBDTypeColorConversion::CIEXYZfromSRGB ( float *  XYZ,
float *  rgb 
)
static

SBDTypeColorConversion::CIEXYZfromSRGB - Converts device independent standard RGB (sRGB) to CIE XYZ with D65/2° standard illuminant.

Parameters
XYZ- X, Y and Z give the CIE chromaticies. X, Y, Z output refer to a D65/2° standard illuminant. The CIE XYZ values are scaled so that the Y of D65 ("white") is 1.0 (X,Y,Z = 0.95047, 1.0000, 1.08883) (chromaticity of the white point).
rgb- standard R, G, and B give the levels of red, green and blue as values in the interval [0.0, 1.0] (input range: 0 ÷ 1).

◆ CylindricalCIELabfromCIELab()

void SBDTypeColorConversion::CylindricalCIELabfromCIELab ( float *  hcl,
float *  lab 
)
static

SBDTypeColorConversion::CylindricalCIELabfromCIELab - Converts CIE L*a*b* to CIE L*a*b* in cylindrical coordinates (CIE LCh_ab)

Parameters
hcl- hue, chroma, and luminance values in the cylindrical CIEL*a*b* color space. Cylindrical CIE Lab: H: 0 ... 360; C: 0 ... 100; L: 0 ... 100
lab- L*a*b* coordinates in the CIE L*a*b*

◆ CylindricalCIELabfromSRGB()

void SBDTypeColorConversion::CylindricalCIELabfromSRGB ( float *  hcl,
float *  rgb 
)
static

SBDTypeColorConversion::CylindricalCIELabfromSRGB - Converts standard RGB (sRGB) to CIE L*a*b* in cylindrical coordinates (a.k.a. CIE LCh_ab)

Parameters
hcl- hue, chroma, and luminance values in the cylindrical CIEL*a*b* color space. Cylindrical CIE Luv: H: 0 ... 360; C: 0 ... 100; L: 0 ... 100
rgb- standard RGB (sRGB)

◆ CylindricalCIELuvfromCIELuv()

void SBDTypeColorConversion::CylindricalCIELuvfromCIELuv ( float *  hcl,
float *  luv 
)
static

SBDTypeColorConversion::CIEPolarLuvfromCIELuv - Converts CIE L*u*v* to CIE L*u*v* in cylindrical coordinates (a.k.a. CIE LCh_uv)

Parameters
hcl- hue, chroma, and luminance values in the cylindrical CIE L*u*v* color space. Cylindrical CIE Luv: H: 0 ... 360; C: 0 ... 100; L: 0 ... 100
luv- L*u*v* coordinates in the CIE L*u*v*

◆ CylindricalCIELuvfromSRGB()

void SBDTypeColorConversion::CylindricalCIELuvfromSRGB ( float *  hcl,
float *  rgb 
)
static

SBDTypeColorConversion::CylindricalCIELuvfromSRGB - Converts standard RGB (sRGB) to CIE L*u*v* in cylindrical coordinates (a.k.a. CIE LCh_uv)

Parameters
hcl- hue, chroma, and luminance values in the cylindrical CIEL*u*v* color space. Cylindrical CIE Luv: H: 0 ... 360; C: 0 ... 100; L: 0 ... 100
rgb- standard RGB (sRGB)

◆ fromHCL()

void SBDTypeColorConversion::fromHCL ( float *  color,
float *  hcl 
)
static

SBDTypeColorConversion::fromHCL - Converts HCL color (cylindrical representation of CIE L*u*v* a.k.a. CIE LCh_uv) to sRGB color as in SBColor.

Parameters
hcl- hue, chroma, and luminance values in the cylindrical CIEL*u*v* color space. Cylindrical CIE Luv: H: 0 ... 360; C: 0 ... 100; L: 0 ... 100
color- sRGB color as in SBColor

◆ HCLfromSRGB()

void SBDTypeColorConversion::HCLfromSRGB ( float *  hcl,
float *  rgb 
)
static

SBDTypeColorConversion::HCLfromSRGB - Converts standard RGB (sRGB) color to HCL color (cylindrical representation of CIE L*u*v* a.k.a. CIE LCh_uv)

Parameters
hcl- hue, chroma, and luminance values in the cylindrical CIEL*u*v* color space. Cylindrical CIE Luv: H: 0 ... 360; C: 0 ... 100; L: 0 ... 100
rgb- standard RGB (sRGB) color

◆ RGBfromCIEXYZ()

void SBDTypeColorConversion::RGBfromCIEXYZ ( float *  rgb,
float *  XYZ 
)
static

SBDTypeColorConversion::RGBfromCIEXYZ - Converts CIE XYZ with D65/2° standard illuminant to linear RGB.

Parameters
rgb- linear R, G, and B give the levels of red, green and blue as values in the interval [0.0, 1.0] (input range: 0 ÷ 1).
XYZ- X, Y and Z are the CIE chromaticies. X, Y, Z input refer to a D65/2° standard illuminant. The CIE XYZ values must be scaled so that the Y of D65 ("white") is 1.0 (X,Y,Z = 0.95047, 1.0000, 1.08883)

◆ RGBfromSRGB()

void SBDTypeColorConversion::RGBfromSRGB ( float *  rgb,
float *  srgb 
)
static

SBDTypeColorConversion::RGBfromSRGB - Converts standard gamma-corrected RGB values to linear RGB values.

Parameters
rgb- linear RGB
srgb- standard RGB (sRGB)

◆ SRGBfromCIEXYZ()

void SBDTypeColorConversion::SRGBfromCIEXYZ ( float *  rgb,
float *  XYZ 
)
static

SBDTypeColorConversion::SRGBfromCIEXYZ - Converts CIEXYZ with D65/2° standard illuminant to device independent standard RGB (sRGB)

Parameters
rgb- standard R, G, and B give the levels of red, green and blue as values in the interval [0.0, 1.0] (input range: 0 ÷ 1).
XYZ- X, Y and Z are the CIE chromaticies. X, Y, Z input refer to a D65/2° standard illuminant. The CIE XYZ values must be scaled so that the Y of D65 ("white") is 1.0 (X,Y,Z = 0.95047, 1.0000, 1.08883)

◆ SRGBfromCylindricalCIELab()

void SBDTypeColorConversion::SRGBfromCylindricalCIELab ( float *  rgb,
float *  hcl 
)
static

SBDTypeColorConversion::SRGBfromCylindricalCIELab - Converts CIE L*a*b* in cylindrical coordinates (a.k.a. CIE LCh_ab) to standard RGB (sRGB)

Parameters
rgb- standard RGB (sRGB)
hcl- hue, chroma, and luminance values in the cylindrical CIEL*a*b* color space. Cylindrical CIE Luv: H: 0 ... 360; C: 0 ... 100; L: 0 ... 100

◆ SRGBfromCylindricalCIELuv()

void SBDTypeColorConversion::SRGBfromCylindricalCIELuv ( float *  rgb,
float *  hcl 
)
static

SBDTypeColorConversion::SRGBfromCylindricalCIELuv - Converts CIE L*u*v* in cylindrical coordinates (a.k.a. CIE LCh_uv) to standard RGB (sRGB)

Parameters
rgb- standard RGB (sRGB)
hcl- hue, chroma, and luminance values in the cylindrical CIEL*u*v* color space. Cylindrical CIE Luv: H: 0 ... 360; C: 0 ... 100; L: 0 ... 100

◆ SRGBfromHCL()

void SBDTypeColorConversion::SRGBfromHCL ( float *  rgb,
float *  hcl 
)
static

SBDTypeColorConversion::SRGBfromHCL - Converts HCL color (cylindrical representation of CIE L*u*v* a.k.a. CIE LCh_uv) to standard RGB (sRGB) color.

Parameters
rgb- standard RGB (sRGB) color
hcl- hue, chroma, and luminance values in the cylindrical CIEL*u*v* color space. Cylindrical CIE Luv: H: 0 ... 360; C: 0 ... 100; L: 0 ... 100

◆ SRGBfromRGB()

void SBDTypeColorConversion::SRGBfromRGB ( float *  srgb,
float *  rgb 
)
static

SBDTypeColorConversion::SRGBfromRGB - Converts linear RGB values to standard gamma-corrected RGB values.

Parameters
srgb- standard RGB (sRGB)
rgb- linear RGB

◆ toHCL()

void SBDTypeColorConversion::toHCL ( float *  hcl,
float *  color 
)
static

SBDTypeColorConversion::toHCL - Converts sRGB color as in SBColor to HCL color (cylindrical representation of CIE L*u*v* a.k.a. CIE LCh_uv)

Parameters
hcl- hue, chroma, and luminance values in the cylindrical CIEL*u*v* color space. Cylindrical CIE Luv: H: 0 ... 360; C: 0 ... 100; L: 0 ... 100
color- sRGB color as in SBColor