colour.io.convert_bit_depth¶
-
colour.io.
convert_bit_depth
(a, bit_depth='float32')[source]¶ Converts given array to given bit depth, the current bit depth of the array is used to determine the appropriate conversion path.
- Parameters
a (array_like) – Array to convert to given bit depth.
bit_depth (unicode) – Bit depth.
- Returns
Converted array.
- Return type
ndarray
Examples
>>> a = np.array([0.0, 0.5, 1.0]) >>> convert_bit_depth(a, 'uint8') array([ 0, 128, 255], dtype=uint8) >>> convert_bit_depth(a, 'uint16') array([ 0, 32768, 65535], dtype=uint16) >>> convert_bit_depth(a, 'float16') array([ 0. , 0.5, 1. ], dtype=float16) >>> a = np.array([0, 128, 255], dtype=np.uint8) >>> convert_bit_depth(a, 'uint16') array([ 0, 32896, 65535], dtype=uint16) >>> convert_bit_depth(a, 'float32') array([ 0. , 0.501960..., 1. ], dtype=float32)