colour.utilities.from_range_int¶
- colour.utilities.from_range_int(a, bit_depth=8, dtype=None)[source]¶
Scales given array \(a\) from int range. The behaviour is as follows:
If Colour domain-range scale is ‘Reference’, the definition is entirely by-passed.
If Colour domain-range scale is ‘1’, array \(a\) is converted to
np.ndarray
and divided by \(2^{bit\_depth} - 1\).If Colour domain-range scale is ‘100’ (currently unsupported private value only used for unit tests), array \(a\) is converted to
np.ndarray
and divided by \(2^{bit\_depth} - 1\).
- Parameters
a (array_like) – \(a\) to scale from int range.
bit_depth (numeric or array_like, optional) – Bit depth, usually int but can be an array_like if some axis need different scaling to be brought from int range.
dtype (object, optional) – Data type used for the conversion to
np.ndarray
.
- Returns
\(a\) scaled from int range.
- Return type
ndarray
Warning
The scale conversion of \(a\) variable happens in-place, i.e. \(a\) will be mutated!
Notes
To avoid precision issues and rounding, the scaling is performed on floating-point numbers.
Examples
With Colour domain-range scale set to ‘Reference’:
>>> with domain_range_scale('Reference'): ... from_range_int(1) 1
With Colour domain-range scale set to ‘1’:
>>> with domain_range_scale('1'): ... from_range_int(1) array(0.0039215...)
With Colour domain-range scale set to ‘100’ (unsupported):
>>> with domain_range_scale('100'): ... from_range_int(1) array(0.3921568...)