A Plea for Colour Analysis Tools in DCC Applications
Introduction¶
As we are increasingly using wide gamut colourspaces (ACES RGB, Rec. 2020, ProPhoto RGB) in the VFX industry, the need for better colour analysis tools is more important than ever. Today, nothing prevents an artist to generate or pick colours outside a given volume.
We think that people working with DCC applications from Autodesk, Adobe and The Foundry need better tools to work with colour. This is especially true when we tend to work in scene referred lighting with floating point values.
We are using the ACES RGB Sony F35 still life image from this directory for our manipulation:
https://www.dropbox.com/sh/2uo12yepe8gg422/AAAtzFqm0eJgyf7TDHmTCXQFa/aces?dl=0
More images are available there: https://www.dropbox.com/sh/bwfrqgyt20gz4dp/XShJffwvXR
This still life image exhibits a lot of colours that are very hard to reproduce and is a great example for the purpose of this document.
From ACES RGB Colourspace...¶
We first read the image using OpenimageIO and display it directly onto our sRGB display device. We apply the sRGB colourspace opto-electronic conversion function and ensure that values are in domain [0, 1] so that Matplotlib can display the image.
import numpy as np
import pylab
from OpenImageIO import FLOAT, ImageInput
import colour
from colour.plotting import *
from colour.utilities import message_box
def exr_image_as_array(path):
image = ImageInput.open(path)
specification = image.spec()
return np.array(image.read_image(FLOAT)).reshape((specification.height,
specification.width,
specification.nchannels))
def image_plot(image,
OECF=colour.sRGB_COLOURSPACE.OECF):
vectorised_oecf = np.vectorize(OECF)
image = np.clip(vectorised_oecf(image), 0, 1)
pylab.imshow(image)
settings = {'no_ticks': True,
'bounding_box': [0, 1, 0, 1],
'bbox_inches': 'tight',
'pad_inches': 0}
aspect(**settings)
display(**settings)
ACES_image = exr_image_as_array('resources/images/SonyF35.StillLife_medium.exr')
image_plot(ACES_image)
... to sRGB Colourspace¶
We will convert the existing data to sRGB colourspace, in order to do so, we first compute the transformation matrix.
Note: We are using CAT02 chromatic adaptation transform (CAT).
sRGB_w = colour.sRGB_COLOURSPACE.whitepoint
sRGB_p = colour.sRGB_COLOURSPACE.primaries
sRGB_XYZ_to_RGB = colour.sRGB_COLOURSPACE.XYZ_to_RGB_matrix
sRGB_RGB_to_XYZ = colour.sRGB_COLOURSPACE.RGB_to_XYZ_matrix
ACES_w = colour.ACES_RGB_COLOURSPACE.whitepoint
ACES_p = colour.ACES_RGB_COLOURSPACE.primaries
ACES_XYZ_to_RGB = colour.ACES_RGB_COLOURSPACE.XYZ_to_RGB_matrix
ACES_RGB_to_XYZ = colour.ACES_RGB_COLOURSPACE.RGB_to_XYZ_matrix
message_box('Computing "ACES RGB" colourspace to "sRGB" colourspace matrix.')
cat = colour.chromatic_adaptation_matrix(colour.xy_to_XYZ(ACES_w),
colour.xy_to_XYZ(sRGB_w))
ACES_RGB_to_sRGB_matrix = np.dot(sRGB_XYZ_to_RGB,
np.dot(cat, ACES_RGB_to_XYZ))
print(ACES_RGB_to_sRGB_matrix)
We finally apply the transformation matrix to the image and display it.
ACES_image_shape = ACES_image.shape
sRGB_image = np.array([np.dot(ACES_RGB_to_sRGB_matrix, RGB) for RGB in ACES_image.reshape((-1, 3))])
sRGB_image = sRGB_image.reshape(ACES_image_shape)
image_plot(sRGB_image)