Color Processing
color_processing
Color processing transforms not directly related to film.
Functions:
-
CCT_to_XYZ–Converts from a color temperature in kelvin to a XYZ triplet.
-
CCT_to_xy–Convert from a color temperature in kelvin to the closest xy pair.
-
apd_to_xyz–Adaptation of the ADX to ACES transform
-
bw_inversion–Invert BW APD density values similar to
apd_to_xyz. -
compress_gamut–A simple gamut compression that limits the maximal relative distance from the
-
output_color_transform–Transform from XYZ to the target gamut and adjust the saturation.
-
output_transform–Transform display referred linear CIE XYZ data to a display color space with some
-
shadow_compensation–Raises or lowers shadows. Has been computed to act as an OOTF for the ITU-R
-
simple_shadow_compensation–A simpler shadow compensation function. For it is designed so that for an intensity
Attributes:
-
COLORCHECKER_2005–The XYZ value for the colorchecker 2005 data.
COLORCHECKER_2005
module-attribute
COLORCHECKER_2005 = np.asarray(COLORCHECKER_2005, DEFAULT_DTYPE)
The XYZ value for the colorchecker 2005 data.
CCT_to_XYZ
Converts from a color temperature in kelvin to a XYZ triplet.
CCT_to_xy
CCT_to_xy(CCT)
Convert from a color temperature in kelvin to the closest xy pair.
apd_to_xyz
apd_to_xyz(
apd: ndarray,
inversion_gamma: float = 2.0,
projector_kelvin: float | int = 6500,
exp_to_xyz: ndarray | None = None,
) -> ndarray
Adaptation of the ADX to ACES transform to take APD input and map them ot ACES instead of the original ADX10 to ACES AP0.
Parameters:
-
(apdndarray) –The input APD data.
-
(inversion_gammafloat, default:2.0) –The gamma to apply.
-
(projector_kelvinfloat | int, default:6500) –White point in kelvin.
-
(exp_to_xyzndarray | None, default:None) –Matrix used for converting from layer exposure to CIE XYZ.
Returns:
-
ndarray–The transformed image in CIE XYZ.
bw_inversion
bw_inversion(
apd: ndarray, inversion_gamma: float = 2.0, projector_kelvin: float | int = 6500
) -> ndarray
compress_gamut
compress_gamut(image: ndarray, gamut_compression: float | None = None) -> ndarray
A simple gamut compression that limits the maximal relative distance from the achromatic. Inspired by ACES Reference Gamut Compression. Has been simplified to be color space agnostic and use a simple clipping function instead of a roll-off. It is not perceptually neutral and should be used conservatively. It is intended to fix numeric issues in highly saturated colors, and not to be part of look creation.
Parameters:
-
(imagendarray) –The image to transform.
-
(gamut_compressionfloat | None, default:None) –How strong to compress. strength=1 is uncompressed and strength=0 is fully desaturated.
Returns:
-
ndarray–The compressed image.
output_color_transform
output_color_transform(
image: ndarray,
output_gamut: COLOR_SPACE_KEYS = "Rec. 709",
sat_adjust: float = 1.0,
lut_size: int = 33,
rolloff: bool = False,
gamma_func: GAMMA_KEYS = "Gamma 2.4",
gamut_compression: None | float = None,
) -> ndarray
Transform from XYZ to the target gamut and adjust the saturation. Saturation adjustment is performed in OkLch for visual uniformity. Gamut compression is performed to avoid visual artifacts. To preserve high performance the transforms are applied as a 2D xy LUT.
Parameters:
-
(imagendarray) –The XYZ image to transform.
-
(output_gamutCOLOR_SPACE_KEYS, default:'Rec. 709') –The name of the output color space.
-
(sat_adjustfloat, default:1.0) –By what factor to multiply the saturation.
-
(lut_sizeint, default:33) –The size of the LUT. Default is 33x33.
Returns:
-
ndarray–The transformed image in the output gamut.
output_transform
output_transform(
image: ndarray,
output_gamut: COLOR_SPACE_KEYS,
sat_adjust: float = 1.0,
lut_size: int = 33,
shadow_comp: float = 0.0,
gamma_func: GAMMA_KEYS = "Gamma 2.4",
rolloff: bool = False,
gamut_compression: None | float = None,
) -> ndarray
Transform display referred linear CIE XYZ data to a display color space with some post-processing adjustments.
Parameters:
-
(imagendarray) –The image (or LUT) in linear CIE XYZ in the range [0, 1] to transform.
-
(output_gamutCOLOR_SPACE_KEYS) –The output display gamut.
-
(sat_adjustfloat, default:1.0) –How much to adjust the saturation. Unchanged for 1.0, BW for 0.0, and increased saturation for >1.0.
-
(lut_sizeint, default:33) –The size of the 2D xy LUT used to apply output color transform.
-
(shadow_compfloat, default:0.0) –How much to compensate the shadows in the range [-1, 1].
-
(gamma_funcGAMMA_KEYS, default:'Gamma 2.4') –The gamma function to encode the output in.
Returns:
-
ndarray–The transformed image in the target gamma and gamut.
shadow_compensation
Raises or lowers shadows. Has been computed to act as an OOTF for the ITU-R BT.1886 curve. Setting gamma to Gamma 2.4 and Black offset to 1.0 will yield essentially Rec. 709. Setting gamma to Rec. 709 and Black offset to -1.0 in turn gives essentially Gamma 2.4. Has been computed from BT.1886 as to not be piecewise, and to not overfit to Rec. 709.
Parameters:
-
(imagendarray) –The image to transform. Assumed to be in linear gamma.
-
(intensityfloat, default:0.0) –How much to lift or lower particularly dark areas. For 0 no effect, 1 and -1 act as forward and inverse OOTFs respectively.
Returns:
-
ndarray–The shadow compensated image.
simple_shadow_compensation
A simpler shadow compensation function. For it is designed so that for an intensity of 1.0 we lift the shadow such that the black level is that of a print with density d_min. The functions is supposed to be simple, but still resemble the natural shadow roll-off of a photographic print. \(\sqrt{x^2 + black^2}\), where \(black = 10^{-d_{max}}\).
For negative intensities we apply the same function, but then shift and scale it so that 0% brightness stays at 0% and 100% stays at 100%.
Parameters:
-
(imagendarray) –The image (or LUT) to transform.
-
(intensityfloat, default:0.0) –The intensity in the range [-1, 1], where 0 has no effect.
-
(d_maxfloat, default:2.0) –The maximal density that is achieved when intensity = 1.
Returns:
-
ndarray–The image with adjusted shadow compensation.