colour.read_image

colour.read_image(path, bit_depth='float32', method='OpenImageIO', **kwargs)[source]

Reads the image at given path using given method.

Parameters:
  • path (unicode) – Image path.
  • bit_depth (unicode, optional) – {‘float32’, ‘uint8’, ‘uint16’, ‘float16’}, Returned image bit depth, for the Imageio method, the image data is converted with colour.io.convert_bit_depth() definition after reading the image, for the OpenImageIO method, the bit depth conversion behaviour is driven directly by the library, this definition only converts to the relevant data type after reading.
  • method (unicode, optional) – {‘OpenImageIO’, ‘Imageio’}, Read method, i.e. the image library used for reading images.
Other Parameters:
 

attributes (bool, optional) – {colour.io.read_image_OpenImageIO()}, Whether to return the image attributes.

Returns:

Image as a ndarray.

Return type:

ndarray

Notes

  • If the given method is OpenImageIO but the library is not available writing will be performed by Imageio.
  • If the given method is Imageio, kwargs is passed directly to the wrapped definition.
  • For convenience, single channel images are squeezed to 2d arrays.

Examples

>>> import os
>>> import colour
>>> path = os.path.join(colour.__path__[0], 'io', 'tests', 'resources',
...                     'CMS_Test_Pattern.exr')
>>> image = read_image(path)
>>> image.shape  # doctest: +SKIP
(1267, 1274, 3)
>>> image.dtype
dtype('float32')