From bae36558580e1f1c45fc343f5a27d1a4257befcb Mon Sep 17 00:00:00 2001 From: Thomas Mansencal Date: Sun, 19 Nov 2023 12:20:07 +1300 Subject: [PATCH] Use `blacken-docs`. --- .pre-commit-config.yaml | 6 +- README.rst | 1235 +++++++++++++++++++++++++-------------- docs/basics.rst | 22 +- docs/index.rst | 1234 ++++++++++++++++++++++++-------------- docs/tutorial.rst | 28 +- 5 files changed, 1639 insertions(+), 886 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 9194b344a..12acb4036 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -33,8 +33,8 @@ repos: hooks: - id: black language_version: python3.9 -- repo: https://github.com/keewis/blackdoc - rev: v0.3.9 +- repo: https://github.com/adamchainz/blacken-docs + rev: 1.16.0 hooks: - - id: blackdoc + - id: blacken-docs language_version: python3.9 diff --git a/README.rst b/README.rst index 0c94e5f47..645f07dd5 100644 --- a/README.rst +++ b/README.rst @@ -263,7 +263,7 @@ Most of the objects are available from the ``colour`` namespace: .. code-block:: python - >>> import colour + import colour Automatic Colour Conversion Graph - ``colour.graph`` ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -275,12 +275,10 @@ conversion graph enabling easier colour conversions. .. code-block:: python - >>> sd = colour.SDS_COLOURCHECKERS["ColorChecker N Ohta"]["dark skin"] - >>> colour.convert( - ... sd, "Spectral Distribution", "sRGB", verbose={"mode": "Short"} - ... ) + sd = colour.SDS_COLOURCHECKERS["ColorChecker N Ohta"]["dark skin"] + colour.convert(sd, "Spectral Distribution", "sRGB", verbose={"mode": "Short"}) -:: +.. code-block:: text =============================================================================== * * @@ -293,13 +291,16 @@ conversion graph enabling easier colour conversions. .. code-block:: python - >>> illuminant = colour.SDS_ILLUMINANTS["FL2"] - >>> colour.convert( - ... sd, - ... "Spectral Distribution", - ... "sRGB", - ... sd_to_XYZ={"illuminant": illuminant}, - ... ) + illuminant = colour.SDS_ILLUMINANTS["FL2"] + colour.convert( + sd, + "Spectral Distribution", + "sRGB", + sd_to_XYZ={"illuminant": illuminant}, + ) + +.. code-block:: text + array([ 0.47924575, 0.31676968, 0.17362725]) Chromatic Adaptation - ``colour.adaptation`` @@ -307,16 +308,21 @@ Chromatic Adaptation - ``colour.adaptation`` .. code-block:: python - >>> 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) - ... ) + 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)) + +.. code-block:: text + array([ 0.2533053 , 0.13765138, 0.01543307]) - >>> sorted(colour.CHROMATIC_ADAPTATION_METHODS) + +.. code-block:: python + + sorted(colour.CHROMATIC_ADAPTATION_METHODS) + +.. code-block:: text + ['CIE 1994', 'CMCCAT2000', 'Fairchild 1990', 'Von Kries', 'Zhai 2018'] Algebra - ``colour.algebra`` @@ -327,9 +333,12 @@ Kernel Interpolation .. code-block:: python - >>> 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]) + 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]) + +.. code-block:: text + array([ 6.18062083, 8.08238488, 57.85783403]) Sprague (1880) Interpolation @@ -337,9 +346,12 @@ Sprague (1880) Interpolation .. code-block:: python - >>> 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]) + 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]) + +.. code-block:: text + array([ 6.72951612, 7.81406251, 43.77379185]) Colour Appearance Models - ``colour.appearance`` @@ -347,21 +359,54 @@ Colour Appearance Models - ``colour.appearance`` .. code-block:: python - >>> 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_CIECAM02(XYZ, XYZ_w, L_A, Y_b) + +.. code-block:: text + CAM_Specification_CIECAM02(J=34.434525727858997, C=67.365010921125943, h=22.279164147957065, s=62.81485585332716, Q=177.47124941102123, M=70.024939419291414, H=2.6896085344238898, HC=None) - >>> colour.XYZ_to_CIECAM16(XYZ, XYZ_w, L_A, Y_b) + +.. code-block:: python + + colour.XYZ_to_CIECAM16(XYZ, XYZ_w, L_A, Y_b) + +.. code-block:: text + CAM_Specification_CIECAM16(J=34.434525727858997, C=67.365010921125943, h=22.279164147957065, s=62.81485585332716, Q=177.47124941102123, M=70.024939419291414, H=2.6896085344238898, HC=None) - >>> colour.XYZ_to_CAM16(XYZ, XYZ_w, L_A, Y_b) + +.. code-block:: python + + colour.XYZ_to_CAM16(XYZ, XYZ_w, L_A, Y_b) + +.. code-block:: text + CAM_Specification_CAM16(J=33.880368498111686, C=69.444353357408033, h=19.510887327451748, s=64.03612114840314, Q=176.03752758512178, M=72.18638534116765, H=399.52975599115319, HC=None) - >>> colour.XYZ_to_Hellwig2022(XYZ, XYZ_w, L_A) + +.. code-block:: python + + colour.XYZ_to_Hellwig2022(XYZ, XYZ_w, L_A) + +.. code-block:: text + CAM_Specification_Hellwig2022(J=33.880368498111686, C=40.347043294550311, h=19.510887327451748, s=117.38555017188679, Q=45.34489577734751, M=53.228355383108031, H=399.52975599115319, HC=None) - >>> colour.XYZ_to_Kim2009(XYZ, XYZ_w, L_A) + +.. code-block:: python + + colour.XYZ_to_Kim2009(XYZ, XYZ_w, L_A) + +.. code-block:: text + CAM_Specification_Kim2009(J=19.879918542450902, C=55.839055250876946, h=22.013388165090046, s=112.97979354939129, Q=36.309026130161449, M=46.346415858227864, H=2.3543198369639931, HC=None) - >>> colour.XYZ_to_ZCAM(XYZ, XYZ_w, L_A, Y_b) + +.. code-block:: python + + colour.XYZ_to_ZCAM(XYZ, XYZ_w, L_A, Y_b) + +.. code-block:: text + CAM_Specification_ZCAM(J=38.347186278956357, C=21.12138989208518, h=33.711578931095197, s=81.444585609489536, Q=76.986725284523772, M=42.403805833900506, H=0.45779200212219573, HC=None, V=43.623590687423544, K=43.20894953152817, W=34.829588380192149) Colour Blindness - ``colour.blindness`` @@ -369,15 +414,23 @@ Colour Blindness - ``colour.blindness`` .. code-block:: python - >>> import numpy as np - >>> cmfs = colour.LMS_CMFS["Stockman & Sharpe 2 Degree Cone Fundamentals"] - >>> colour.msds_cmfs_anomalous_trichromacy_Machado2009( - ... cmfs, np.array([15, 0, 0]) - ... )[450] + import numpy as np + + cmfs = colour.LMS_CMFS["Stockman & Sharpe 2 Degree Cone Fundamentals"] + colour.msds_cmfs_anomalous_trichromacy_Machado2009(cmfs, np.array([15, 0, 0]))[450] + +.. code-block:: text + array([ 0.08912884, 0.0870524 , 0.955393 ]) - >>> primaries = colour.MSDS_DISPLAY_PRIMARIES["Apple Studio Display"] - >>> d_LMS = (15, 0, 0) - >>> colour.matrix_anomalous_trichromacy_Machado2009(cmfs, primaries, d_LMS) + +.. code-block:: python + + primaries = colour.MSDS_DISPLAY_PRIMARIES["Apple Studio Display"] + d_LMS = (15, 0, 0) + colour.matrix_anomalous_trichromacy_Machado2009(cmfs, primaries, d_LMS) + +.. code-block:: text + array([[-0.27774652, 2.65150084, -1.37375432], [ 0.27189369, 0.20047862, 0.52762768], [ 0.00644047, 0.25921579, 0.73434374]]) @@ -387,13 +440,23 @@ Colour Correction - ``colour characterisation`` .. code-block:: python - >>> 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) + 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) + +.. code-block:: text + array([ 0.1806237 , 0.07234791, 0.07848845]) - >>> sorted(colour.COLOUR_CORRECTION_METHODS) + +.. code-block:: python + + sorted(colour.COLOUR_CORRECTION_METHODS) + +.. code-block:: text + ['Cheung 2004', 'Finlayson 2015', 'Vandermonde'] ACES Input Transform - ``colour characterisation`` @@ -401,9 +464,12 @@ ACES Input Transform - ``colour characterisation`` .. code-block:: python - >>> sensitivities = colour.MSDS_CAMERA_SENSITIVITIES["Nikon 5100 (NPL)"] - >>> illuminant = colour.SDS_ILLUMINANTS["D55"] - >>> colour.matrix_idt(sensitivities, illuminant) + sensitivities = colour.MSDS_CAMERA_SENSITIVITIES["Nikon 5100 (NPL)"] + illuminant = colour.SDS_ILLUMINANTS["D55"] + colour.matrix_idt(sensitivities, illuminant) + +.. code-block:: text + (array([[ 0.59368175, 0.30418371, 0.10213454], [ 0.00457979, 1.14946003, -0.15403982], [ 0.03552213, -0.16312291, 1.12760077]]), array([ 1.58214188, 1. , 1.28910346])) @@ -416,9 +482,18 @@ Spectral Computations .. code-block:: python - >>> colour.sd_to_XYZ(colour.SDS_LIGHT_SOURCES["Neodimium Incandescent"]) + colour.sd_to_XYZ(colour.SDS_LIGHT_SOURCES["Neodimium Incandescent"]) + +.. code-block:: text + array([ 36.94726204, 32.62076174, 13.0143849 ]) - >>> sorted(colour.SPECTRAL_TO_XYZ_METHODS) + +.. code-block:: python + + sorted(colour.SPECTRAL_TO_XYZ_METHODS) + +.. code-block:: text + ['ASTM E308', 'Integration', 'astm2015'] @@ -427,119 +502,122 @@ Multi-Spectral Computations .. code-block:: python - >>> msds = np.array( - ... [ - ... [ - ... [ - ... 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), - ... ) + msds = np.array( + [ + [ + [ + 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), + ) + +.. code-block:: text + array([[[ 7.68544647, 4.09414317, 8.49324254], [ 17.12567298, 27.77681821, 25.52573685], [ 19.10280411, 34.45851476, 29.76319628]], @@ -552,7 +630,13 @@ Multi-Spectral Computations [[ 80.00969553, 80.39810464, 76.08184429], [ 33.27611427, 24.38947838, 39.34919287], [ 8.89425686, 11.05185138, 10.86767594]]]) - >>> sorted(colour.MSDS_TO_XYZ_METHODS) + +.. code-block:: python + + sorted(colour.MSDS_TO_XYZ_METHODS) + +.. code-block:: text + ['ASTM E308', 'Integration', 'astm2015'] Blackbody Spectral Radiance Computation @@ -560,7 +644,10 @@ Blackbody Spectral Radiance Computation .. code-block:: python - >>> colour.sd_blackbody(5000) + colour.sd_blackbody(5000) + +.. code-block:: text + SpectralDistribution([[ 3.60000000e+02, 6.65427827e+12], [ 3.61000000e+02, 6.70960528e+12], [ 3.62000000e+02, 6.76482512e+12], @@ -578,9 +665,12 @@ Dominant, Complementary Wavelength & Colour Purity Computation .. code-block:: python - >>> xy = [0.54369557, 0.32107944] - >>> xy_n = [0.31270000, 0.32900000] - >>> colour.dominant_wavelength(xy, xy_n) + xy = [0.54369557, 0.32107944] + xy_n = [0.31270000, 0.32900000] + colour.dominant_wavelength(xy, xy_n) + +.. code-block:: text + (array(616.0), array([ 0.68354746, 0.31628409]), array([ 0.68354746, 0.31628409])) @@ -590,10 +680,19 @@ Lightness Computation .. code-block:: python - >>> colour.lightness(12.19722535) + colour.lightness(12.19722535) + +.. code-block:: text + 41.527875844653451 - >>> sorted(colour.LIGHTNESS_METHODS) - ['Abebe 2017' + +.. code-block:: python + + sorted(colour.LIGHTNESS_METHODS) + +.. code-block:: text + + ['Abebe 2017', 'CIE 1976', 'Fairchild 2010', 'Fairchild 2011', @@ -606,9 +705,18 @@ Luminance Computation .. code-block:: python - >>> colour.luminance(41.52787585) + colour.luminance(41.52787585) + +.. code-block:: text + 12.197225353400775 - >>> sorted(colour.LUMINANCE_METHODS) + +.. code-block:: python + + sorted(colour.LUMINANCE_METHODS) + +.. code-block:: text + ['ASTM D1535', 'CIE 1976', 'Fairchild 2010', @@ -622,11 +730,20 @@ Whiteness Computation .. code-block:: python - >>> XYZ = [95.00000000, 100.00000000, 105.00000000] - >>> XYZ_0 = [94.80966767, 100.00000000, 107.30513595] - >>> colour.whiteness(XYZ, XYZ_0) + XYZ = [95.00000000, 100.00000000, 105.00000000] + XYZ_0 = [94.80966767, 100.00000000, 107.30513595] + colour.whiteness(XYZ, XYZ_0) + +.. code-block:: text + array([ 93.756 , -1.33000001]) - >>> sorted(colour.WHITENESS_METHODS) + +.. code-block:: python + + sorted(colour.WHITENESS_METHODS) + +.. code-block:: text + ['ASTM E313', 'Berger 1959', 'CIE 2004', @@ -640,10 +757,18 @@ Yellowness Computation .. code-block:: python - >>> XYZ = [95.00000000, 100.00000000, 105.00000000] - >>> colour.yellowness(XYZ) + XYZ = [95.00000000, 100.00000000, 105.00000000] + colour.yellowness(XYZ) + +.. code-block:: text 4.3400000000000034 - >>> sorted(colour.YELLOWNESS_METHODS) + +.. code-block:: python + + sorted(colour.YELLOWNESS_METHODS) + +.. code-block:: text + ['ASTM D1925', 'ASTM E313', 'ASTM E313 Alternative'] Luminous Flux, Efficiency & Efficacy Computation @@ -651,14 +776,29 @@ Luminous Flux, Efficiency & Efficacy Computation .. code-block:: python - >>> sd = colour.SDS_LIGHT_SOURCES["Neodimium Incandescent"] - >>> colour.luminous_flux(sd) + sd = colour.SDS_LIGHT_SOURCES["Neodimium Incandescent"] + colour.luminous_flux(sd) + +.. code-block:: text + 23807.655527367202 - >>> sd = colour.SDS_LIGHT_SOURCES["Neodimium Incandescent"] - >>> colour.luminous_efficiency(sd) + +.. code-block:: python + + sd = colour.SDS_LIGHT_SOURCES["Neodimium Incandescent"] + colour.luminous_efficiency(sd) + +.. code-block:: text + 0.19943935624521045 - >>> sd = colour.SDS_LIGHT_SOURCES["Neodimium Incandescent"] - >>> colour.luminous_efficacy(sd) + +.. code-block:: python + + sd = colour.SDS_LIGHT_SOURCES["Neodimium Incandescent"] + colour.luminous_efficacy(sd) + +.. code-block:: text + 136.21708031547874 Contrast Sensitivity Function - ``colour.contrast`` @@ -666,22 +806,39 @@ Contrast Sensitivity Function - ``colour.contrast`` .. code-block:: python - >>> colour.contrast_sensitivity_function(u=4, X_0=60, E=65) + colour.contrast_sensitivity_function(u=4, X_0=60, E=65) + +.. code-block:: text + 358.51180789884984 - >>> sorted(colour.CONTRAST_SENSITIVITY_METHODS) - ['Barten 1999'] +.. code-block:: python + + sorted(colour.CONTRAST_SENSITIVITY_METHODS) + +.. code-block:: text + + ['Barten 1999'] Colour Difference - ``colour.difference`` ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .. code-block:: python - >>> Lab_1 = [100.00000000, 21.57210357, 272.22819350] - >>> Lab_2 = [100.00000000, 426.67945353, 72.39590835] - >>> colour.delta_E(Lab_1, Lab_2) + Lab_1 = [100.00000000, 21.57210357, 272.22819350] + Lab_2 = [100.00000000, 426.67945353, 72.39590835] + colour.delta_E(Lab_1, Lab_2) + +.. code-block:: text + 94.035649026659485 - >>> sorted(colour.DELTA_E_METHODS) + +.. code-block:: python + + sorted(colour.DELTA_E_METHODS) + +.. code-block:: text + ['CAM02-LCD', 'CAM02-SCD', 'CAM02-UCS', @@ -706,8 +863,11 @@ Images .. code-block:: python - >>> RGB = colour.read_image("Ishihara_Colour_Blindness_Test_Plate_3.png") - >>> RGB.shape + RGB = colour.read_image("Ishihara_Colour_Blindness_Test_Plate_3.png") + RGB.shape + +.. code-block:: text + (276, 281, 3) Look Up Table (LUT) Data @@ -715,10 +875,10 @@ Look Up Table (LUT) Data .. code-block:: python - >>> LUT = colour.read_LUT("ACES_Proxy_10_to_ACES.cube") - >>> print(LUT) + LUT = colour.read_LUT("ACES_Proxy_10_to_ACES.cube") + print(LUT) -:: +.. code-block:: text LUT3x1D - ACES Proxy 10 to ACES ------------------------------- @@ -729,8 +889,11 @@ Look Up Table (LUT) Data .. code-block:: python - >>> RGB = [0.17224810, 0.09170660, 0.06416938] - >>> LUT.apply(RGB) + RGB = [0.17224810, 0.09170660, 0.06416938] + LUT.apply(RGB) + +.. code-block:: text + array([ 0.00575674, 0.00181493, 0.00121419]) Colour Models - ``colour.models`` @@ -741,7 +904,10 @@ CIE xyY Colourspace .. code-block:: python - >>> colour.XYZ_to_xyY([0.20654008, 0.12197225, 0.05136952]) + colour.XYZ_to_xyY([0.20654008, 0.12197225, 0.05136952]) + +.. code-block:: text + array([ 0.54369557, 0.32107944, 0.12197225]) CIE L*a*b* Colourspace @@ -749,7 +915,10 @@ CIE L*a*b* Colourspace .. code-block:: python - >>> colour.XYZ_to_Lab([0.20654008, 0.12197225, 0.05136952]) + colour.XYZ_to_Lab([0.20654008, 0.12197225, 0.05136952]) + +.. code-block:: text + array([ 41.52787529, 52.63858304, 26.92317922]) CIE L*u*v* Colourspace @@ -757,7 +926,10 @@ CIE L*u*v* Colourspace .. code-block:: python - >>> colour.XYZ_to_Luv([0.20654008, 0.12197225, 0.05136952]) + colour.XYZ_to_Luv([0.20654008, 0.12197225, 0.05136952]) + +.. code-block:: text + array([ 41.52787529, 96.83626054, 17.75210149]) CIE 1960 UCS Colourspace @@ -765,7 +937,10 @@ CIE 1960 UCS Colourspace .. code-block:: python - >>> colour.XYZ_to_UCS([0.20654008, 0.12197225, 0.05136952]) + colour.XYZ_to_UCS([0.20654008, 0.12197225, 0.05136952]) + +.. code-block:: text + array([ 0.13769339, 0.12197225, 0.1053731 ]) CIE 1964 U*V*W* Colourspace @@ -773,8 +948,11 @@ CIE 1964 U*V*W* Colourspace .. code-block:: python - >>> XYZ = [0.20654008 * 100, 0.12197225 * 100, 0.05136952 * 100] - >>> colour.XYZ_to_UVW(XYZ) + XYZ = [0.20654008 * 100, 0.12197225 * 100, 0.05136952 * 100] + colour.XYZ_to_UVW(XYZ) + +.. code-block:: text + array([ 94.55035725, 11.55536523, 40.54757405]) CAM02-LCD, CAM02-SCD, and CAM02-UCS Colourspaces - Luo, Cui and Li (2006) @@ -782,18 +960,27 @@ CAM02-LCD, CAM02-SCD, and CAM02-UCS Colourspaces - Luo, Cui and Li (2006) .. code-block:: python - >>> 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 * 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) + +.. code-block:: text + array([ 47.16899898, 38.72623785, 15.8663383 ]) - >>> XYZ = [0.20654008, 0.12197225, 0.05136952] - >>> XYZ_w = [95.05 / 100, 100.00 / 100, 108.88 / 100] - >>> colour.XYZ_to_CAM02UCS(XYZ, XYZ_w=XYZ_w, L_A=L_A, Y_b=Y_b) + +.. code-block:: python + + XYZ = [0.20654008, 0.12197225, 0.05136952] + XYZ_w = [95.05 / 100, 100.00 / 100, 108.88 / 100] + colour.XYZ_to_CAM02UCS(XYZ, XYZ_w=XYZ_w, L_A=L_A, Y_b=Y_b) + +.. code-block:: text + array([ 47.16899898, 38.72623785, 15.8663383 ]) CAM16-LCD, CAM16-SCD, and CAM16-UCS Colourspaces - Li et al. (2017) @@ -801,18 +988,27 @@ CAM16-LCD, CAM16-SCD, and CAM16-UCS Colourspaces - Li et al. (2017) .. code-block:: python - >>> 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) - array([ 46.55542238, 40.22460974, 14.25288392] - >>> XYZ = [0.20654008, 0.12197225, 0.05136952] - >>> XYZ_w = [95.05 / 100, 100.00 / 100, 108.88 / 100] - >>> colour.XYZ_to_CAM16UCS(XYZ, XYZ_w=XYZ_w, L_A=L_A, Y_b=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 + 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) + +.. code-block:: text + + array([ 46.55542238, 40.22460974, 14.25288392]) + +.. code-block:: python + + XYZ = [0.20654008, 0.12197225, 0.05136952] + XYZ_w = [95.05 / 100, 100.00 / 100, 108.88 / 100] + colour.XYZ_to_CAM16UCS(XYZ, XYZ_w=XYZ_w, L_A=L_A, Y_b=Y_b) + +.. code-block:: text + array([ 46.55542238, 40.22460974, 14.25288392]) DIN99 Colourspace and DIN99b, DIN99c, DIN99d Refined Formulas @@ -820,8 +1016,11 @@ DIN99 Colourspace and DIN99b, DIN99c, DIN99d Refined Formulas .. code-block:: python - >>> Lab = [41.52787529, 52.63858304, 26.92317922] - >>> colour.Lab_to_DIN99(Lab) + Lab = [41.52787529, 52.63858304, 26.92317922] + colour.Lab_to_DIN99(Lab) + +.. code-block:: text + array([ 53.22821988, 28.41634656, 3.89839552]) ICaCb Colourspace @@ -829,7 +1028,10 @@ ICaCb Colourspace .. code-block:: python - >>> XYZ_to_ICaCb(np.array([0.20654008, 0.12197225, 0.05136952])) + XYZ_to_ICaCb(np.array([0.20654008, 0.12197225, 0.05136952])) + +.. code-block:: text + array([ 0.06875297, 0.05753352, 0.02081548]) IgPgTg Colourspace @@ -837,7 +1039,10 @@ IgPgTg Colourspace .. code-block:: python - >>> colour.XYZ_to_IgPgTg([0.20654008, 0.12197225, 0.05136952]) + colour.XYZ_to_IgPgTg([0.20654008, 0.12197225, 0.05136952]) + +.. code-block:: text + array([ 0.42421258, 0.18632491, 0.10689223]) IPT Colourspace @@ -845,7 +1050,10 @@ IPT Colourspace .. code-block:: python - >>> colour.XYZ_to_IPT([0.20654008, 0.12197225, 0.05136952]) + colour.XYZ_to_IPT([0.20654008, 0.12197225, 0.05136952]) + +.. code-block:: text + array([ 0.38426191, 0.38487306, 0.18886838]) Jzazbz Colourspace @@ -853,7 +1061,10 @@ Jzazbz Colourspace .. code-block:: python - >>> colour.XYZ_to_Jzazbz([0.20654008, 0.12197225, 0.05136952]) + colour.XYZ_to_Jzazbz([0.20654008, 0.12197225, 0.05136952]) + +.. code-block:: text + array([ 0.00535048, 0.00924302, 0.00526007]) hdr-CIELAB Colourspace @@ -861,7 +1072,10 @@ hdr-CIELAB Colourspace .. code-block:: python - >>> colour.XYZ_to_hdr_CIELab([0.20654008, 0.12197225, 0.05136952]) + colour.XYZ_to_hdr_CIELab([0.20654008, 0.12197225, 0.05136952]) + +.. code-block:: text + array([ 51.87002062, 60.4763385 , 32.14551912]) hdr-IPT Colourspace @@ -869,7 +1083,10 @@ hdr-IPT Colourspace .. code-block:: python - >>> colour.XYZ_to_hdr_IPT([0.20654008, 0.12197225, 0.05136952]) + colour.XYZ_to_hdr_IPT([0.20654008, 0.12197225, 0.05136952]) + +.. code-block:: text + array([ 25.18261761, -22.62111297, 3.18511729]) Hunter L,a,b Colour Scale @@ -877,8 +1094,11 @@ Hunter L,a,b Colour Scale .. code-block:: python - >>> XYZ = [0.20654008 * 100, 0.12197225 * 100, 0.05136952 * 100] - >>> colour.XYZ_to_Hunter_Lab(XYZ) + XYZ = [0.20654008 * 100, 0.12197225 * 100, 0.05136952 * 100] + colour.XYZ_to_Hunter_Lab(XYZ) + +.. code-block:: text + array([ 34.92452577, 47.06189858, 14.38615107]) Hunter Rd,a,b Colour Scale @@ -886,8 +1106,11 @@ Hunter Rd,a,b Colour Scale .. code-block:: python - >>> XYZ = [0.20654008 * 100, 0.12197225 * 100, 0.05136952 * 100] - >>> colour.XYZ_to_Hunter_Rdab(XYZ) + XYZ = [0.20654008 * 100, 0.12197225 * 100, 0.05136952 * 100] + colour.XYZ_to_Hunter_Rdab(XYZ) + +.. code-block:: text + array([ 12.197225 , 57.12537874, 17.46241341]) Oklab Colourspace @@ -895,7 +1118,10 @@ Oklab Colourspace .. code-block:: python - >>> colour.XYZ_to_Oklab([0.20654008, 0.12197225, 0.05136952]) + colour.XYZ_to_Oklab([0.20654008, 0.12197225, 0.05136952]) + +.. code-block:: text + array([ 0.51634019, 0.154695 , 0.06289579]) OSA UCS Colourspace @@ -903,8 +1129,11 @@ OSA UCS Colourspace .. code-block:: python - >>> XYZ = [0.20654008 * 100, 0.12197225 * 100, 0.05136952 * 100] - >>> colour.XYZ_to_OSA_UCS(XYZ) + XYZ = [0.20654008 * 100, 0.12197225 * 100, 0.05136952 * 100] + colour.XYZ_to_OSA_UCS(XYZ) + +.. code-block:: text + array([-3.0049979 , 2.99713697, -9.66784231]) ProLab Colourspace @@ -912,7 +1141,10 @@ ProLab Colourspace .. code-block:: python - >>> colour.XYZ_to_ProLab([0.51634019, 0.15469500, 0.06289579]) + colour.XYZ_to_ProLab([0.51634019, 0.15469500, 0.06289579]) + +.. code-block:: text + array([1.24610688, 2.39525236, 0.41902126]) Ragoo and Farup (2021) Optimised IPT Colourspace @@ -920,7 +1152,10 @@ Ragoo and Farup (2021) Optimised IPT Colourspace .. code-block:: python - >>> colour.XYZ_to_IPT_Ragoo2021([0.20654008, 0.12197225, 0.05136952]) + colour.XYZ_to_IPT_Ragoo2021([0.20654008, 0.12197225, 0.05136952]) + +.. code-block:: text + array([ 0.42248243, 0.2910514 , 0.20410663]) Yrg Colourspace - Kirk (2019) @@ -928,7 +1163,10 @@ Yrg Colourspace - Kirk (2019) .. code-block:: python - >>> colour.XYZ_to_Yrg([0.20654008, 0.12197225, 0.05136952]) + colour.XYZ_to_Yrg([0.20654008, 0.12197225, 0.05136952]) + +.. code-block:: text + array([ 0.13137801, 0.49037645, 0.37777388]) Y'CbCr Colour Encoding @@ -936,7 +1174,10 @@ Y'CbCr Colour Encoding .. code-block:: python - >>> colour.RGB_to_YCbCr([1.0, 1.0, 1.0]) + colour.RGB_to_YCbCr([1.0, 1.0, 1.0]) + +.. code-block:: text + array([ 0.92156863, 0.50196078, 0.50196078]) YCoCg Colour Encoding @@ -944,7 +1185,10 @@ YCoCg Colour Encoding .. code-block:: python - >>> colour.RGB_to_YCoCg([0.75, 0.75, 0.0]) + colour.RGB_to_YCoCg([0.75, 0.75, 0.0]) + +.. code-block:: text + array([ 0.5625, 0.375 , 0.1875]) ICtCp Colour Encoding @@ -952,7 +1196,10 @@ ICtCp Colour Encoding .. code-block:: python - >>> colour.RGB_to_ICtCp([0.45620519, 0.03081071, 0.04091952]) + colour.RGB_to_ICtCp([0.45620519, 0.03081071, 0.04091952]) + +.. code-block:: text + array([ 0.07351364, 0.00475253, 0.09351596]) HSV Colourspace @@ -960,7 +1207,10 @@ HSV Colourspace .. code-block:: python - >>> colour.RGB_to_HSV([0.45620519, 0.03081071, 0.04091952]) + colour.RGB_to_HSV([0.45620519, 0.03081071, 0.04091952]) + +.. code-block:: text + array([ 0.99603944, 0.93246304, 0.45620519]) IHLS Colourspace @@ -968,7 +1218,10 @@ IHLS Colourspace .. code-block:: python - >>> colour.RGB_to_IHLS([0.45620519, 0.03081071, 0.04091952]) + colour.RGB_to_IHLS([0.45620519, 0.03081071, 0.04091952]) + +.. code-block:: text + array([ 6.26236117, 0.12197943, 0.42539448]) Prismatic Colourspace @@ -976,7 +1229,10 @@ Prismatic Colourspace .. code-block:: python - >>> colour.RGB_to_Prismatic([0.25, 0.50, 0.75]) + colour.RGB_to_Prismatic([0.25, 0.50, 0.75]) + +.. code-block:: text + array([ 0.75 , 0.16666667, 0.33333333, 0.5 ]) RGB Colourspace and Transformations @@ -984,22 +1240,25 @@ RGB Colourspace and Transformations .. code-block:: python - >>> 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, - ... ) + 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, + ) + +.. code-block:: text + array([ 0.45595571, 0.03039702, 0.04087245]) RGB Colourspace Derivation @@ -1007,9 +1266,12 @@ RGB Colourspace Derivation .. code-block:: python - >>> p = [0.73470, 0.26530, 0.00000, 1.00000, 0.00010, -0.07700] - >>> w = [0.32168, 0.33767] - >>> colour.normalised_primary_matrix(p, w) + p = [0.73470, 0.26530, 0.00000, 1.00000, 0.00010, -0.07700] + w = [0.32168, 0.33767] + colour.normalised_primary_matrix(p, w) + +.. code-block:: text + array([[ 9.52552396e-01, 0.00000000e+00, 9.36786317e-05], [ 3.43966450e-01, 7.28166097e-01, -7.21325464e-02], [ 0.00000000e+00, 0.00000000e+00, 1.00882518e+00]]) @@ -1019,7 +1281,10 @@ RGB Colourspaces .. code-block:: python - >>> sorted(colour.RGB_COLOURSPACES) + sorted(colour.RGB_COLOURSPACES) + +.. code-block:: text + ['ACES2065-1', 'ACEScc', 'ACEScct', @@ -1095,7 +1360,10 @@ OETFs .. code-block:: python - >>> sorted(colour.OETFS) + sorted(colour.OETFS) + +.. code-block:: text + ['ARIB STD-B67', 'Blackmagic Film Generation 5', 'DaVinci Intermediate', @@ -1115,7 +1383,10 @@ EOTFs .. code-block:: python - >>> sorted(colour.EOTFS) + sorted(colour.EOTFS) + +.. code-block:: text + ['DCDM', 'DICOM GSDF', 'ITU-R BT.1886', @@ -1131,15 +1402,22 @@ OOTFs .. code-block:: python - >>> sorted(colour.OOTFS) + sorted(colour.OOTFS) + +.. code-block:: text + ['ITU-R BT.2100 HLG', 'ITU-R BT.2100 PQ'] + Log Encoding / Decoding *********************** .. code-block:: python - >>> sorted(colour.LOG_ENCODINGS) + sorted(colour.LOG_ENCODINGS) + +.. code-block:: text + ['ACEScc', 'ACEScct', 'ACESproxy', @@ -1176,7 +1454,10 @@ CCTFs Encoding / Decoding .. code-block:: python - >>> sorted(colour.CCTF_ENCODINGS) + sorted(colour.CCTF_ENCODINGS) + +.. code-block:: text + ['ACEScc', 'ACEScct', 'ACESproxy', @@ -1229,10 +1510,18 @@ Recommendation ITU-T H.273 Code points for Video Signal Type Identification .. code-block:: python - >>> colour.COLOUR_PRIMARIES_ITUTH273.keys() + colour.COLOUR_PRIMARIES_ITUTH273.keys() + +.. code-block:: text + dict_keys([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 22, 23]) - >>> colour.COLOUR_PRIMARIES_ITUTH273.keys() - >>> description = colour.models.describe_video_signal_colour_primaries(1) + +.. code-block:: python + + colour.models.describe_video_signal_colour_primaries(1) + +.. code-block:: text + =============================================================================== * * * Colour Primaries: 1 * @@ -1252,11 +1541,21 @@ Recommendation ITU-T H.273 Code points for Video Signal Type Identification * FFmpeg Constants : ['AVCOL_PRI_BT709', 'BT709'] * * * =============================================================================== - >>> colour.TRANSFER_CHARACTERISTICS_ITUTH273.keys() + +.. code-block:: python + + colour.TRANSFER_CHARACTERISTICS_ITUTH273.keys() + +.. code-block:: text + dict_keys([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) - >>> description = ( - ... colour.models.describe_video_signal_transfer_characteristics(1) - ... ) + +.. code-block:: python + + colour.models.describe_video_signal_transfer_characteristics(1) + +.. code-block:: text + =============================================================================== * * * Transfer Characteristics: 1 * @@ -1266,11 +1565,21 @@ Recommendation ITU-T H.273 Code points for Video Signal Type Identification * FFmpeg Constants : ['AVCOL_TRC_BT709', 'BT709'] * * * =============================================================================== - >>> colour.MATRIX_COEFFICIENTS_ITUTH273.keys() + +.. code-block:: python + + colour.MATRIX_COEFFICIENTS_ITUTH273.keys() + +.. code-block:: text + dict_keys([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) - >>> description = colour.models.describe_video_signal_matrix_coefficients( - ... 1 - ... ) + +.. code-block:: python + + colour.models.describe_video_signal_matrix_coefficients(1) + +.. code-block:: text + =============================================================================== * * * Matrix Coefficients: 1 * @@ -1289,9 +1598,18 @@ Munsell Value .. code-block:: python - >>> colour.munsell_value(12.23634268) + colour.munsell_value(12.23634268) + +.. code-block:: text + 4.0824437076525664 - >>> sorted(colour.MUNSELL_VALUE_METHODS) + +.. code-block:: python + + sorted(colour.MUNSELL_VALUE_METHODS) + +.. code-block:: text + ['ASTM D1535', 'Ladd 1955', 'McCamy 1987', @@ -1306,9 +1624,18 @@ Munsell Colour .. code-block:: python - >>> colour.xyY_to_munsell_colour([0.38736945, 0.35751656, 0.59362000]) + colour.xyY_to_munsell_colour([0.38736945, 0.35751656, 0.59362000]) + +.. code-block:: text + '4.2YR 8.1/5.3' - >>> colour.munsell_colour_to_xyY("4.2YR 8.1/5.3") + +.. code-block:: python + + colour.munsell_colour_to_xyY("4.2YR 8.1/5.3") + +.. code-block:: text + array([ 0.38736945, 0.35751656, 0.59362 ]) Optical Phenomena - ``colour.phenomena`` @@ -1316,7 +1643,10 @@ Optical Phenomena - ``colour.phenomena`` .. code-block:: python - >>> colour.rayleigh_scattering_sd() + colour.rayleigh_scattering_sd() + +.. code-block:: text + SpectralDistribution([[ 3.60000000e+02, 5.99101337e-01], [ 3.61000000e+02, 5.92170690e-01], [ 3.62000000e+02, 5.85341006e-01], @@ -1337,9 +1667,18 @@ Colour Fidelity Index .. code-block:: python - >>> colour.colour_fidelity_index(colour.SDS_ILLUMINANTS["FL2"]) + colour.colour_fidelity_index(colour.SDS_ILLUMINANTS["FL2"]) + +.. code-block:: text + 70.120825477833037 - >>> sorted(colour.COLOUR_FIDELITY_INDEX_METHODS) + +.. code-block:: python + + sorted(colour.COLOUR_FIDELITY_INDEX_METHODS) + +.. code-block:: text + ['ANSI/IES TM-30-18', 'CIE 2017'] Colour Quality Scale @@ -1347,9 +1686,18 @@ Colour Quality Scale .. code-block:: python - >>> colour.colour_quality_scale(colour.SDS_ILLUMINANTS["FL2"]) + colour.colour_quality_scale(colour.SDS_ILLUMINANTS["FL2"]) + +.. code-block:: text + 64.111703163816699 - >>> sorted(colour.COLOUR_QUALITY_SCALE_METHODS) + +.. code-block:: python + + sorted(colour.COLOUR_QUALITY_SCALE_METHODS) + +.. code-block:: text + ['NIST CQS 7.4', 'NIST CQS 9.0'] Colour Rendering Index @@ -1357,7 +1705,10 @@ Colour Rendering Index .. code-block:: python - >>> colour.colour_rendering_index(colour.SDS_ILLUMINANTS["FL2"]) + colour.colour_rendering_index(colour.SDS_ILLUMINANTS["FL2"]) + +.. code-block:: text + 64.233724121664807 Academy Spectral Similarity Index (SSI) @@ -1365,9 +1716,12 @@ Academy Spectral Similarity Index (SSI) .. code-block:: python - >>> colour.spectral_similarity_index( - ... colour.SDS_ILLUMINANTS["C"], colour.SDS_ILLUMINANTS["D65"] - ... ) + colour.spectral_similarity_index( + colour.SDS_ILLUMINANTS["C"], colour.SDS_ILLUMINANTS["D65"] + ) + +.. code-block:: text + 94.0 Spectral Up-Sampling & Recovery - ``colour.recovery`` @@ -1378,7 +1732,10 @@ Reflectance Recovery .. code-block:: python - >>> colour.XYZ_to_sd([0.20654008, 0.12197225, 0.05136952]) + colour.XYZ_to_sd([0.20654008, 0.12197225, 0.05136952]) + +.. code-block:: text + SpectralDistribution([[ 3.60000000e+02, 8.40144095e-02], [ 3.65000000e+02, 8.41264236e-02], [ 3.70000000e+02, 8.40057597e-02], @@ -1391,40 +1748,48 @@ Reflectance Recovery Extrapolator, {'method': 'Constant', 'left': None, 'right': None}) - >>> sorted(colour.REFLECTANCE_RECOVERY_METHODS) +.. code-block:: python + + sorted(colour.REFLECTANCE_RECOVERY_METHODS) + +.. code-block:: text + ['Jakob 2019', 'Mallett 2019', 'Meng 2015', 'Otsu 2018', 'Smits 1999'] 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.characterisation.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, - ... ) + 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.characterisation.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, + ) + +.. code-block:: text + RGB_CameraSensitivities([[ 4.00000000e+02, 7.22815777e-03, 9.22506480e-03, -9.88368972e-03], [ 4.10000000e+02, -8.50457609e-03, 1.12777480e-02, @@ -1449,11 +1814,26 @@ Correlated Colour Temperature Computation Methods - ``colour.temperature`` .. code-block:: python - >>> colour.uv_to_CCT([0.1978, 0.3122]) + colour.uv_to_CCT([0.1978, 0.3122]) + +.. code-block:: text + array([ 6.50751282e+03, 3.22335875e-03]) - >>> sorted(colour.UV_TO_CCT_METHODS) + +.. code-block:: python + + sorted(colour.UV_TO_CCT_METHODS) + +.. code-block:: text + ['Krystek 1985', 'Ohno 2013', 'Planck 1900', 'Robertson 1968', 'ohno2013', 'robertson1968'] - >>> sorted(colour.XY_TO_CCT_METHODS) + +.. code-block:: python + + sorted(colour.XY_TO_CCT_METHODS) + +.. code-block:: text + ['CIE Illuminant D Series', 'Hernandez 1999', 'Kang 2002', @@ -1468,9 +1848,10 @@ Colour Volume - ``colour.volume`` .. code-block:: python - >>> colour.RGB_colourspace_volume_MonteCarlo( - ... colour.RGB_COLOURSPACE_RGB["sRGB"] - ... ) + colour.RGB_colourspace_volume_MonteCarlo(colour.RGB_COLOURSPACE_RGB["sRGB"]) + +.. code-block:: text + 821958.30000000005 Geometry Primitives Generation - ``colour.geometry`` @@ -1478,8 +1859,11 @@ Geometry Primitives Generation - ``colour.geometry`` .. code-block:: python - >>> colour.primitive("Grid") - (array([ ([-0.5, 0.5, 0. ], [ 0., 1.], [ 0., 0., 1.], [ 0., 1., 0., 1.]), + colour.primitive("Grid") + +.. code-block:: text + + (array([ ([-0.5, 0.5, 0. ], [ 0., 1.], [ 0., 0., 1.], [ 0., 1., 0., 1.]), ([ 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.])], @@ -1488,14 +1872,26 @@ Geometry Primitives Generation - ``colour.geometry`` [2, 3], [3, 1], [1, 0]], dtype=uint32)) - >>> sorted(colour.PRIMITIVE_METHODS) + +.. code-block:: python + + sorted(colour.PRIMITIVE_METHODS) + +.. code-block:: text + ['Cube', 'Grid'] - >>> colour.primitive_vertices("Quad MPL") + +.. code-block:: python + + colour.primitive_vertices("Quad MPL") + +.. code-block:: text + array([[ 0., 0., 0.], [ 1., 0., 0.], [ 1., 1., 0.], [ 0., 1., 0.]]) - >>> sorted(colour.PRIMITIVE_VERTICES_METHODS) + sorted(colour.PRIMITIVE_VERTICES_METHODS) ['Cube MPL', 'Grid MPL', 'Quad MPL', 'Sphere'] Plotting - ``colour.plotting`` @@ -1505,15 +1901,16 @@ Most of the objects are available from the ``colour.plotting`` namespace: .. code-block:: python - >>> from colour.plotting import * - >>> colour_style() + from colour.plotting import * + + colour_style() Visible Spectrum **************** .. code-block:: python - >>> plot_visible_spectrum("CIE 1931 2 Degree Standard Observer") + plot_visible_spectrum("CIE 1931 2 Degree Standard Observer") .. image:: https://colour.readthedocs.io/en/develop/_static/Examples_Plotting_Visible_Spectrum.png @@ -1522,7 +1919,7 @@ Spectral Distribution .. code-block:: python - >>> plot_single_illuminant_sd("FL1") + plot_single_illuminant_sd("FL1") .. image:: https://colour.readthedocs.io/en/develop/_static/Examples_Plotting_Illuminant_F1_SD.png @@ -1531,17 +1928,17 @@ Blackbody .. code-block:: python - >>> blackbody_sds = [ - ... colour.sd_blackbody(i, colour.SpectralShape(0, 10000, 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), - ... ) + blackbody_sds = [ + colour.sd_blackbody(i, colour.SpectralShape(0, 10000, 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), + ) .. image:: https://colour.readthedocs.io/en/develop/_static/Examples_Plotting_Blackbodies.png @@ -1550,11 +1947,11 @@ Colour Matching Functions .. code-block:: python - >>> plot_single_cmfs( - ... "Stockman & Sharpe 2 Degree Cone Fundamentals", - ... y_label="Sensitivity", - ... bounding_box=(390, 870, 0, 1.1), - ... ) + plot_single_cmfs( + "Stockman & Sharpe 2 Degree Cone Fundamentals", + y_label="Sensitivity", + bounding_box=(390, 870, 0, 1.1), + ) .. image:: https://colour.readthedocs.io/en/develop/_static/Examples_Plotting_Cone_Fundamentals.png @@ -1563,20 +1960,20 @@ Luminous Efficiency .. code-block:: python - >>> sd_mesopic_luminous_efficiency_function = ( - ... colour.sd_mesopic_luminous_efficiency_function(0.2) - ... ) - >>> plot_multi_sds( - ... ( - ... sd_mesopic_luminous_efficiency_function, - ... colour.PHOTOPIC_LEFS["CIE 1924 Photopic Standard Observer"], - ... colour.SCOTOPIC_LEFS["CIE 1951 Scotopic Standard Observer"], - ... ), - ... y_label="Luminous Efficiency", - ... legend_location="upper right", - ... y_tighten=True, - ... margins=(0, 0, 0, 0.1), - ... ) + sd_mesopic_luminous_efficiency_function = ( + colour.sd_mesopic_luminous_efficiency_function(0.2) + ) + plot_multi_sds( + ( + sd_mesopic_luminous_efficiency_function, + colour.PHOTOPIC_LEFS["CIE 1924 Photopic Standard Observer"], + colour.SCOTOPIC_LEFS["CIE 1951 Scotopic Standard Observer"], + ), + y_label="Luminous Efficiency", + legend_location="upper right", + y_tighten=True, + margins=(0, 0, 0, 0.1), + ) .. image:: https://colour.readthedocs.io/en/develop/_static/Examples_Plotting_Luminous_Efficiency.png @@ -1585,29 +1982,26 @@ Colour Checker .. code-block:: python - >>> from colour.characterisation.dataset.colour_checkers.sds import ( - ... COLOURCHECKER_INDEXES_TO_NAMES_MAPPING, - ... ) - >>> plot_multi_sds( - ... [ - ... colour.SDS_COLOURCHECKERS["BabelColor Average"][value] - ... for key, value in sorted( - ... COLOURCHECKER_INDEXES_TO_NAMES_MAPPING.items() - ... ) - ... ], - ... plot_kwargs={ - ... "use_sd_colours": True, - ... }, - ... title=("BabelColor Average - " "Spectral Distributions"), - ... ) + from colour.characterisation.dataset.colour_checkers.sds import ( + COLOURCHECKER_INDEXES_TO_NAMES_MAPPING, + ) + + plot_multi_sds( + [ + colour.SDS_COLOURCHECKERS["BabelColor Average"][value] + for key, value in sorted(COLOURCHECKER_INDEXES_TO_NAMES_MAPPING.items()) + ], + plot_kwargs={ + "use_sd_colours": True, + }, + title=("BabelColor Average - " "Spectral Distributions"), + ) .. image:: https://colour.readthedocs.io/en/develop/_static/Examples_Plotting_BabelColor_Average.png .. code-block:: python - >>> plot_single_colour_checker( - ... "ColorChecker 2005", text_kwargs={"visible": False} - ... ) + plot_single_colour_checker("ColorChecker 2005", text_kwargs={"visible": False}) .. image:: https://colour.readthedocs.io/en/develop/_static/Examples_Plotting_ColorChecker_2005.png @@ -1616,9 +2010,7 @@ Chromaticities Prediction .. code-block:: python - >>> plot_corresponding_chromaticities_prediction( - ... 2, "Von Kries", "Bianco 2010" - ... ) + plot_corresponding_chromaticities_prediction(2, "Von Kries", "Bianco 2010") .. image:: https://colour.readthedocs.io/en/develop/_static/Examples_Plotting_Chromaticities_Prediction.png @@ -1627,13 +2019,14 @@ Chromaticities .. code-block:: python - >>> import numpy as np - >>> 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"], - ... ) + import numpy as np + + 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"], + ) .. image:: https://colour.readthedocs.io/en/develop/_static/Examples_Plotting_Chromaticities_CIE_1931_Chromaticity_Diagram.png @@ -1642,9 +2035,7 @@ Colour Rendering Index .. code-block:: python - >>> plot_single_sd_colour_rendering_index_bars( - ... colour.SDS_ILLUMINANTS["FL2"] - ... ) + plot_single_sd_colour_rendering_index_bars(colour.SDS_ILLUMINANTS["FL2"]) .. image:: https://colour.readthedocs.io/en/develop/_static/Examples_Plotting_CRI.png @@ -1653,7 +2044,7 @@ ANSI/IES TM-30-18 Colour Rendition Report .. code-block:: python - >>> plot_single_sd_colour_rendition_report(colour.SDS_ILLUMINANTS["FL2"]) + plot_single_sd_colour_rendition_report(colour.SDS_ILLUMINANTS["FL2"]) .. image:: https://colour.readthedocs.io/en/develop/_static/Examples_Plotting_Colour_Rendition_Report.png @@ -1662,17 +2053,13 @@ Gamut Section .. code-block:: python - >>> plot_visible_spectrum_section( - ... section_colours="RGB", section_opacity=0.15 - ... ) + plot_visible_spectrum_section(section_colours="RGB", section_opacity=0.15) .. image:: https://colour.readthedocs.io/en/develop/_static/Examples_Plotting_Plot_Visible_Spectrum_Section.png .. code-block:: python - >>> plot_RGB_colourspace_section( - ... "sRGB", section_colours="RGB", section_opacity=0.15 - ... ) + plot_RGB_colourspace_section("sRGB", section_colours="RGB", section_opacity=0.15) .. image:: https://colour.readthedocs.io/en/develop/_static/Examples_Plotting_Plot_RGB_Colourspace_Section.png @@ -1681,9 +2068,7 @@ Colour Temperature .. code-block:: python - >>> plot_planckian_locus_in_chromaticity_diagram_CIE1960UCS( - ... ["A", "B", "C"] - ... ) + plot_planckian_locus_in_chromaticity_diagram_CIE1960UCS(["A", "B", "C"]) .. image:: https://colour.readthedocs.io/en/develop/_static/Examples_Plotting_CCT_CIE_1960_UCS_Chromaticity_Diagram.png diff --git a/docs/basics.rst b/docs/basics.rst index b6d923da1..b98da7703 100644 --- a/docs/basics.rst +++ b/docs/basics.rst @@ -14,7 +14,7 @@ For example, in `IPython `__ or `Jupyter Notebook >> import colour + import colour Automatic Colour Conversion Graph - ``colour.graph`` ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -55,12 +55,10 @@ conversion graph enabling easier colour conversions. .. code-block:: python - >>> sd = colour.SDS_COLOURCHECKERS["ColorChecker N Ohta"]["dark skin"] - >>> colour.convert( - ... sd, "Spectral Distribution", "sRGB", verbose={"mode": "Short"} - ... ) + sd = colour.SDS_COLOURCHECKERS["ColorChecker N Ohta"]["dark skin"] + colour.convert(sd, "Spectral Distribution", "sRGB", verbose={"mode": "Short"}) -:: +.. code-block:: text =============================================================================== * * @@ -73,13 +71,16 @@ conversion graph enabling easier colour conversions. .. code-block:: python - >>> illuminant = colour.SDS_ILLUMINANTS["FL2"] - >>> colour.convert( - ... sd, - ... "Spectral Distribution", - ... "sRGB", - ... sd_to_XYZ={"illuminant": illuminant}, - ... ) + illuminant = colour.SDS_ILLUMINANTS["FL2"] + colour.convert( + sd, + "Spectral Distribution", + "sRGB", + sd_to_XYZ={"illuminant": illuminant}, + ) + +.. code-block:: text + array([ 0.47924575, 0.31676968, 0.17362725]) Chromatic Adaptation - ``colour.adaptation`` @@ -87,16 +88,21 @@ Chromatic Adaptation - ``colour.adaptation`` .. code-block:: python - >>> 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) - ... ) + 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)) + +.. code-block:: text + array([ 0.2533053 , 0.13765138, 0.01543307]) - >>> sorted(colour.CHROMATIC_ADAPTATION_METHODS) + +.. code-block:: python + + sorted(colour.CHROMATIC_ADAPTATION_METHODS) + +.. code-block:: text + ['CIE 1994', 'CMCCAT2000', 'Fairchild 1990', 'Von Kries', 'Zhai 2018'] Algebra - ``colour.algebra`` @@ -107,9 +113,12 @@ Kernel Interpolation .. code-block:: python - >>> 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]) + 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]) + +.. code-block:: text + array([ 6.18062083, 8.08238488, 57.85783403]) Sprague (1880) Interpolation @@ -117,9 +126,12 @@ Sprague (1880) Interpolation .. code-block:: python - >>> 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]) + 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]) + +.. code-block:: text + array([ 6.72951612, 7.81406251, 43.77379185]) Colour Appearance Models - ``colour.appearance`` @@ -127,21 +139,54 @@ Colour Appearance Models - ``colour.appearance`` .. code-block:: python - >>> 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_CIECAM02(XYZ, XYZ_w, L_A, Y_b) + +.. code-block:: text + CAM_Specification_CIECAM02(J=34.434525727858997, C=67.365010921125943, h=22.279164147957065, s=62.81485585332716, Q=177.47124941102123, M=70.024939419291414, H=2.6896085344238898, HC=None) - >>> colour.XYZ_to_CIECAM16(XYZ, XYZ_w, L_A, Y_b) + +.. code-block:: python + + colour.XYZ_to_CIECAM16(XYZ, XYZ_w, L_A, Y_b) + +.. code-block:: text + CAM_Specification_CIECAM16(J=34.434525727858997, C=67.365010921125943, h=22.279164147957065, s=62.81485585332716, Q=177.47124941102123, M=70.024939419291414, H=2.6896085344238898, HC=None) - >>> colour.XYZ_to_CAM16(XYZ, XYZ_w, L_A, Y_b) + +.. code-block:: python + + colour.XYZ_to_CAM16(XYZ, XYZ_w, L_A, Y_b) + +.. code-block:: text + CAM_Specification_CAM16(J=33.880368498111686, C=69.444353357408033, h=19.510887327451748, s=64.03612114840314, Q=176.03752758512178, M=72.18638534116765, H=399.52975599115319, HC=None) - >>> colour.XYZ_to_Hellwig2022(XYZ, XYZ_w, L_A) + +.. code-block:: python + + colour.XYZ_to_Hellwig2022(XYZ, XYZ_w, L_A) + +.. code-block:: text + CAM_Specification_Hellwig2022(J=33.880368498111686, C=40.347043294550311, h=19.510887327451748, s=117.38555017188679, Q=45.34489577734751, M=53.228355383108031, H=399.52975599115319, HC=None) - >>> colour.XYZ_to_Kim2009(XYZ, XYZ_w, L_A) + +.. code-block:: python + + colour.XYZ_to_Kim2009(XYZ, XYZ_w, L_A) + +.. code-block:: text + CAM_Specification_Kim2009(J=19.879918542450902, C=55.839055250876946, h=22.013388165090046, s=112.97979354939129, Q=36.309026130161449, M=46.346415858227864, H=2.3543198369639931, HC=None) - >>> colour.XYZ_to_ZCAM(XYZ, XYZ_w, L_A, Y_b) + +.. code-block:: python + + colour.XYZ_to_ZCAM(XYZ, XYZ_w, L_A, Y_b) + +.. code-block:: text + CAM_Specification_ZCAM(J=38.347186278956357, C=21.12138989208518, h=33.711578931095197, s=81.444585609489536, Q=76.986725284523772, M=42.403805833900506, H=0.45779200212219573, HC=None, V=43.623590687423544, K=43.20894953152817, W=34.829588380192149) Colour Blindness - ``colour.blindness`` @@ -149,15 +194,23 @@ Colour Blindness - ``colour.blindness`` .. code-block:: python - >>> import numpy as np - >>> cmfs = colour.LMS_CMFS["Stockman & Sharpe 2 Degree Cone Fundamentals"] - >>> colour.msds_cmfs_anomalous_trichromacy_Machado2009( - ... cmfs, np.array([15, 0, 0]) - ... )[450] + import numpy as np + + cmfs = colour.LMS_CMFS["Stockman & Sharpe 2 Degree Cone Fundamentals"] + colour.msds_cmfs_anomalous_trichromacy_Machado2009(cmfs, np.array([15, 0, 0]))[450] + +.. code-block:: text + array([ 0.08912884, 0.0870524 , 0.955393 ]) - >>> primaries = colour.MSDS_DISPLAY_PRIMARIES["Apple Studio Display"] - >>> d_LMS = (15, 0, 0) - >>> colour.matrix_anomalous_trichromacy_Machado2009(cmfs, primaries, d_LMS) + +.. code-block:: python + + primaries = colour.MSDS_DISPLAY_PRIMARIES["Apple Studio Display"] + d_LMS = (15, 0, 0) + colour.matrix_anomalous_trichromacy_Machado2009(cmfs, primaries, d_LMS) + +.. code-block:: text + array([[-0.27774652, 2.65150084, -1.37375432], [ 0.27189369, 0.20047862, 0.52762768], [ 0.00644047, 0.25921579, 0.73434374]]) @@ -167,13 +220,23 @@ Colour Correction - ``colour characterisation`` .. code-block:: python - >>> 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) + 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) + +.. code-block:: text + array([ 0.1806237 , 0.07234791, 0.07848845]) - >>> sorted(colour.COLOUR_CORRECTION_METHODS) + +.. code-block:: python + + sorted(colour.COLOUR_CORRECTION_METHODS) + +.. code-block:: text + ['Cheung 2004', 'Finlayson 2015', 'Vandermonde'] ACES Input Transform - ``colour characterisation`` @@ -181,9 +244,12 @@ ACES Input Transform - ``colour characterisation`` .. code-block:: python - >>> sensitivities = colour.MSDS_CAMERA_SENSITIVITIES["Nikon 5100 (NPL)"] - >>> illuminant = colour.SDS_ILLUMINANTS["D55"] - >>> colour.matrix_idt(sensitivities, illuminant) + sensitivities = colour.MSDS_CAMERA_SENSITIVITIES["Nikon 5100 (NPL)"] + illuminant = colour.SDS_ILLUMINANTS["D55"] + colour.matrix_idt(sensitivities, illuminant) + +.. code-block:: text + (array([[ 0.59368175, 0.30418371, 0.10213454], [ 0.00457979, 1.14946003, -0.15403982], [ 0.03552213, -0.16312291, 1.12760077]]), array([ 1.58214188, 1. , 1.28910346])) @@ -196,9 +262,18 @@ Spectral Computations .. code-block:: python - >>> colour.sd_to_XYZ(colour.SDS_LIGHT_SOURCES["Neodimium Incandescent"]) + colour.sd_to_XYZ(colour.SDS_LIGHT_SOURCES["Neodimium Incandescent"]) + +.. code-block:: text + array([ 36.94726204, 32.62076174, 13.0143849 ]) - >>> sorted(colour.SPECTRAL_TO_XYZ_METHODS) + +.. code-block:: python + + sorted(colour.SPECTRAL_TO_XYZ_METHODS) + +.. code-block:: text + ['ASTM E308', 'Integration', 'astm2015'] @@ -207,119 +282,122 @@ Multi-Spectral Computations .. code-block:: python - >>> msds = np.array( - ... [ - ... [ - ... [ - ... 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), - ... ) + msds = np.array( + [ + [ + [ + 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), + ) + +.. code-block:: text + array([[[ 7.68544647, 4.09414317, 8.49324254], [ 17.12567298, 27.77681821, 25.52573685], [ 19.10280411, 34.45851476, 29.76319628]], @@ -332,7 +410,13 @@ Multi-Spectral Computations [[ 80.00969553, 80.39810464, 76.08184429], [ 33.27611427, 24.38947838, 39.34919287], [ 8.89425686, 11.05185138, 10.86767594]]]) - >>> sorted(colour.MSDS_TO_XYZ_METHODS) + +.. code-block:: python + + sorted(colour.MSDS_TO_XYZ_METHODS) + +.. code-block:: text + ['ASTM E308', 'Integration', 'astm2015'] Blackbody Spectral Radiance Computation @@ -340,7 +424,10 @@ Blackbody Spectral Radiance Computation .. code-block:: python - >>> colour.sd_blackbody(5000) + colour.sd_blackbody(5000) + +.. code-block:: text + SpectralDistribution([[ 3.60000000e+02, 6.65427827e+12], [ 3.61000000e+02, 6.70960528e+12], [ 3.62000000e+02, 6.76482512e+12], @@ -358,9 +445,12 @@ Dominant, Complementary Wavelength & Colour Purity Computation .. code-block:: python - >>> xy = [0.54369557, 0.32107944] - >>> xy_n = [0.31270000, 0.32900000] - >>> colour.dominant_wavelength(xy, xy_n) + xy = [0.54369557, 0.32107944] + xy_n = [0.31270000, 0.32900000] + colour.dominant_wavelength(xy, xy_n) + +.. code-block:: text + (array(616.0), array([ 0.68354746, 0.31628409]), array([ 0.68354746, 0.31628409])) @@ -370,9 +460,18 @@ Lightness Computation .. code-block:: python - >>> colour.lightness(12.19722535) + colour.lightness(12.19722535) + +.. code-block:: text + 41.527875844653451 - >>> sorted(colour.LIGHTNESS_METHODS) + +.. code-block:: python + + sorted(colour.LIGHTNESS_METHODS) + +.. code-block:: text + ['Abebe 2017', 'CIE 1976', 'Fairchild 2010', @@ -386,9 +485,18 @@ Luminance Computation .. code-block:: python - >>> colour.luminance(41.52787585) + colour.luminance(41.52787585) + +.. code-block:: text + 12.197225353400775 - >>> sorted(colour.LUMINANCE_METHODS) + +.. code-block:: python + + sorted(colour.LUMINANCE_METHODS) + +.. code-block:: text + ['ASTM D1535', 'CIE 1976', 'Fairchild 2010', @@ -402,11 +510,20 @@ Whiteness Computation .. code-block:: python - >>> XYZ = [95.00000000, 100.00000000, 105.00000000] - >>> XYZ_0 = [94.80966767, 100.00000000, 107.30513595] - >>> colour.whiteness(XYZ, XYZ_0) + XYZ = [95.00000000, 100.00000000, 105.00000000] + XYZ_0 = [94.80966767, 100.00000000, 107.30513595] + colour.whiteness(XYZ, XYZ_0) + +.. code-block:: text + array([ 93.756 , -1.33000001]) - >>> sorted(colour.WHITENESS_METHODS) + +.. code-block:: python + + sorted(colour.WHITENESS_METHODS) + +.. code-block:: text + ['ASTM E313', 'Berger 1959', 'CIE 2004', @@ -420,10 +537,18 @@ Yellowness Computation .. code-block:: python - >>> XYZ = [95.00000000, 100.00000000, 105.00000000] - >>> colour.yellowness(XYZ) + XYZ = [95.00000000, 100.00000000, 105.00000000] + colour.yellowness(XYZ) + +.. code-block:: text 4.3400000000000034 - >>> sorted(colour.YELLOWNESS_METHODS) + +.. code-block:: python + + sorted(colour.YELLOWNESS_METHODS) + +.. code-block:: text + ['ASTM D1925', 'ASTM E313', 'ASTM E313 Alternative'] Luminous Flux, Efficiency & Efficacy Computation @@ -431,14 +556,29 @@ Luminous Flux, Efficiency & Efficacy Computation .. code-block:: python - >>> sd = colour.SDS_LIGHT_SOURCES["Neodimium Incandescent"] - >>> colour.luminous_flux(sd) + sd = colour.SDS_LIGHT_SOURCES["Neodimium Incandescent"] + colour.luminous_flux(sd) + +.. code-block:: text + 23807.655527367202 - >>> sd = colour.SDS_LIGHT_SOURCES["Neodimium Incandescent"] - >>> colour.luminous_efficiency(sd) + +.. code-block:: python + + sd = colour.SDS_LIGHT_SOURCES["Neodimium Incandescent"] + colour.luminous_efficiency(sd) + +.. code-block:: text + 0.19943935624521045 - >>> sd = colour.SDS_LIGHT_SOURCES["Neodimium Incandescent"] - >>> colour.luminous_efficacy(sd) + +.. code-block:: python + + sd = colour.SDS_LIGHT_SOURCES["Neodimium Incandescent"] + colour.luminous_efficacy(sd) + +.. code-block:: text + 136.21708031547874 Contrast Sensitivity Function - ``colour.contrast`` @@ -446,22 +586,39 @@ Contrast Sensitivity Function - ``colour.contrast`` .. code-block:: python - >>> colour.contrast_sensitivity_function(u=4, X_0=60, E=65) + colour.contrast_sensitivity_function(u=4, X_0=60, E=65) + +.. code-block:: text + 358.51180789884984 - >>> sorted(colour.CONTRAST_SENSITIVITY_METHODS) - ['Barten 1999'] +.. code-block:: python + + sorted(colour.CONTRAST_SENSITIVITY_METHODS) + +.. code-block:: text + + ['Barten 1999'] Colour Difference - ``colour.difference`` ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .. code-block:: python - >>> Lab_1 = [100.00000000, 21.57210357, 272.22819350] - >>> Lab_2 = [100.00000000, 426.67945353, 72.39590835] - >>> colour.delta_E(Lab_1, Lab_2) + Lab_1 = [100.00000000, 21.57210357, 272.22819350] + Lab_2 = [100.00000000, 426.67945353, 72.39590835] + colour.delta_E(Lab_1, Lab_2) + +.. code-block:: text + 94.035649026659485 - >>> sorted(colour.DELTA_E_METHODS) + +.. code-block:: python + + sorted(colour.DELTA_E_METHODS) + +.. code-block:: text + ['CAM02-LCD', 'CAM02-SCD', 'CAM02-UCS', @@ -486,8 +643,11 @@ Images .. code-block:: python - >>> RGB = colour.read_image("Ishihara_Colour_Blindness_Test_Plate_3.png") - >>> RGB.shape + RGB = colour.read_image("Ishihara_Colour_Blindness_Test_Plate_3.png") + RGB.shape + +.. code-block:: text + (276, 281, 3) Look Up Table (LUT) Data @@ -495,10 +655,10 @@ Look Up Table (LUT) Data .. code-block:: python - >>> LUT = colour.read_LUT("ACES_Proxy_10_to_ACES.cube") - >>> print(LUT) + LUT = colour.read_LUT("ACES_Proxy_10_to_ACES.cube") + print(LUT) -:: +.. code-block:: text LUT3x1D - ACES Proxy 10 to ACES ------------------------------- @@ -509,8 +669,11 @@ Look Up Table (LUT) Data .. code-block:: python - >>> RGB = [0.17224810, 0.09170660, 0.06416938] - >>> LUT.apply(RGB) + RGB = [0.17224810, 0.09170660, 0.06416938] + LUT.apply(RGB) + +.. code-block:: text + array([ 0.00575674, 0.00181493, 0.00121419]) Colour Models - ``colour.models`` @@ -521,7 +684,10 @@ CIE xyY Colourspace .. code-block:: python - >>> colour.XYZ_to_xyY([0.20654008, 0.12197225, 0.05136952]) + colour.XYZ_to_xyY([0.20654008, 0.12197225, 0.05136952]) + +.. code-block:: text + array([ 0.54369557, 0.32107944, 0.12197225]) CIE L*a*b* Colourspace @@ -529,7 +695,10 @@ CIE L*a*b* Colourspace .. code-block:: python - >>> colour.XYZ_to_Lab([0.20654008, 0.12197225, 0.05136952]) + colour.XYZ_to_Lab([0.20654008, 0.12197225, 0.05136952]) + +.. code-block:: text + array([ 41.52787529, 52.63858304, 26.92317922]) CIE L*u*v* Colourspace @@ -537,7 +706,10 @@ CIE L*u*v* Colourspace .. code-block:: python - >>> colour.XYZ_to_Luv([0.20654008, 0.12197225, 0.05136952]) + colour.XYZ_to_Luv([0.20654008, 0.12197225, 0.05136952]) + +.. code-block:: text + array([ 41.52787529, 96.83626054, 17.75210149]) CIE 1960 UCS Colourspace @@ -545,7 +717,10 @@ CIE 1960 UCS Colourspace .. code-block:: python - >>> colour.XYZ_to_UCS([0.20654008, 0.12197225, 0.05136952]) + colour.XYZ_to_UCS([0.20654008, 0.12197225, 0.05136952]) + +.. code-block:: text + array([ 0.13769339, 0.12197225, 0.1053731 ]) CIE 1964 U*V*W* Colourspace @@ -553,8 +728,11 @@ CIE 1964 U*V*W* Colourspace .. code-block:: python - >>> XYZ = [0.20654008 * 100, 0.12197225 * 100, 0.05136952 * 100] - >>> colour.XYZ_to_UVW(XYZ) + XYZ = [0.20654008 * 100, 0.12197225 * 100, 0.05136952 * 100] + colour.XYZ_to_UVW(XYZ) + +.. code-block:: text + array([ 94.55035725, 11.55536523, 40.54757405]) CAM02-LCD, CAM02-SCD, and CAM02-UCS Colourspaces - Luo, Cui and Li (2006) @@ -562,18 +740,27 @@ CAM02-LCD, CAM02-SCD, and CAM02-UCS Colourspaces - Luo, Cui and Li (2006) .. code-block:: python - >>> 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 * 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) + +.. code-block:: text + array([ 47.16899898, 38.72623785, 15.8663383 ]) - >>> XYZ = [0.20654008, 0.12197225, 0.05136952] - >>> XYZ_w = [95.05 / 100, 100.00 / 100, 108.88 / 100] - >>> colour.XYZ_to_CAM02UCS(XYZ, XYZ_w=XYZ_w, L_A=L_A, Y_b=Y_b) + +.. code-block:: python + + XYZ = [0.20654008, 0.12197225, 0.05136952] + XYZ_w = [95.05 / 100, 100.00 / 100, 108.88 / 100] + colour.XYZ_to_CAM02UCS(XYZ, XYZ_w=XYZ_w, L_A=L_A, Y_b=Y_b) + +.. code-block:: text + array([ 47.16899898, 38.72623785, 15.8663383 ]) CAM16-LCD, CAM16-SCD, and CAM16-UCS Colourspaces - Li et al. (2017) @@ -581,18 +768,27 @@ CAM16-LCD, CAM16-SCD, and CAM16-UCS Colourspaces - Li et al. (2017) .. code-block:: python - >>> 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) - array([ 46.55542238, 40.22460974, 14.25288392] - >>> XYZ = [0.20654008, 0.12197225, 0.05136952] - >>> XYZ_w = [95.05 / 100, 100.00 / 100, 108.88 / 100] - >>> colour.XYZ_to_CAM16UCS(XYZ, XYZ_w=XYZ_w, L_A=L_A, Y_b=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 + 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) + +.. code-block:: text + + array([ 46.55542238, 40.22460974, 14.25288392]) + +.. code-block:: python + + XYZ = [0.20654008, 0.12197225, 0.05136952] + XYZ_w = [95.05 / 100, 100.00 / 100, 108.88 / 100] + colour.XYZ_to_CAM16UCS(XYZ, XYZ_w=XYZ_w, L_A=L_A, Y_b=Y_b) + +.. code-block:: text + array([ 46.55542238, 40.22460974, 14.25288392]) DIN99 Colourspace and DIN99b, DIN99c, DIN99d Refined Formulas @@ -600,8 +796,11 @@ DIN99 Colourspace and DIN99b, DIN99c, DIN99d Refined Formulas .. code-block:: python - >>> Lab = [41.52787529, 52.63858304, 26.92317922] - >>> colour.Lab_to_DIN99(Lab) + Lab = [41.52787529, 52.63858304, 26.92317922] + colour.Lab_to_DIN99(Lab) + +.. code-block:: text + array([ 53.22821988, 28.41634656, 3.89839552]) ICaCb Colourspace @@ -609,7 +808,10 @@ ICaCb Colourspace .. code-block:: python - >>> XYZ_to_ICaCb(np.array([0.20654008, 0.12197225, 0.05136952])) + XYZ_to_ICaCb(np.array([0.20654008, 0.12197225, 0.05136952])) + +.. code-block:: text + array([ 0.06875297, 0.05753352, 0.02081548]) IgPgTg Colourspace @@ -617,7 +819,10 @@ IgPgTg Colourspace .. code-block:: python - >>> colour.XYZ_to_IgPgTg([0.20654008, 0.12197225, 0.05136952]) + colour.XYZ_to_IgPgTg([0.20654008, 0.12197225, 0.05136952]) + +.. code-block:: text + array([ 0.42421258, 0.18632491, 0.10689223]) IPT Colourspace @@ -625,7 +830,10 @@ IPT Colourspace .. code-block:: python - >>> colour.XYZ_to_IPT([0.20654008, 0.12197225, 0.05136952]) + colour.XYZ_to_IPT([0.20654008, 0.12197225, 0.05136952]) + +.. code-block:: text + array([ 0.38426191, 0.38487306, 0.18886838]) Jzazbz Colourspace @@ -633,7 +841,10 @@ Jzazbz Colourspace .. code-block:: python - >>> colour.XYZ_to_Jzazbz([0.20654008, 0.12197225, 0.05136952]) + colour.XYZ_to_Jzazbz([0.20654008, 0.12197225, 0.05136952]) + +.. code-block:: text + array([ 0.00535048, 0.00924302, 0.00526007]) hdr-CIELAB Colourspace @@ -641,7 +852,10 @@ hdr-CIELAB Colourspace .. code-block:: python - >>> colour.XYZ_to_hdr_CIELab([0.20654008, 0.12197225, 0.05136952]) + colour.XYZ_to_hdr_CIELab([0.20654008, 0.12197225, 0.05136952]) + +.. code-block:: text + array([ 51.87002062, 60.4763385 , 32.14551912]) hdr-IPT Colourspace @@ -649,7 +863,10 @@ hdr-IPT Colourspace .. code-block:: python - >>> colour.XYZ_to_hdr_IPT([0.20654008, 0.12197225, 0.05136952]) + colour.XYZ_to_hdr_IPT([0.20654008, 0.12197225, 0.05136952]) + +.. code-block:: text + array([ 25.18261761, -22.62111297, 3.18511729]) Hunter L,a,b Colour Scale @@ -657,8 +874,11 @@ Hunter L,a,b Colour Scale .. code-block:: python - >>> XYZ = [0.20654008 * 100, 0.12197225 * 100, 0.05136952 * 100] - >>> colour.XYZ_to_Hunter_Lab(XYZ) + XYZ = [0.20654008 * 100, 0.12197225 * 100, 0.05136952 * 100] + colour.XYZ_to_Hunter_Lab(XYZ) + +.. code-block:: text + array([ 34.92452577, 47.06189858, 14.38615107]) Hunter Rd,a,b Colour Scale @@ -666,8 +886,11 @@ Hunter Rd,a,b Colour Scale .. code-block:: python - >>> XYZ = [0.20654008 * 100, 0.12197225 * 100, 0.05136952 * 100] - >>> colour.XYZ_to_Hunter_Rdab(XYZ) + XYZ = [0.20654008 * 100, 0.12197225 * 100, 0.05136952 * 100] + colour.XYZ_to_Hunter_Rdab(XYZ) + +.. code-block:: text + array([ 12.197225 , 57.12537874, 17.46241341]) Oklab Colourspace @@ -675,7 +898,10 @@ Oklab Colourspace .. code-block:: python - >>> colour.XYZ_to_Oklab([0.20654008, 0.12197225, 0.05136952]) + colour.XYZ_to_Oklab([0.20654008, 0.12197225, 0.05136952]) + +.. code-block:: text + array([ 0.51634019, 0.154695 , 0.06289579]) OSA UCS Colourspace @@ -683,8 +909,11 @@ OSA UCS Colourspace .. code-block:: python - >>> XYZ = [0.20654008 * 100, 0.12197225 * 100, 0.05136952 * 100] - >>> colour.XYZ_to_OSA_UCS(XYZ) + XYZ = [0.20654008 * 100, 0.12197225 * 100, 0.05136952 * 100] + colour.XYZ_to_OSA_UCS(XYZ) + +.. code-block:: text + array([-3.0049979 , 2.99713697, -9.66784231]) ProLab Colourspace @@ -692,7 +921,10 @@ ProLab Colourspace .. code-block:: python - >>> colour.XYZ_to_ProLab([0.51634019, 0.15469500, 0.06289579]) + colour.XYZ_to_ProLab([0.51634019, 0.15469500, 0.06289579]) + +.. code-block:: text + array([1.24610688, 2.39525236, 0.41902126]) Ragoo and Farup (2021) Optimised IPT Colourspace @@ -700,7 +932,10 @@ Ragoo and Farup (2021) Optimised IPT Colourspace .. code-block:: python - >>> colour.XYZ_to_IPT_Ragoo2021([0.20654008, 0.12197225, 0.05136952]) + colour.XYZ_to_IPT_Ragoo2021([0.20654008, 0.12197225, 0.05136952]) + +.. code-block:: text + array([ 0.42248243, 0.2910514 , 0.20410663]) Yrg Colourspace - Kirk (2019) @@ -708,7 +943,10 @@ Yrg Colourspace - Kirk (2019) .. code-block:: python - >>> colour.XYZ_to_Yrg([0.20654008, 0.12197225, 0.05136952]) + colour.XYZ_to_Yrg([0.20654008, 0.12197225, 0.05136952]) + +.. code-block:: text + array([ 0.13137801, 0.49037645, 0.37777388]) Y'CbCr Colour Encoding @@ -716,7 +954,10 @@ Y'CbCr Colour Encoding .. code-block:: python - >>> colour.RGB_to_YCbCr([1.0, 1.0, 1.0]) + colour.RGB_to_YCbCr([1.0, 1.0, 1.0]) + +.. code-block:: text + array([ 0.92156863, 0.50196078, 0.50196078]) YCoCg Colour Encoding @@ -724,7 +965,10 @@ YCoCg Colour Encoding .. code-block:: python - >>> colour.RGB_to_YCoCg([0.75, 0.75, 0.0]) + colour.RGB_to_YCoCg([0.75, 0.75, 0.0]) + +.. code-block:: text + array([ 0.5625, 0.375 , 0.1875]) ICtCp Colour Encoding @@ -732,7 +976,10 @@ ICtCp Colour Encoding .. code-block:: python - >>> colour.RGB_to_ICtCp([0.45620519, 0.03081071, 0.04091952]) + colour.RGB_to_ICtCp([0.45620519, 0.03081071, 0.04091952]) + +.. code-block:: text + array([ 0.07351364, 0.00475253, 0.09351596]) HSV Colourspace @@ -740,7 +987,10 @@ HSV Colourspace .. code-block:: python - >>> colour.RGB_to_HSV([0.45620519, 0.03081071, 0.04091952]) + colour.RGB_to_HSV([0.45620519, 0.03081071, 0.04091952]) + +.. code-block:: text + array([ 0.99603944, 0.93246304, 0.45620519]) IHLS Colourspace @@ -748,7 +998,10 @@ IHLS Colourspace .. code-block:: python - >>> colour.RGB_to_IHLS([0.45620519, 0.03081071, 0.04091952]) + colour.RGB_to_IHLS([0.45620519, 0.03081071, 0.04091952]) + +.. code-block:: text + array([ 6.26236117, 0.12197943, 0.42539448]) Prismatic Colourspace @@ -756,7 +1009,10 @@ Prismatic Colourspace .. code-block:: python - >>> colour.RGB_to_Prismatic([0.25, 0.50, 0.75]) + colour.RGB_to_Prismatic([0.25, 0.50, 0.75]) + +.. code-block:: text + array([ 0.75 , 0.16666667, 0.33333333, 0.5 ]) RGB Colourspace and Transformations @@ -764,22 +1020,25 @@ RGB Colourspace and Transformations .. code-block:: python - >>> 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, - ... ) + 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, + ) + +.. code-block:: text + array([ 0.45595571, 0.03039702, 0.04087245]) RGB Colourspace Derivation @@ -787,9 +1046,12 @@ RGB Colourspace Derivation .. code-block:: python - >>> p = [0.73470, 0.26530, 0.00000, 1.00000, 0.00010, -0.07700] - >>> w = [0.32168, 0.33767] - >>> colour.normalised_primary_matrix(p, w) + p = [0.73470, 0.26530, 0.00000, 1.00000, 0.00010, -0.07700] + w = [0.32168, 0.33767] + colour.normalised_primary_matrix(p, w) + +.. code-block:: text + array([[ 9.52552396e-01, 0.00000000e+00, 9.36786317e-05], [ 3.43966450e-01, 7.28166097e-01, -7.21325464e-02], [ 0.00000000e+00, 0.00000000e+00, 1.00882518e+00]]) @@ -799,7 +1061,10 @@ RGB Colourspaces .. code-block:: python - >>> sorted(colour.RGB_COLOURSPACES) + sorted(colour.RGB_COLOURSPACES) + +.. code-block:: text + ['ACES2065-1', 'ACEScc', 'ACEScct', @@ -875,7 +1140,10 @@ OETFs .. code-block:: python - >>> sorted(colour.OETFS) + sorted(colour.OETFS) + +.. code-block:: text + ['ARIB STD-B67', 'Blackmagic Film Generation 5', 'DaVinci Intermediate', @@ -895,7 +1163,10 @@ EOTFs .. code-block:: python - >>> sorted(colour.EOTFS) + sorted(colour.EOTFS) + +.. code-block:: text + ['DCDM', 'DICOM GSDF', 'ITU-R BT.1886', @@ -911,7 +1182,10 @@ OOTFs .. code-block:: python - >>> sorted(colour.OOTFS) + sorted(colour.OOTFS) + +.. code-block:: text + ['ITU-R BT.2100 HLG', 'ITU-R BT.2100 PQ'] @@ -920,7 +1194,10 @@ Log Encoding / Decoding .. code-block:: python - >>> sorted(colour.LOG_ENCODINGS) + sorted(colour.LOG_ENCODINGS) + +.. code-block:: text + ['ACEScc', 'ACEScct', 'ACESproxy', @@ -957,7 +1234,10 @@ CCTFs Encoding / Decoding .. code-block:: python - >>> sorted(colour.CCTF_ENCODINGS) + sorted(colour.CCTF_ENCODINGS) + +.. code-block:: text + ['ACEScc', 'ACEScct', 'ACESproxy', @@ -1010,10 +1290,18 @@ Recommendation ITU-T H.273 Code points for Video Signal Type Identification .. code-block:: python - >>> colour.COLOUR_PRIMARIES_ITUTH273.keys() + colour.COLOUR_PRIMARIES_ITUTH273.keys() + +.. code-block:: text + dict_keys([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 22, 23]) - >>> colour.COLOUR_PRIMARIES_ITUTH273.keys() - >>> description = colour.models.describe_video_signal_colour_primaries(1) + +.. code-block:: python + + colour.models.describe_video_signal_colour_primaries(1) + +.. code-block:: text + =============================================================================== * * * Colour Primaries: 1 * @@ -1033,11 +1321,21 @@ Recommendation ITU-T H.273 Code points for Video Signal Type Identification * FFmpeg Constants : ['AVCOL_PRI_BT709', 'BT709'] * * * =============================================================================== - >>> colour.TRANSFER_CHARACTERISTICS_ITUTH273.keys() + +.. code-block:: python + + colour.TRANSFER_CHARACTERISTICS_ITUTH273.keys() + +.. code-block:: text + dict_keys([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) - >>> description = ( - ... colour.models.describe_video_signal_transfer_characteristics(1) - ... ) + +.. code-block:: python + + colour.models.describe_video_signal_transfer_characteristics(1) + +.. code-block:: text + =============================================================================== * * * Transfer Characteristics: 1 * @@ -1047,11 +1345,21 @@ Recommendation ITU-T H.273 Code points for Video Signal Type Identification * FFmpeg Constants : ['AVCOL_TRC_BT709', 'BT709'] * * * =============================================================================== - >>> colour.MATRIX_COEFFICIENTS_ITUTH273.keys() + +.. code-block:: python + + colour.MATRIX_COEFFICIENTS_ITUTH273.keys() + +.. code-block:: text + dict_keys([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) - >>> description = colour.models.describe_video_signal_matrix_coefficients( - ... 1 - ... ) + +.. code-block:: python + + colour.models.describe_video_signal_matrix_coefficients(1) + +.. code-block:: text + =============================================================================== * * * Matrix Coefficients: 1 * @@ -1070,9 +1378,18 @@ Munsell Value .. code-block:: python - >>> colour.munsell_value(12.23634268) + colour.munsell_value(12.23634268) + +.. code-block:: text + 4.0824437076525664 - >>> sorted(colour.MUNSELL_VALUE_METHODS) + +.. code-block:: python + + sorted(colour.MUNSELL_VALUE_METHODS) + +.. code-block:: text + ['ASTM D1535', 'Ladd 1955', 'McCamy 1987', @@ -1087,9 +1404,18 @@ Munsell Colour .. code-block:: python - >>> colour.xyY_to_munsell_colour([0.38736945, 0.35751656, 0.59362000]) + colour.xyY_to_munsell_colour([0.38736945, 0.35751656, 0.59362000]) + +.. code-block:: text + '4.2YR 8.1/5.3' - >>> colour.munsell_colour_to_xyY("4.2YR 8.1/5.3") + +.. code-block:: python + + colour.munsell_colour_to_xyY("4.2YR 8.1/5.3") + +.. code-block:: text + array([ 0.38736945, 0.35751656, 0.59362 ]) Optical Phenomena - ``colour.phenomena`` @@ -1097,7 +1423,10 @@ Optical Phenomena - ``colour.phenomena`` .. code-block:: python - >>> colour.rayleigh_scattering_sd() + colour.rayleigh_scattering_sd() + +.. code-block:: text + SpectralDistribution([[ 3.60000000e+02, 5.99101337e-01], [ 3.61000000e+02, 5.92170690e-01], [ 3.62000000e+02, 5.85341006e-01], @@ -1118,9 +1447,18 @@ Colour Fidelity Index .. code-block:: python - >>> colour.colour_fidelity_index(colour.SDS_ILLUMINANTS["FL2"]) + colour.colour_fidelity_index(colour.SDS_ILLUMINANTS["FL2"]) + +.. code-block:: text + 70.120825477833037 - >>> sorted(colour.COLOUR_FIDELITY_INDEX_METHODS) + +.. code-block:: python + + sorted(colour.COLOUR_FIDELITY_INDEX_METHODS) + +.. code-block:: text + ['ANSI/IES TM-30-18', 'CIE 2017'] Colour Quality Scale @@ -1128,9 +1466,18 @@ Colour Quality Scale .. code-block:: python - >>> colour.colour_quality_scale(colour.SDS_ILLUMINANTS["FL2"]) + colour.colour_quality_scale(colour.SDS_ILLUMINANTS["FL2"]) + +.. code-block:: text + 64.111703163816699 - >>> sorted(colour.COLOUR_QUALITY_SCALE_METHODS) + +.. code-block:: python + + sorted(colour.COLOUR_QUALITY_SCALE_METHODS) + +.. code-block:: text + ['NIST CQS 7.4', 'NIST CQS 9.0'] Colour Rendering Index @@ -1138,7 +1485,10 @@ Colour Rendering Index .. code-block:: python - >>> colour.colour_rendering_index(colour.SDS_ILLUMINANTS["FL2"]) + colour.colour_rendering_index(colour.SDS_ILLUMINANTS["FL2"]) + +.. code-block:: text + 64.233724121664807 Academy Spectral Similarity Index (SSI) @@ -1146,9 +1496,12 @@ Academy Spectral Similarity Index (SSI) .. code-block:: python - >>> colour.spectral_similarity_index( - ... colour.SDS_ILLUMINANTS["C"], colour.SDS_ILLUMINANTS["D65"] - ... ) + colour.spectral_similarity_index( + colour.SDS_ILLUMINANTS["C"], colour.SDS_ILLUMINANTS["D65"] + ) + +.. code-block:: text + 94.0 Spectral Up-Sampling & Recovery - ``colour.recovery`` @@ -1159,7 +1512,10 @@ Reflectance Recovery .. code-block:: python - >>> colour.XYZ_to_sd([0.20654008, 0.12197225, 0.05136952]) + colour.XYZ_to_sd([0.20654008, 0.12197225, 0.05136952]) + +.. code-block:: text + SpectralDistribution([[ 3.60000000e+02, 8.40144095e-02], [ 3.65000000e+02, 8.41264236e-02], [ 3.70000000e+02, 8.40057597e-02], @@ -1172,40 +1528,48 @@ Reflectance Recovery Extrapolator, {'method': 'Constant', 'left': None, 'right': None}) - >>> sorted(colour.REFLECTANCE_RECOVERY_METHODS) +.. code-block:: python + + sorted(colour.REFLECTANCE_RECOVERY_METHODS) + +.. code-block:: text + ['Jakob 2019', 'Mallett 2019', 'Meng 2015', 'Otsu 2018', 'Smits 1999'] 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.characterisation.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, - ... ) + 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.characterisation.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, + ) + +.. code-block:: text + RGB_CameraSensitivities([[ 4.00000000e+02, 7.22815777e-03, 9.22506480e-03, -9.88368972e-03], [ 4.10000000e+02, -8.50457609e-03, 1.12777480e-02, @@ -1230,11 +1594,26 @@ Correlated Colour Temperature Computation Methods - ``colour.temperature`` .. code-block:: python - >>> colour.uv_to_CCT([0.1978, 0.3122]) + colour.uv_to_CCT([0.1978, 0.3122]) + +.. code-block:: text + array([ 6.50751282e+03, 3.22335875e-03]) - >>> sorted(colour.UV_TO_CCT_METHODS) + +.. code-block:: python + + sorted(colour.UV_TO_CCT_METHODS) + +.. code-block:: text + ['Krystek 1985', 'Ohno 2013', 'Planck 1900', 'Robertson 1968', 'ohno2013', 'robertson1968'] - >>> sorted(colour.XY_TO_CCT_METHODS) + +.. code-block:: python + + sorted(colour.XY_TO_CCT_METHODS) + +.. code-block:: text + ['CIE Illuminant D Series', 'Hernandez 1999', 'Kang 2002', @@ -1249,9 +1628,10 @@ Colour Volume - ``colour.volume`` .. code-block:: python - >>> colour.RGB_colourspace_volume_MonteCarlo( - ... colour.RGB_COLOURSPACE_RGB["sRGB"] - ... ) + colour.RGB_colourspace_volume_MonteCarlo(colour.RGB_COLOURSPACE_RGB["sRGB"]) + +.. code-block:: text + 821958.30000000005 Geometry Primitives Generation - ``colour.geometry`` @@ -1259,8 +1639,11 @@ Geometry Primitives Generation - ``colour.geometry`` .. code-block:: python - >>> colour.primitive("Grid") - (array([ ([-0.5, 0.5, 0. ], [ 0., 1.], [ 0., 0., 1.], [ 0., 1., 0., 1.]), + colour.primitive("Grid") + +.. code-block:: text + + (array([ ([-0.5, 0.5, 0. ], [ 0., 1.], [ 0., 0., 1.], [ 0., 1., 0., 1.]), ([ 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.])], @@ -1269,14 +1652,26 @@ Geometry Primitives Generation - ``colour.geometry`` [2, 3], [3, 1], [1, 0]], dtype=uint32)) - >>> sorted(colour.PRIMITIVE_METHODS) + +.. code-block:: python + + sorted(colour.PRIMITIVE_METHODS) + +.. code-block:: text + ['Cube', 'Grid'] - >>> colour.primitive_vertices("Quad MPL") + +.. code-block:: python + + colour.primitive_vertices("Quad MPL") + +.. code-block:: text + array([[ 0., 0., 0.], [ 1., 0., 0.], [ 1., 1., 0.], [ 0., 1., 0.]]) - >>> sorted(colour.PRIMITIVE_VERTICES_METHODS) + sorted(colour.PRIMITIVE_VERTICES_METHODS) ['Cube MPL', 'Grid MPL', 'Quad MPL', 'Sphere'] Plotting - ``colour.plotting`` @@ -1286,15 +1681,16 @@ Most of the objects are available from the ``colour.plotting`` namespace: .. code-block:: python - >>> from colour.plotting import * - >>> colour_style() + from colour.plotting import * + + colour_style() Visible Spectrum **************** .. code-block:: python - >>> plot_visible_spectrum("CIE 1931 2 Degree Standard Observer") + plot_visible_spectrum("CIE 1931 2 Degree Standard Observer") .. image:: _static/Examples_Plotting_Visible_Spectrum.png @@ -1303,7 +1699,7 @@ Spectral Distribution .. code-block:: python - >>> plot_single_illuminant_sd("FL1") + plot_single_illuminant_sd("FL1") .. image:: _static/Examples_Plotting_Illuminant_F1_SD.png @@ -1312,17 +1708,17 @@ Blackbody .. code-block:: python - >>> blackbody_sds = [ - ... colour.sd_blackbody(i, colour.SpectralShape(0, 10000, 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), - ... ) + blackbody_sds = [ + colour.sd_blackbody(i, colour.SpectralShape(0, 10000, 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), + ) .. image:: _static/Examples_Plotting_Blackbodies.png Colour Matching Functions @@ -1330,11 +1726,11 @@ Colour Matching Functions .. code-block:: python - >>> plot_single_cmfs( - ... "Stockman & Sharpe 2 Degree Cone Fundamentals", - ... y_label="Sensitivity", - ... bounding_box=(390, 870, 0, 1.1), - ... ) + plot_single_cmfs( + "Stockman & Sharpe 2 Degree Cone Fundamentals", + y_label="Sensitivity", + bounding_box=(390, 870, 0, 1.1), + ) .. image:: _static/Examples_Plotting_Cone_Fundamentals.png @@ -1343,20 +1739,20 @@ Luminous Efficiency .. code-block:: python - >>> sd_mesopic_luminous_efficiency_function = ( - ... colour.sd_mesopic_luminous_efficiency_function(0.2) - ... ) - >>> plot_multi_sds( - ... ( - ... sd_mesopic_luminous_efficiency_function, - ... colour.PHOTOPIC_LEFS["CIE 1924 Photopic Standard Observer"], - ... colour.SCOTOPIC_LEFS["CIE 1951 Scotopic Standard Observer"], - ... ), - ... y_label="Luminous Efficiency", - ... legend_location="upper right", - ... y_tighten=True, - ... margins=(0, 0, 0, 0.1), - ... ) + sd_mesopic_luminous_efficiency_function = ( + colour.sd_mesopic_luminous_efficiency_function(0.2) + ) + plot_multi_sds( + ( + sd_mesopic_luminous_efficiency_function, + colour.PHOTOPIC_LEFS["CIE 1924 Photopic Standard Observer"], + colour.SCOTOPIC_LEFS["CIE 1951 Scotopic Standard Observer"], + ), + y_label="Luminous Efficiency", + legend_location="upper right", + y_tighten=True, + margins=(0, 0, 0, 0.1), + ) .. image:: _static/Examples_Plotting_Luminous_Efficiency.png @@ -1365,29 +1761,26 @@ Colour Checker .. code-block:: python - >>> from colour.characterisation.dataset.colour_checkers.sds import ( - ... COLOURCHECKER_INDEXES_TO_NAMES_MAPPING, - ... ) - >>> plot_multi_sds( - ... [ - ... colour.SDS_COLOURCHECKERS["BabelColor Average"][value] - ... for key, value in sorted( - ... COLOURCHECKER_INDEXES_TO_NAMES_MAPPING.items() - ... ) - ... ], - ... plot_kwargs={ - ... "use_sd_colours": True, - ... }, - ... title=("BabelColor Average - " "Spectral Distributions"), - ... ) + from colour.characterisation.dataset.colour_checkers.sds import ( + COLOURCHECKER_INDEXES_TO_NAMES_MAPPING, + ) + + plot_multi_sds( + [ + colour.SDS_COLOURCHECKERS["BabelColor Average"][value] + for key, value in sorted(COLOURCHECKER_INDEXES_TO_NAMES_MAPPING.items()) + ], + plot_kwargs={ + "use_sd_colours": True, + }, + title=("BabelColor Average - " "Spectral Distributions"), + ) .. image:: _static/Examples_Plotting_BabelColor_Average.png .. code-block:: python - >>> plot_single_colour_checker( - ... "ColorChecker 2005", text_kwargs={"visible": False} - ... ) + plot_single_colour_checker("ColorChecker 2005", text_kwargs={"visible": False}) .. image:: _static/Examples_Plotting_ColorChecker_2005.png @@ -1396,9 +1789,7 @@ Chromaticities Prediction .. code-block:: python - >>> plot_corresponding_chromaticities_prediction( - ... 2, "Von Kries", "Bianco 2010" - ... ) + plot_corresponding_chromaticities_prediction(2, "Von Kries", "Bianco 2010") .. image:: _static/Examples_Plotting_Chromaticities_Prediction.png @@ -1407,14 +1798,15 @@ Chromaticities .. code-block:: python - >>> import numpy as np - >>> RGB = np.random.random((32, 32, 3)) - >>> plot_RGB_chromaticities_in_chromaticity_diagram_CIE1931( - ... RGB, - ... "ITU-R BT.709", - ... colourspaces=["ACEScg", "S-Gamut"], - ... show_pointer_gamut=True, - ... ) + import numpy as np + + RGB = np.random.random((32, 32, 3)) + plot_RGB_chromaticities_in_chromaticity_diagram_CIE1931( + RGB, + "ITU-R BT.709", + colourspaces=["ACEScg", "S-Gamut"], + show_pointer_gamut=True, + ) .. image:: _static/Examples_Plotting_Chromaticities_CIE_1931_Chromaticity_Diagram.png @@ -1423,9 +1815,7 @@ Colour Rendering Index .. code-block:: python - >>> plot_single_sd_colour_rendering_index_bars( - ... colour.SDS_ILLUMINANTS["FL2"] - ... ) + plot_single_sd_colour_rendering_index_bars(colour.SDS_ILLUMINANTS["FL2"]) .. image:: _static/Examples_Plotting_CRI.png @@ -1434,7 +1824,7 @@ ANSI/IES TM-30-18 Colour Rendition Report .. code-block:: python - >>> plot_single_sd_colour_rendition_report(colour.SDS_ILLUMINANTS["FL2"]) + plot_single_sd_colour_rendition_report(colour.SDS_ILLUMINANTS["FL2"]) .. image:: _static/Examples_Plotting_Colour_Rendition_Report.png @@ -1443,17 +1833,13 @@ Gamut Section .. code-block:: python - >>> plot_visible_spectrum_section( - ... section_colours="RGB", section_opacity=0.15 - ... ) + plot_visible_spectrum_section(section_colours="RGB", section_opacity=0.15) .. image:: _static/Examples_Plotting_Plot_Visible_Spectrum_Section.png .. code-block:: python - >>> plot_RGB_colourspace_section( - ... "sRGB", section_colours="RGB", section_opacity=0.15 - ... ) + plot_RGB_colourspace_section("sRGB", section_colours="RGB", section_opacity=0.15) .. image:: _static/Examples_Plotting_Plot_RGB_Colourspace_Section.png @@ -1462,9 +1848,7 @@ Colour Temperature .. code-block:: python - >>> plot_planckian_locus_in_chromaticity_diagram_CIE1960UCS( - ... ["A", "B", "C"] - ... ) + plot_planckian_locus_in_chromaticity_diagram_CIE1960UCS(["A", "B", "C"]) .. image:: _static/Examples_Plotting_CCT_CIE_1960_UCS_Chromaticity_Diagram.png diff --git a/docs/tutorial.rst b/docs/tutorial.rst index 2a9a044a9..9fb7363c2 100644 --- a/docs/tutorial.rst +++ b/docs/tutorial.rst @@ -360,14 +360,14 @@ The codebase is documented and most docstrings have usage examples: Examples -------- - >>> from colour import MSDS_CMFS, SPECTRAL_SHAPE_DEFAULT - >>> cmfs = ( - ... MSDS_CMFS["CIE 1931 2 Degree Standard Observer"] - ... .copy() - ... .align(SPECTRAL_SHAPE_DEFAULT) - ... ) - >>> CCT_D_uv = np.array([6507.4342201047066, 0.003223690901513]) - >>> CCT_to_uv_Ohno2013(CCT_D_uv, cmfs) # doctest: +ELLIPSIS + from colour import MSDS_CMFS, SPECTRAL_SHAPE_DEFAULT + cmfs = ( + MSDS_CMFS["CIE 1931 2 Degree Standard Observer"] + .copy() + .align(SPECTRAL_SHAPE_DEFAULT) + ) + CCT_D_uv = np.array([6507.4342201047066, 0.003223690901513]) + CCT_to_uv_Ohno2013(CCT_D_uv, cmfs) # doctest: +ELLIPSIS array([ 0.1977999..., 0.3122004...]) At the core of **Colour** is the ``colour.colorimetry`` sub-package, it defines @@ -1054,13 +1054,7 @@ operations like *addition*, *subtraction*, *multiplication*, *division* or print((sd.copy() + 1).values) print((sd.copy() * 2).values) print((sd * [0.35, 1.55, 0.75, 2.55, 0.95, 0.65, 0.15]).values) - print( - ( - sd - * colour.sd_constant(2, sd.shape) - * colour.sd_constant(3, sd.shape) - ).values - ) + print((sd * colour.sd_constant(2, sd.shape) * colour.sd_constant(3, sd.shape)).values) .. code-block:: text @@ -1215,9 +1209,7 @@ values in order to display them on screen: .. code:: python # Plotting the *sRGB* colourspace colour of the *Sample* spectral distribution. - plot_single_colour_swatch( - ColourSwatch(RGB, "Sample"), text_kwargs={"size": "x-large"} - ) + plot_single_colour_swatch(ColourSwatch(RGB, "Sample"), text_kwargs={"size": "x-large"}) .. image:: _static/Tutorial_Sample_Swatch.png