phenotypic.sdk_.colourspace#

Functions

decode_srgb

Convert sRGB gamma-encoded values to linear light.

encode_srgb

Convert linear-light values to sRGB gamma-encoded values.

phenotypic.sdk_.colourspace.decode_srgb(arr: numpy.ndarray) numpy.ndarray[source]

Convert sRGB gamma-encoded values to linear light.

Applies the inverse sRGB colour component transfer function (the standard piecewise gamma curve) elementwise. Sensor and photon noise is generated in linear light, so denoisers and variance-stabilizing transforms (e.g. the Generalized Anscombe Transform) operate most correctly on linearized data rather than the display-encoded values.

Parameters:

arr (numpy.ndarray) – Array of sRGB gamma-encoded values normalized to [0, 1]. Any shape; the transfer function is applied elementwise, so a 2D channel or an (H, W, 3) image are both valid.

Returns:

Linear-light values in [0, 1] as float64, same shape as arr.

Return type:

np.ndarray

phenotypic.sdk_.colourspace.encode_srgb(arr: numpy.ndarray) numpy.ndarray[source]

Convert linear-light values to sRGB gamma-encoded values.

Applies the forward sRGB colour component transfer function elementwise. This is the inverse of decode_srgb() and restores the display-encoded representation after processing in linear light.

Parameters:

arr (numpy.ndarray) – Array of linear-light values normalized to [0, 1]. Any shape; the transfer function is applied elementwise.

Returns:

sRGB gamma-encoded values in [0, 1] as float64, same shape as arr.

Return type:

np.ndarray