Colour is an open-source Python package providing a comprehensive number of algorithms and datasets for colour science.
It is freely available under the BSD-3-Clause terms.
Colour is an affiliated project of NumFOCUS, a 501(c)(3) nonprofit in the United States.
Table of Contents
- 1 Draft Release Notes
- 2 Sponsors
- 3 Features
- 3.1 Automatic Colour Conversion Graph -
colour.graph - 3.2 Chromatic Adaptation -
colour.adaptation - 3.3 Algebra -
colour.algebra - 3.4 Colour Appearance Models -
colour.appearance - 3.5 Colour Blindness -
colour.blindness - 3.6 Colour Correction -
colour characterisation - 3.7 ACES Input Transform -
colour characterisation - 3.8 Colorimetry -
colour.colorimetry - 3.9 Contrast Sensitivity Function -
colour.contrast - 3.10 Colour Difference -
colour.difference - 3.11 IO -
colour.io - 3.12 Colour Models -
colour.models - 3.13 Colour Notation Systems -
colour.notation - 3.14 Optical Phenomena -
colour.phenomena - 3.15 Light Quality -
colour.quality - 3.16 Spectral Up-Sampling & Recovery -
colour.recovery - 3.17 Correlated Colour Temperature Computation Methods -
colour.temperature - 3.18 Colour Volume -
colour.volume - 3.19 Geometry Primitives Generation -
colour.geometry - 3.20 Plotting -
colour.plotting
- 3.1 Automatic Colour Conversion Graph -
- 4 User Guide
- 4.1 Installation
- 4.2 Tutorial
- 4.3 How-To
- 4.4 Contributing
- 4.5 Changes
- 4.6 Bibliography
- 5 API Reference
- 6 See Also
- 6.1 Software
- 7 Code of Conduct
- 8 Contact & Social
- 9 Thank You!
- 10 About
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.
Gold Sponsors
Silver Sponsors
Bronze Sponsors
Donations & Special Sponsors
3 Features
Most of the objects are available from the colour namespace:
3.1 Automatic Colour Conversion Graph - colour.graph
sd = colour.SDS_COLOURCHECKERS["ColorChecker N Ohta"]["dark skin"]
colour.convert(sd, "Spectral Distribution", "sRGB", verbose={"mode": "Short"})
* *
* [ Conversion Path ] *
* *
* "sd_to_XYZ" --> "XYZ_to_sRGB" *
* *
===============================================================================
[ 0.49034776 0.30185875 0.23587685]
sd = colour.SDS_COLOURCHECKERS["ColorChecker N Ohta"]["dark skin"]
illuminant = colour.SDS_ILLUMINANTS["FL2"]
colour.convert(
sd,
"Spectral Distribution",
"sRGB",
sd_to_XYZ={"illuminant": illuminant},
)
3.2 Chromatic Adaptation - colour.adaptation
XYZ = [0.20654008, 0.12197225, 0.05136952]
D65 = colour.CCS_ILLUMINANTS["CIE 1931 2 Degree Standard Observer"]["D65"]
A = colour.CCS_ILLUMINANTS["CIE 1931 2 Degree Standard Observer"]["A"]
colour.chromatic_adaptation(XYZ, colour.xy_to_XYZ(D65), colour.xy_to_XYZ(A))
sorted(colour.CHROMATIC_ADAPTATION_METHODS)
3.3 Algebra - colour.algebra
3.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])
3.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])
3.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)
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_CIECAM16(XYZ, XYZ_w, L_A, Y_b)
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_CAM16(XYZ, XYZ_w, L_A, Y_b)
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_Hellwig2022(XYZ, XYZ_w, L_A, Y_b)
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_Kim2009(XYZ, XYZ_w, L_A)
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_sCAM(XYZ, XYZ_w, L_A, Y_b)
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_ZCAM(XYZ, XYZ_w, L_A, Y_b)
3.5 Colour Blindness - colour.blindness
cmfs = colour.colorimetry.MSDS_CMFS_LMS["Stockman & Sharpe 2 Degree Cone Fundamentals"]
colour.msds_cmfs_anomalous_trichromacy_Machado2009(cmfs, [15, 0, 0])[450]
cmfs = colour.colorimetry.MSDS_CMFS_LMS["Stockman & Sharpe 2 Degree Cone Fundamentals"]
primaries = colour.MSDS_DISPLAY_PRIMARIES["Apple Studio Display"]
d_LMS = (15, 0, 0)
colour.matrix_anomalous_trichromacy_Machado2009(cmfs, primaries, d_LMS)
[ 0.27189369 0.20047862 0.52762768]
[ 0.00644047 0.25921579 0.73434374]]
3.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)
sorted(colour.COLOUR_CORRECTION_METHODS)
3.7 ACES Input Transform - colour characterisation
sensitivities = colour.MSDS_CAMERA_SENSITIVITIES["Nikon 5100 (NPL)"]
illuminant = colour.SDS_ILLUMINANTS["D55"]
colour.matrix_idt(sensitivities, illuminant)
[ 0.0045798 , 1.14946005, -0.15403985],
[ 0.03552214, -0.16312291, 1.12760078]]), array([ 1.58214188, 1. , 1.28910346]))
3.8 Colorimetry - colour.colorimetry
3.8.1 Spectral Computations
colour.sd_to_XYZ(colour.SDS_LIGHT_SOURCES["Neodimium Incandescent"])
sorted(colour.SD_TO_XYZ_METHODS)
3.8.2 Multi-Spectral Computations
msds = [
[
[
0.01367208,
0.09127947,
0.01524376,
0.02810712,
0.19176012,
0.04299992,
],
[
0.00959792,
0.25822842,
0.41388571,
0.22275120,
0.00407416,
0.37439537,
],
[
0.01791409,
0.29707789,
0.56295109,
0.23752193,
0.00236515,
0.58190280,
],
],
[
[
0.01492332,
0.10421912,
0.02240025,
0.03735409,
0.57663846,
0.32416266,
],
[
0.04180972,
0.26402685,
0.03572137,
0.00413520,
0.41808194,
0.24696727,
],
[
0.00628672,
0.11454948,
0.02198825,
0.39906919,
0.63640803,
0.01139849,
],
],
[
[
0.04325933,
0.26825359,
0.23732357,
0.05175860,
0.01181048,
0.08233768,
],
[
0.02484169,
0.12027161,
0.00541695,
0.00654612,
0.18603799,
0.36247808,
],
[
0.03102159,
0.16815442,
0.37186235,
0.08610666,
0.00413520,
0.78492409,
],
],
[
[
0.11682307,
0.78883040,
0.74468607,
0.83375293,
0.90571451,
0.70054168,
],
[
0.06321812,
0.41898224,
0.15190357,
0.24591440,
0.55301750,
0.00657664,
],
[
0.00305180,
0.11288624,
0.11357290,
0.12924391,
0.00195315,
0.21771573,
],
],
]
colour.msds_to_XYZ(
msds,
method="Integration",
shape=colour.SpectralShape(400, 700, 60),
)
[ 17.12567298 27.77681821 25.52573685]
[ 19.10280411 34.45851476 29.76319628]]
[[ 18.03375827 8.62340812 9.71702574]
[ 15.03110867 6.54001068 24.53208465]
[ 37.68269495 26.4411103 10.66361816]]
[[ 8.09532373 12.75333339 25.79613956]
[ 7.09620297 2.79257389 11.15039854]
[ 8.933163 19.39985815 17.14915636]]
[[ 80.00969553 80.39810464 76.08184429]
[ 33.27611427 24.38947838 39.34919287]
[ 8.89425686 11.05185138 10.86767594]]]
sorted(colour.MSDS_TO_XYZ_METHODS)
3.8.3 Blackbody Spectral Radiance Computation
colour.sd_blackbody(5000)
[ 361. 6709.60527925]
[ 362. 6764.82512152]
...
[ 780. 10573.85196369]]
3.8.4 Dominant, Complementary Wavelength & Colour Purity Computation
xy = [0.54369557, 0.32107944]
xy_n = [0.31270000, 0.32900000]
colour.dominant_wavelength(xy, xy_n)
3.8.5 Lightness Computation
colour.lightness(12.19722535)
sorted(colour.LIGHTNESS_METHODS)
3.8.6 Luminance Computation
colour.luminance(41.52787585)
sorted(colour.LUMINANCE_METHODS)
3.8.7 Whiteness Computation
XYZ = [95.00000000, 100.00000000, 105.00000000]
XYZ_0 = [94.80966767, 100.00000000, 107.30513595]
colour.whiteness(XYZ, XYZ_0)
sorted(colour.WHITENESS_METHODS)
3.8.8 Yellowness Computation
XYZ = [95.00000000, 100.00000000, 105.00000000]
colour.yellowness(XYZ)
sorted(colour.YELLOWNESS_METHODS)
3.8.9 Luminous Flux, Efficiency & Efficacy Computation
sd = colour.SDS_LIGHT_SOURCES["Neodimium Incandescent"]
colour.luminous_flux(sd)
sd = colour.SDS_LIGHT_SOURCES["Neodimium Incandescent"]
colour.luminous_efficiency(sd)
sd = colour.SDS_LIGHT_SOURCES["Neodimium Incandescent"]
colour.luminous_efficacy(sd)
3.9 Contrast Sensitivity Function - colour.contrast
colour.contrast_sensitivity_function(u=4, X_0=60, E=65)
sorted(colour.CONTRAST_SENSITIVITY_METHODS)
3.10 Colour Difference - colour.difference
Lab_1 = [100.00000000, 21.57210357, 272.22819350]
Lab_2 = [100.00000000, 426.67945353, 72.39590835]
colour.delta_E(Lab_1, Lab_2)
sorted(colour.DELTA_E_METHODS)
3.11 IO - colour.io
3.11.1 Images
RGB = colour.read_image("Ishihara_Colour_Blindness_Test_Plate_3.png")
RGB.shape
3.11.2 Spectral Images - Fichet et al. (2021)
components = colour.read_spectral_image_Fichet2021("Polarised.exr")
list(components.keys())
3.11.3 Look Up Table (LUT) Data
LUT = colour.read_LUT("ACES_Proxy_10_to_ACES.cube")
print(LUT)
-------------------------------
Dimensions : 2
Domain : [[0 0 0]
[1 1 1]]
Size : (32, 3)
RGB = [0.17224810, 0.09170660, 0.06416938]
LUT.apply(RGB)
3.12 Colour Models - colour.models
3.12.1 CIE xyY Colourspace
colour.XYZ_to_xyY([0.20654008, 0.12197225, 0.05136952])
3.12.2 CIE L*a*b* Colourspace
colour.XYZ_to_Lab([0.20654008, 0.12197225, 0.05136952])
3.12.3 CIE L*u*v* Colourspace
colour.XYZ_to_Luv([0.20654008, 0.12197225, 0.05136952])
3.12.4 CIE 1960 UCS Colourspace
colour.XYZ_to_UCS([0.20654008, 0.12197225, 0.05136952])
3.12.5 CIE 1964 U*V*W* Colourspace
XYZ = [0.20654008 * 100, 0.12197225 * 100, 0.05136952 * 100]
colour.XYZ_to_UVW(XYZ)
3.12.6 CAM02-LCD, CAM02-SCD, and CAM02-UCS Colourspaces - Luo, Cui and Li (2006)
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
surround = colour.VIEWING_CONDITIONS_CIECAM02["Average"]
specification = colour.XYZ_to_CIECAM02(XYZ, XYZ_w, L_A, Y_b, surround)
JMh = [specification.J, specification.M, specification.h]
colour.JMh_CIECAM02_to_CAM02UCS(JMh)
XYZ = [0.20654008, 0.12197225, 0.05136952]
XYZ_w = [95.05 / 100, 100.00 / 100, 108.88 / 100]
L_A = 318.31
Y_b = 20.0
colour.XYZ_to_CAM02UCS(XYZ, XYZ_w=XYZ_w, L_A=L_A, Y_b=Y_b)
3.12.7 CAM16-LCD, CAM16-SCD, and CAM16-UCS Colourspaces - Li et al. (2017)
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
surround = colour.VIEWING_CONDITIONS_CAM16["Average"]
specification = colour.XYZ_to_CAM16(XYZ, XYZ_w, L_A, Y_b, surround)
JMh = [specification.J, specification.M, specification.h]
colour.JMh_CAM16_to_CAM16UCS(JMh)
XYZ = [0.20654008, 0.12197225, 0.05136952]
XYZ_w = [95.05 / 100, 100.00 / 100, 108.88 / 100]
L_A = 318.31
Y_b = 20.0
colour.XYZ_to_CAM16UCS(XYZ, XYZ_w=XYZ_w, L_A=L_A, Y_b=Y_b)
3.12.8 DIN99 Colourspace and DIN99b, DIN99c, DIN99d Refined Formulas
Lab = [41.52787529, 52.63858304, 26.92317922]
colour.Lab_to_DIN99(Lab)
3.12.9 ICaCb Colourspace
colour.XYZ_to_ICaCb([0.20654008, 0.12197225, 0.05136952])
3.12.10 IgPgTg Colourspace
colour.XYZ_to_IgPgTg([0.20654008, 0.12197225, 0.05136952])
3.12.11 IPT Colourspace
colour.XYZ_to_IPT([0.20654008, 0.12197225, 0.05136952])
3.12.12 Jzazbz Colourspace
colour.XYZ_to_Jzazbz([0.20654008, 0.12197225, 0.05136952])
3.12.13 Hunter L,a,b Colour Scale
XYZ = [0.20654008 * 100, 0.12197225 * 100, 0.05136952 * 100]
colour.XYZ_to_Hunter_Lab(XYZ)
3.12.14 Hunter Rd,a,b Colour Scale
XYZ = [0.20654008 * 100, 0.12197225 * 100, 0.05136952 * 100]
colour.XYZ_to_Hunter_Rdab(XYZ)
3.12.15 Oklab Colourspace
colour.XYZ_to_Oklab([0.20654008, 0.12197225, 0.05136952])
3.12.16 OSA UCS Colourspace
XYZ = [0.20654008 * 100, 0.12197225 * 100, 0.05136952 * 100]
colour.XYZ_to_OSA_UCS(XYZ)
3.12.17 ProLab Colourspace
colour.XYZ_to_ProLab([0.51634019, 0.15469500, 0.06289579])
3.12.18 Ragoo and Farup (2021) Optimised IPT Colourspace
colour.XYZ_to_IPT_Ragoo2021([0.20654008, 0.12197225, 0.05136952])
3.12.19 Yrg Colourspace - Kirk (2019)
colour.XYZ_to_Yrg([0.20654008, 0.12197225, 0.05136952])
3.12.20 hdr-CIELAB Colourspace
colour.XYZ_to_hdr_CIELab([0.20654008, 0.12197225, 0.05136952])
3.12.21 hdr-IPT Colourspace
colour.XYZ_to_hdr_IPT([0.20654008, 0.12197225, 0.05136952])
3.12.22 Y'CbCr Colour Encoding
colour.RGB_to_YCbCr([1.0, 1.0, 1.0])
3.12.23 YCoCg Colour Encoding
colour.RGB_to_YCoCg([0.75, 0.75, 0.0])
3.12.24 ICtCp Colour Encoding
colour.RGB_to_ICtCp([0.45620519, 0.03081071, 0.04091952])
3.12.25 HSV Colourspace
colour.RGB_to_HSV([0.45620519, 0.03081071, 0.04091952])
3.12.26 IHLS Colourspace
colour.RGB_to_IHLS([0.45620519, 0.03081071, 0.04091952])
3.12.27 Prismatic Colourspace
colour.RGB_to_Prismatic([0.25, 0.50, 0.75])
3.12.28 RGB Colourspace and Transformations
XYZ = [0.21638819, 0.12570000, 0.03847493]
illuminant_XYZ = [0.34570, 0.35850]
illuminant_RGB = [0.31270, 0.32900]
chromatic_adaptation_transform = "Bradford"
matrix_XYZ_to_RGB = [
[3.24062548, -1.53720797, -0.49862860],
[-0.96893071, 1.87575606, 0.04151752],
[0.05571012, -0.20402105, 1.05699594],
]
colour.XYZ_to_RGB(
XYZ,
illuminant_XYZ,
illuminant_RGB,
matrix_XYZ_to_RGB,
chromatic_adaptation_transform,
)
3.12.29 RGB Colourspace Derivation
p = [0.73470, 0.26530, 0.00000, 1.00000, 0.00010, -0.07700]
w = [0.32168, 0.33767]
colour.normalised_primary_matrix(p, w)
[ 3.43966450e-01 7.28166097e-01 -7.21325464e-02]
[ 0.00000000e+00 0.00000000e+00 1.00882518e+00]]
3.12.30 RGB Colourspaces
sorted(colour.RGB_COLOURSPACES)
3.12.31 OETFs
sorted(colour.OETFS)
3.12.32 EOTFs
sorted(colour.EOTFS)
3.12.33 OOTFs
sorted(colour.OOTFS)
3.12.34 Log Encoding / Decoding
sorted(colour.LOG_ENCODINGS)
3.12.35 CCTFs Encoding / Decoding
sorted(colour.CCTF_ENCODINGS)
3.12.36 Recommendation ITU-T H.273 Code points for Video Signal Type Identification
colour.COLOUR_PRIMARIES_ITUTH273.keys()
colour.models.describe_video_signal_colour_primaries(1)
* *
* Colour Primaries: 1 *
* ------------------- *
* *
* Primaries : [[ 0.64 0.33] *
* [ 0.3 0.6 ] *
* [ 0.15 0.06]] *
* Whitepoint : [ 0.3127 0.329 ] *
* Whitepoint Name : D65 *
* NPM : [[ 0.4123908 0.35758434 0.18048079] *
* [ 0.21263901 0.71516868 0.07219232] *
* [ 0.01933082 0.11919478 0.95053215]] *
* NPM -1 : [[ 3.24096994 -1.53738318 -0.49861076] *
* [-0.96924364 1.8759675 0.04155506] *
* [ 0.05563008 -0.20397696 1.05697151]] *
* FFmpeg Constants : ['AVCOL_PRI_BT709', 'BT709'] *
* *
===============================================================================
colour.TRANSFER_CHARACTERISTICS_ITUTH273.keys()
colour.models.describe_video_signal_transfer_characteristics(1)
* *
* Transfer Characteristics: 1 *
* --------------------------- *
* *
* Function :
* FFmpeg Constants : ['AVCOL_TRC_BT709', 'BT709'] *
* *
===============================================================================
colour.MATRIX_COEFFICIENTS_ITUTH273.keys()
colour.models.describe_video_signal_matrix_coefficients(1)
* *
* Matrix Coefficients: 1 *
* ---------------------- *
* *
* Matrix Coefficients : [ 0.2126 0.0722] *
* FFmpeg Constants : ['AVCOL_SPC_BT709', 'BT709'] *
* *
===============================================================================
3.13 Colour Notation Systems - colour.notation
3.13.1 Munsell Value
colour.munsell_value(12.23634268)
sorted(colour.MUNSELL_VALUE_METHODS)
3.13.2 Munsell Colour
colour.xyY_to_munsell_colour([0.38736945, 0.35751656, 0.59362000])
colour.munsell_colour_to_xyY("4.2YR 8.1/5.3")
3.14 Optical Phenomena - colour.phenomena
3.14.1 Rayleigh Scattering
colour.sd_rayleigh_scattering()
[ 3.61000000e+02 5.53748137e-01]
[ 3.62000000e+02 5.47344692e-01]
...
[ 7.80000000e+02 2.35336632e-02]]
3.14.2 Thin Film Interference
import numpy as np
# Soap film (water, n=1.33) interference
R, T = colour.thin_film_tmm(
n=[1.0, 1.33, 1.0], # [air, film, air]
t=300, # 300 nm thickness
wavelength=np.linspace(380, 780, 10),
theta=0, # Normal incidence
)
print(R[..., 0]) # s-polarisation reflectance
[[0.03176697]]
[[0.0452849 ]]
[[0.05812178]]
[[0.06940598]]
[[0.07834261]]
[[0.08446072]]
[[0.08770155]]
[[0.08842705]]
[[0.08732785]]]
3.15 Light Quality - colour.quality
3.15.1 Colour Fidelity Index
colour.colour_fidelity_index(colour.SDS_ILLUMINANTS["FL2"])
sorted(colour.COLOUR_FIDELITY_INDEX_METHODS)
3.15.2 Colour Quality Scale
colour.colour_quality_scale(colour.SDS_ILLUMINANTS["FL2"])
sorted(colour.COLOUR_QUALITY_SCALE_METHODS)
3.15.3 Colour Rendering Index
colour.colour_rendering_index(colour.SDS_ILLUMINANTS["FL2"])
sorted(colour.COLOUR_RENDERING_INDEX_METHODS)
3.15.4 Academy Spectral Similarity Index (SSI)
colour.spectral_similarity_index(
colour.SDS_ILLUMINANTS["C"], colour.SDS_ILLUMINANTS["D65"]
)
3.16 Spectral Up-Sampling & Recovery - colour.recovery
3.16.1 Reflectance Recovery
colour.XYZ_to_sd([0.20654008, 0.12197225, 0.05136952])
[ 3.65000000e+02 8.42355431e-02]
[ 3.70000000e+02 8.42689564e-02]
...
[ 7.80000000e+02 4.46952477e-01]]
sorted(colour.XYZ_TO_SD_METHODS)
colour.XYZ_to_msds(
[
[0.20654008, 0.12197225, 0.05136952],
[0.14223761, 0.23042375, 0.10498415],
[0.07820260, 0.06157595, 0.28106183],
]
).shape
sorted(colour.XYZ_TO_MSDS_METHODS)
3.16.2 Camera RGB Sensitivities Recovery
illuminant = colour.colorimetry.SDS_ILLUMINANTS["D65"]
sensitivities = colour.characterisation.MSDS_CAMERA_SENSITIVITIES["Nikon 5100 (NPL)"]
reflectances = [
sd.copy().align(colour.recovery.SPECTRAL_SHAPE_BASIS_FUNCTIONS_DYER2017)
for sd in colour.SDS_COLOURCHECKERS["BabelColor Average"].values()
]
reflectances = colour.colorimetry.sds_and_msds_to_msds(reflectances)
RGB = colour.colorimetry.msds_to_XYZ(
reflectances,
method="Integration",
cmfs=sensitivities,
illuminant=illuminant,
k=0.01,
shape=colour.recovery.SPECTRAL_SHAPE_BASIS_FUNCTIONS_DYER2017,
)
colour.recovery.RGB_to_msds_camera_sensitivities_Jiang2013(
RGB,
illuminant,
reflectances,
colour.recovery.BASIS_FUNCTIONS_DYER2017,
colour.recovery.SPECTRAL_SHAPE_BASIS_FUNCTIONS_DYER2017,
)
-7.64080878e-03],
[ 4.10000000e+02, -8.76715607e-03, 1.12726694e-02,
6.37434190e-03],
[ 4.20000000e+02, 4.58126856e-02, 7.18000418e-02,
4.00001696e-01],
...
[ 6.80000000e+02, 4.00195568e-02, 5.55512389e-03,
1.36794925e-03],
[ 6.90000000e+02, -4.32240535e-03, 2.49731193e-03,
3.80303275e-04],
[ 7.00000000e+02, -6.00395414e-03, 1.54678227e-03,
5.40394352e-04]],
['red', 'green', 'blue'],
SpragueInterpolator,
{},
Extrapolator,
{'method': 'Constant', 'left': None, 'right': None})
3.17 Correlated Colour Temperature Computation Methods - colour.temperature
colour.uv_to_CCT([0.1978, 0.3122])
sorted(colour.UV_TO_CCT_METHODS)
sorted(colour.XY_TO_CCT_METHODS)
3.18 Colour Volume - colour.volume
colour.RGB_colourspace_volume_MonteCarlo(colour.RGB_COLOURSPACE_RGB["sRGB"])
3.19 Geometry Primitives Generation - colour.geometry
colour.primitive("Grid")
([ 0.5, 0.5, 0. ], [ 1., 1.], [ 0., 0., 1.], [ 1., 1., 0., 1.]),
([-0.5, -0.5, 0. ], [ 0., 0.], [ 0., 0., 1.], [ 0., 0., 0., 1.]),
([ 0.5, -0.5, 0. ], [ 1., 0.], [ 0., 0., 1.], [ 1., 0., 0., 1.])],
dtype=[('position', '
[2, 3],
[3, 1],
[1, 0]]))
sorted(colour.PRIMITIVE_METHODS)
colour.primitive_vertices("Quad MPL")
[ 1. 0. 0.]
[ 1. 1. 0.]
[ 0. 1. 0.]]
3.20 Plotting - colour.plotting
Most of the objects are available from the colour.plotting namespace:
colour_style()
3.20.1 Visible Spectrum
plot_visible_spectrum("CIE 1931 2 Degree Standard Observer")
3.20.2 Spectral Distribution
plot_single_illuminant_sd("FL1")
3.20.3 Blackbody
from colour.plotting import *
blackbody_sds = [
colour.sd_blackbody(i, colour.SpectralShape(1, 10001, 10))
for i in range(1000, 15000, 1000)
]
plot_multi_sds(
blackbody_sds,
y_label="W / (sr m$^2$) / m",
plot_kwargs={"use_sd_colours": True, "normalise_sd_colours": True},
legend_location="upper right",
bounding_box=(0, 1250, 0, 2.5e6),
)
3.20.4 Colour Matching Functions
plot_single_cmfs(
"Stockman & Sharpe 2 Degree Cone Fundamentals",
y_label="Sensitivity",
bounding_box=(390, 870, 0, 1.1),
)
3.20.5 Luminous Efficiency
from colour.plotting import *
sd_mesopic_luminous_efficiency_function = (
colour.sd_mesopic_luminous_efficiency_function(0.2)
)
plot_multi_sds(
(
sd_mesopic_luminous_efficiency_function,
colour.colorimetry.SDS_LEFS_PHOTOPIC["CIE 1924 Photopic Standard Observer"],
colour.colorimetry.SDS_LEFS_SCOTOPIC["CIE 1951 Scotopic Standard Observer"],
),
y_label="Luminous Efficiency",
legend_location="upper right",
y_tighten=True,
margins=(0, 0, 0, 0.1),
)
3.20.6 Colour Checker
from colour.plotting import *
plot_multi_sds(
list(colour.SDS_COLOURCHECKERS["BabelColor Average"].values()),
plot_kwargs={
"use_sd_colours": True,
},
title=("BabelColor Average - " "Spectral Distributions"),
)
plot_single_colour_checker("ColorChecker 2005", text_kwargs={"visible": False})
3.20.7 Chromaticities Prediction
plot_corresponding_chromaticities_prediction(
2, "Von Kries", {"transform": "Bianco 2010"}
)
3.20.8 Chromaticities
from colour.plotting import *
RGB = np.random.random((32, 32, 3))
plot_RGB_chromaticities_in_chromaticity_diagram_CIE1931(
RGB,
"ITU-R BT.709",
colourspaces=["ACEScg", "S-Gamut", "Pointer Gamut"],
)
3.20.9 Colour Rendering Index Bars
from colour.plotting import *
plot_single_sd_colour_rendering_index_bars(colour.SDS_ILLUMINANTS["FL2"])
3.20.10 ANSI/IES TM-30-18 Colour Rendition Report
from colour.plotting import *
plot_single_sd_colour_rendition_report(colour.SDS_ILLUMINANTS["FL2"])
3.20.11 Gamut Section
plot_visible_spectrum_section(section_colours="RGB", section_opacity=0.15)
plot_RGB_colourspace_section("sRGB", section_colours="RGB", section_opacity=0.15)
3.20.12 Colour Temperature
plot_planckian_locus_in_chromaticity_diagram_CIE1960UCS(["A", "B", "C"])
3.20.13 Thin Film Interference
plot_thin_film_iridescence([1.0, 1.33, 1.0])
4 User Guide
4.1 Installation
Colour and its primary dependencies can be easily installed from the Python Package Index by issuing this command in a shell:
The detailed installation procedure for the secondary dependencies is described in the Installation Guide.
Colour is also available for Anaconda from Continuum Analytics via conda-forge:
4.2 Tutorial
The static tutorial provides an introduction to Colour. An interactive version is available via Google Colab.
4.3 How-To
The Google Colab How-To guide for Colour shows various techniques to solve specific problems and highlights some interesting use cases.
4.4 Contributing
If you would like to contribute to Colour, please refer to the following Contributing guide.
4.5 Changes
The changes are viewable on the Releases page.
4.6 Bibliography
The bibliography is available on the Bibliography page.
It is also viewable directly from the repository in BibTeX format.
5 API Reference
The main technical reference for Colour is the API Reference:
6 See Also
6.1 Software
Python
- ColorAide by Muse, I.
- ColorPy by Kness, M.
- Colorspacious by Smith, N. J., et al.
- python-colormath by Taylor, G., et al.
Go
- go-colorful by Beyer, L., et al.
.NET
- Colourful by Pazourek, T., et al.
Julia
- Colors.jl by Holy, T., et al.
Matlab & Octave
- COLORLAB by Malo, J., et al.
- Psychtoolbox by Brainard, D., et al.
- The Munsell and Kubelka-Munk Toolbox by Centore, P.
7 Code of Conduct
The Code of Conduct, adapted from the Contributor Covenant 1.4, is available on the Code of Conduct page.
8 Contact & Social
The Colour Developers can be reached via different means: