#!/usr/bin/env python # coding: utf-8 # # Colour Playground # A repository leveraging [Binder](https://mybinder.org/) to play with [Colour](https://github.com/colour-science/colour). # In[1]: from IPython.core.display import Image Image(filename="resources/images/Colour_Logo_Medium_001.png") # # Introduction # In[2]: from widgets import set_style set_style() # ## RGB Colourspace Models Transformation Matrix # Computes the colour transformation matrix between the given _RGB Colourspace Models_ using the given _Chromatic Adaptation Transform_. # In[3]: from widgets import RGB_colourspace_models_transformation_matrix_widget RGB_colourspace_models_transformation_matrix_widget() # ## RGB Colourspace Models Chromatically Adapted Primaries # Computes the _Chromatically Adapted Primaries_ of the given _RGB Colourspace Model_ to the given _Illuminant_ using the given _Chromatic Adaptation Transform_. # In[4]: from widgets import RGB_colourspace_models_chromatically_adapted_primaries_widget RGB_colourspace_models_chromatically_adapted_primaries_widget() # ## Chromatically Adapted XYZ to RGB Matrix # Computes the _Chromatically Adapted XYZ to RGB Matrix_ of the given _RGB Colourspace Model_ to the given _Illuminant_ using the given _Chromatic Adaptation Transform_. # > Notes: `colour.XYZ_to_RGB_matrix` and`colour.RGB_to_XYZ_matrix` definitions are planned to be added to [Colour](https://github.com/colour-science/colour) to perform that computation directly. # In[5]: import colour input_colourspace = colour.RGB_COLOURSPACES['sRGB'] D50 = colour.ILLUMINANTS['CIE 1931 2 Degree Standard Observer']['D50'] M_CAT = colour.adaptation.chromatic_adaptation_matrix_VonKries( colour.xyY_to_XYZ(colour.xy_to_xyY(input_colourspace.whitepoint)), colour.xyY_to_XYZ(colour.xy_to_xyY(D50)), transform='CAT02') colour.utilities.dot_matrix(input_colourspace.XYZ_to_RGB_matrix, M_CAT)