colour.gamma_function

colour.gamma_function(a: FloatingOrArrayLike, exponent: FloatingOrArrayLike = 1, negative_number_handling: Union[Literal['Clamp', 'Indeterminate', 'Mirror', 'Preserve'], str] = 'Indeterminate') FloatingOrNDArray[source]

Define a typical gamma encoding / decoding function.

Parameters
  • a (FloatingOrArrayLike) – Array to encode / decode.

  • exponent (FloatingOrArrayLike) – Encoding / decoding exponent.

  • negative_number_handling (Union[Literal['Clamp', 'Indeterminate', 'Mirror', 'Preserve'], str]) –

    Defines the behaviour for a negative numbers and / or the definition return value:

    • Indeterminate: The behaviour will be indeterminate and definition return value might contain nans.

    • Mirror: The definition return value will be mirrored around abscissa and ordinate axis, i.e. Blackmagic Design: Davinci Resolve behaviour.

    • Preserve: The definition will preserve any negative number in a, i.e. The Foundry Nuke behaviour.

    • Clamp: The definition will clamp any negative number in a to 0.

Returns

Encoded / decoded array.

Return type

numpy.floating or numpy.ndarray

Examples

>>> gamma_function(0.18, 2.2)  
0.0229932...
>>> gamma_function(-0.18, 2.0)  
0.0323999...
>>> gamma_function(-0.18, 2.2)
nan
>>> gamma_function(-0.18, 2.2, 'Mirror')  
-0.0229932...
>>> gamma_function(-0.18, 2.2, 'Preserve')  
-0.1...
>>> gamma_function(-0.18, 2.2, 'Clamp')  
0.0