grapa.shared.colors_conversion

Provides conversions between different color spaces. RGB, and CIE Lab and CIE LCh. Meant as an extension to python colorsys Includes reparametrized versions of CIE Lab and LCh, with values 0-1.

@author: Romain Carron Copyright (c) 2026, Empa, Laboratory for Thin Films and Photovoltaics, Romain Carron

Functions

cielab_to_cielch(L, a, b)

Convert CIELAB to CIELCh°.

cielab_to_rgb(L, a, b)

Convert CIELAB to sRGB (D65).

cielabnorm_to_cielchnorm(L_norm, a_norm, b_norm)

Convert CIELAB to CIELCh°, all values between 0-1 :param L: lightness (0-1) :param a: Lab chromaticity component b, normalized :param b: Lab chromaticity component b, normalized :return: (L, C, h) where C = chroma /150 and h = hue angle 0-1

cielabnorm_to_rgb(L_norm, a_norm, b_norm)

Convert CIELAB to sRGB (D65).

cielch_to_cielab(L, C, h)

Convert CIELCh° to CIELAB.

cielch_to_rgb(L, C, h)

Converts CIE LCh into rgb (L, C, h) where C = chroma, h = hue angle in degrees (0-360) :return: (r,g,b) as floats 0-1

cielchnorm_to_cielabnorm(L_norm, C_norm, h_norm)

Convert CIELCh° to CIELAB.

cielchnorm_to_rgb(L_norm, C_norm, h_norm)

(r,g,b) as floats 0-1

rgb_to_cielab(r, g, b)

Convert an sRGB color to CIELAB (D65).

rgb_to_cielabnorm(r, g, b)

Convert an sRGB color to CIELAB (D65).

rgb_to_cielch(r, g, b)

(r,g,b) as floats 0-1 :return: (L, C, h) where C = chroma, h = hue angle in degrees (0-360)

rgb_to_cielchnorm(r, g, b)

(r,g,b) as floats 0-1

Classes

CIELChNormalization()

Provides conversion functions for CIE LCh colorspace, with parameter values normalized 0-1.

CIELabNormalization()

Provides conversion functions for CIE Lab colorspace.