Plotting chromaticities using OIIO and Colour Science for Python

Hello @nick, sorry to bother you. I was wondering if you could help me to plot the gamut of an image. Are you using a colour science package? Thanks for your help! Chris

I am using Colour Science for Python:

Thanks @nick ! That’s great! We’ll have a look!

@nick So we were having a look at how to plot the gamut of an image with colour science. It looks like we need to install OIIO.
Here is our script:

import colour
import colour.plotting

RGB = colour.read_image(’/home/ryuu/PROJECTS/IMGDP_WEBSITE/resource/image/member/256/ryuu.png’)
RGB = RGB[…, 0:3] # Discarding alpha channel.
XYZ = colour.sRGB_to_XYZ(RGB)

colour.plotting.image_plot(XYZ, text_parameters={‘text’: ‘sRGB to XYZ’})

It gives us this error:

Traceback (most recent call last):
File “”, line 4, in
RGB = colour.read_image(’/home/ryuu/PROJECTS/IMGDP_WEBSITE/resource/image/member/256/ryuu.png’)
File “/home/ryuu/.local/lib/python3.7/site-packages/colour/io/”, line 85, in read_image
if is_openimageio_installed(raise_exception=True):
File “/home/ryuu/.local/lib/python3.7/site-packages/colour/utilities/”, line 183, in is_openimageio_installed
‘are not available: “{0}”.’).format(error))
ImportError: “OpenImageIO” related Api features are not available: “No module named ‘OpenImageIO’”.

Thanks for your help…


That is correct. Colour relies on OIIO for image reading. I have had issues myself making that dependency work, so am not the best person to help.

But the plotting functions of Colour simply plot from a NumPy array of colour triples, so any way of reading an image into that will work. For 8-bit integer image formats you can simply use PIL.

EDIT: RGB_chromaticity_coordinates_chromaticity_diagram_plot_CIE1931() expects linear input, so remember to linearise the values in your NumPy array if necessary before plotting.

Thanks @nick! We will have a try. Have a nice week-end!

Hi @nick,
I’m working as a technical director with @ChrisBrejon. I’ve installed PIL on my server. OCIIO seams to have a lot of dependencies, to much complicated for me I think. I will try to do same tests as soon as possible. Thanks for your help++


@ryuu: It seems like you guys are using a Unix flavour (Linux or macOS) given the paths in the traceback. OIIO should be relatively easy to compile on both and I highly recommend that you give it stab as it will allow you to use some of his tools such as oiiotool which are brilliant. With the Python bindings you will be able to process images with Colour and Numpy which might also be very useful. Let me know and maybe I can help you for the compilation.



Thanks @Thomas_Mansencal! That;s awesome! We’ll let you know how this goes! Much appreciated mate! :wink:

Thanks @sdyer for creating this thread! So sorry, I did not mean to hack the previous page! Chris

I’m not a linux expert, I spent a whole afternoon solving dependency problems with OIIO, but it’s finally working. I use RGB_chromaticity_coordinates_chromaticity_diagram_plot_CIE1931 to plot RGB arrays in a given color space, but it would be great if I could see other colorspaces in the same diagram as well. Can someone help me how to do that?

Hi @Attila_Bakos,

The following should work, not this uses the latest develop branch but 0.3.11 should have same feature, note that the colour.plotting.RGB_chromaticity_coordinates_chromaticity_diagram_plot_CIE1931 definition has been renamed:

import numpy as np
from colour.plotting import *

    np.random.random([64, 64, 3]),



Thanks a lot, it’s working :slight_smile: