Colour is an open-source Python package providing a comprehensive number of algorithms and datasets for colour science.
It is freely available under the New BSD License terms.
Colour is an affiliated project of NumFOCUS, a 501(c)(3) nonprofit in the United States.
1 Draft Release Notes
The draft release notes of the develop branch are available at this url.
2 Sponsors
We are grateful
💖 for the support of our sponsors. If you'd like to join them, please consider becoming a sponsor on OpenCollective.
Bronze Sponsors
Donations & Special Sponsors
3 Features
Colour features a rich dataset and collection of objects, please see the features page for more information.
4 Installation
Colour can be easily installed from the Python Package Index by issuing this command in a shell:
$ pip install colour-science
Colour is also available for Anaconda from Continuum Analytics via conda-forge:
$ conda install -c conda-forge colour-science
The detailed installation procedure is described in the Installation Guide.
5 Documentation
5.1 Tutorial
The static tutorial provides an introduction to Colour. An interactive version is available via Google Colab.
5.2 How-To Guide
The How-To guide for Colour shows various techniques to solve specific problems and highlights some interesting use cases.
5.3 API Reference
The main technical reference for Colour and its API is the Colour Manual.
5.4 Examples
Most of the objects are available from the colour namespace:
>>> import colour
5.4.1 Automatic Colour Conversion Graph - colour.graph
Starting with version 0.3.14, Colour implements an automatic colour conversion graph enabling easier colour conversions.
>>> sd = colour.COLOURCHECKER_SDS['ColorChecker N Ohta']['dark skin']
>>> convert(sd, 'Spectral Distribution', 'sRGB', verbose={'mode': 'Short'})
===============================================================================
* *
* [ Conversion Path ] *
* *
* "sd_to_XYZ" --> "XYZ_to_sRGB" *
* *
===============================================================================
array([ 0.45675795, 0.30986982, 0.24861924])
>>> illuminant = colour.ILLUMINANT_SDS['FL2']
>>> convert(sd, 'Spectral Distribution', 'sRGB', sd_to_XYZ={'illuminant': illuminant})
array([ 0.47924575, 0.31676968, 0.17362725])
5.4.2 Chromatic Adaptation - colour.adaptation
>>> XYZ = [0.20654008, 0.12197225, 0.05136952]
>>> D65 = colour.ILLUMINANTS['CIE 1931 2 Degree Standard Observer']['D65']
>>> A = colour.ILLUMINANTS['CIE 1931 2 Degree Standard Observer']['A']
>>> colour.chromatic_adaptation(
... XYZ, colour.xy_to_XYZ(D65), colour.xy_to_XYZ(A))
array([ 0.2533053 , 0.13765138, 0.01543307])
>>> sorted(colour.CHROMATIC_ADAPTATION_METHODS.keys())
['CIE 1994', 'CMCCAT2000', 'Fairchild 1990', 'Von Kries']
5.4.3 Algebra - colour.algebra
5.4.3.1 Kernel Interpolation
>>> y = [5.9200, 9.3700, 10.8135, 4.5100, 69.5900, 27.8007, 86.0500]
>>> x = range(len(y))
>>> colour.KernelInterpolator(x, y)([0.25, 0.75, 5.50])
array([ 6.18062083, 8.08238488, 57.85783403])
5.4.3.2 Sprague (1880) Interpolation
>>> y = [5.9200, 9.3700, 10.8135, 4.5100, 69.5900, 27.8007, 86.0500]
>>> x = range(len(y))
>>> colour.SpragueInterpolator(x, y)([0.25, 0.75, 5.50])
array([ 6.72951612, 7.81406251, 43.77379185])
5.4.4 Colour Appearance Models - colour.appearance
>>> XYZ = [0.20654008 * 100, 0.12197225 * 100, 0.05136952 * 100]
>>> XYZ_w = [95.05, 100.00, 108.88]
>>> L_A = 318.31
>>> Y_b = 20.0
>>> colour.XYZ_to_CIECAM02(XYZ, XYZ_w, L_A, Y_b)
CIECAM02_Specification(J=34.434525727858997, C=67.365010921125915, h=22.279164147957076, s=62.814855853327131, Q=177.47124941102123, M=70.024939419291385, H=2.689608534423904, HC=None)
5.4.5 Colour Blindness - colour.blindness
>>> import colour
>>> cmfs = colour.LMS_CMFS['Stockman & Sharpe 2 Degree Cone Fundamentals']
>>> colour.anomalous_trichromacy_cmfs_Machado2009(cmfs, np.array([15, 0, 0]))[450]
array([ 0.08912884, 0.0870524 , 0.955393 ])
>>> primaries = colour.DISPLAY_RGB_PRIMARIES['Apple Studio Display']
>>> d_LMS = (15, 0, 0)
>>> colour.anomalous_trichromacy_matrix_Machado2009(cmfs, primaries, d_LMS)
array([[-0.27774652, 2.65150084, -1.37375432],
[ 0.27189369, 0.20047862, 0.52762768],
[ 0.00644047, 0.25921579, 0.73434374]])
5.4.6 Colour Correction - colour characterisation
>>> import numpy as np
>>> RGB = [0.17224810, 0.09170660, 0.06416938]
>>> M_T = np.random.random((24, 3))
>>> M_R = M_T + (np.random.random((24, 3)) - 0.5) * 0.5
>>> colour.colour_correction(RGB, M_T, M_R)
array([ 0.15205429, 0.08974029, 0.04141435])
>>> sorted(colour.COLOUR_CORRECTION_METHODS.keys())
['Cheung 2004', 'Finlayson 2015', 'Vandermonde']
5.4.7 ACES Input Transform - colour characterisation
>>> sensitivities = colour.CAMERA_RGB_SPECTRAL_SENSITIVITIES['Nikon 5100 (NPL)']
>>> illuminant = colour.ILLUMINANT_SDS['D55']
>>> colour.idt_matrix(sensitivities, illuminant)
array([[ 0.46579991, 0.13409239, 0.01935141],
[ 0.