Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Colour 0.3.16 - Current Changes

Colour 0.3.16 - Alpha Milestone

The colour.SpectralDistribution.interpolate and colour.MultiSpectralDistributions.interpolate now honour instantiation time interpolation class instead of blindly applying CIE 167:2005 recommendation, this introduces minor numerical changes.

As part of GSoC 2020, Omar Wagih (@OmarWagih1) implemented various optimizations across the board.

Features

colour.algebra

  • Add colour.algebra.smoothstep definition. (@KelSolaar)

colour.characterisation

  • Support for ACES Input Device Transform (IDT) generation: The implementation follows to some extent RAW to ACES v1 and P-2013-001. (@KelSolaar)

Usage is simple and as follows:

>>> sensitivities = colour.CAMERA_RGB_SPECTRAL_SENSITIVITIES['Nikon 5100 (NPL)']
>>> illuminant = colour.ILLUMINANT_SDS['D55']
>>> colour.idt_matrix(sensitivities, illuminant)
array([[ 0.46579991,  0.13409239,  0.01935141],
       [ 0.01786094,  0.77557292, -0.16775555],
       [ 0.03458652, -0.16152926,  0.74270359]])

The following ISO 7589 and 6728 spectral data has been added: (@KelSolaar)

  • ISO 6728 Standard Lens

  • ISO 7589 Diffuser

  • New attributes colour.LENS_SDS containing the ISO 6728 Standard Lens and colour.FILTER_SDScontaining the ISO 7589 Diffuser have been added.

colour.colorimetry

The following ISO 7589 illuminants have been added: (@KelSolaar)

  • ISO 7589 Photographic Daylight

  • ISO 7589 Sensitometric Daylight

  • ISO 7589 Studio Tungsten

  • ISO 7589 Sensitometric Studio Tungsten

  • ISO 7589 Photoflood

  • ISO 7589 Sensitometric Photoflood

  • ISO 7589 Sensitometric Printer

  • Add colour.msds_constant, colour.msds_zeros and colour.msds_ones definitions. (@KelSolaar)

colour.geometry

The geometry primitives generation code has been consolidated into a new colour.geometry sub-package. The following objects are available: (@KelSolaar)

Primitives

  • colour.geometry.primitive_grid
  • colour.geometry.primitive_cube
  • colour.PRIMITIVE_METHODS
  • colour.primitive

Primitives Vertices

  • colour.geometry.primitive_vertices_quad_mpl (for Matplotlib usage only)
  • colour.geometry.primitive_vertices_grid_mpl (for Matplotlib usage only)
  • colour.geometry.primitive_vertices_cube_mpl (for Matplotlib usage only)
  • colour.geometry.primitive_vertices_sphere
  • colour.PRIMITIVE_VERTICES_METHODS
  • colour.primitive_vertices

colour.models

  • Add colour.models.log_encoding_Log2 and colour.models.log_decoding_Log2 log encoding and decoding definitions. (@njwardhan, @KelSolaar)
  • Add colour.models.exponent_function_basic and colour.models.exponent_function_monitor_curve. (@njwardhan)

colour.utilities

  • Float precision can be set globally with the colour.utilities.set_float_precision definition and the COLOUR_SCIENCE__FLOAT_PRECISION environment variable. It will affect almost the entire API and lead to increase performance at the price of broken capabilities. (@KelSolaar)
  • It is now possible to pass an axis argument to the colour.utilities.metric_mse and colour.utilities.metric_psnr definitions. (@KelSolaar)
  • Add colour.utilities.LazyCaseInsensitiveMapping class for lazily loading slow and heavy datasets. (@KelSolaar)

Fixes

colour.characterisation

  • The Finlayson, MacKiewicz and Hurlbert (2015) colour correction method was defective when root-polynomial expansion is in use. (@ChunHsinWang, @KelSolaar)

colour.colorimetry

  • The colour.SpectralDistribution.align, colour.MultiSpectralDistributions.align, colour.SpectralDistribution.interpolate and colour.MultiSpectralDistributions.interpolate methods did not honour the instantiation time interpolation class and were forcibly using either the colour.SpragueInterpolator or colour.CubicSplineInterpolator classes unless an interpolator argument was passed. This behaviour was not desirable and was changed so that if the instantiation time interpolation class is not one of colour.SpragueInterpolator or colour.CubicSplineInterpolator, then, it will be used instead and thus it will take precedence over the CIE 167:2005 recommendation. (@KelSolaar)

The immediate consequence is small numerical changes to various spectral computations, for example:

     >>> illuminant = ILLUMINANTS_SDS['D65']
     >>> sd_to_XYZ_tristimulus_weighting_factors_ASTME308(
     ...     sd, cmfs, illuminant)  # doctest: +ELLIPSIS
-    array([ 10.8402899...,   9.6843539...,   6.2160858...])
+    array([ 10.8405832...,   9.6844909...,   6.2155622...])
     >>> from colour import COLOURCHECKERS_SDS
     >>> sd = COLOURCHECKERS_SDS['ColorChecker N Ohta']['dark skin']
     >>> sd_to_aces_relative_exposure_values(sd)  # doctest: +ELLIPSIS
-    array([ 0.1171785...,  0.0866347...,  0.0589707...])
+    array([ 0.1171814...,  0.0866360...,  0.0589726...])

Colour quality metrics are affected a bit more severely:

```diff
     >>> from colour import ILLUMINANTS_SDS
     >>> sd = ILLUMINANTS_SDS['FL2']
     >>> colour_rendering_index(sd)  # doctest: +ELLIPSIS
-    64.1515202...
+    64.2337241...
     >>> from colour import ILLUMINANTS_SDS
     >>> sd = ILLUMINANTS_SDS['FL2']
     >>> colour_quality_scale(sd)  # doctest: +ELLIPSIS
-    64.0172835...
+    64.1117031...

CIE Illuminant D Series D60 chromaticity have also been modified:

-    'D60': np.array([0.321626242047397, 0.337736995955436]),
+    'D60': np.array([0.321616709705268, 0.337619916550817]),

See https://github.com/colour-science/colour/issues/566 for more details.

colour.models

  • colour.OETF_INVERSES ITU-R BT.2100 HLG key was incorrectly named ITU-R BT.2100 HLD. (@jchwei)

colour.plotting

  • The colour.plotting.diagrams.plot_chromaticity_diagram definition was not passing anymore the CMFS to the underlying colour.plotting.diagrams.plot_spectral_locus and colour.plotting.diagrams.plot_chromaticity_diagram_colours definitions. (@KelSolaar, @sobotka)

colour.utilities

  • The colour.utilities.filter_warnings definition was not behaving properly and has been fixed. (@KelSolaar)

Examples

  • colour.plotting.plot_RGB_colourspaces_gamuts definition was using an incorrect style argument. (@sianyi)

Changes

colour.algebra

  • The colour.algebra.cartesian_to_spherical and colour.algebra.spherical_to_cartesian definitions now use the ISO 31-11 parameterisation for consistency.

  • colour.KernelInterpolator.__init__: (@KelSolaar)

    • Signature: KernelInterpolator(self, x, y, window=3, kernel=kernel_lanczos, kernel_kwargs=None, padding_kwargs=None, dtype=DEFAULT_FLOAT_DTYPE)
  • colour.KernelInterpolator.kernel_args: (@KelSolaar)

    • Name: KernelInterpolator.kernel_kwargs
  • colour.KernelInterpolator.padding_args: (@KelSolaar)

    • Name: KernelInterpolator.padding_kwargs

colour.colorimetry

  • colour.sd_blackbody definition now returns values in W/sr/m^2/nm instead of W/sr/m^2/m. See #559 for more background information. (@KelSolaar, @Wagyx, @MichaelMauderer) colour.colorimetry

  • colour.colorimetry.sd_CIE_illuminant_D_series definition return a spectral distribution whose name includes the used chromaticity coordinates and whose interpolator is instantiated from colour.algebra.LinearInterpolator. (@KelSolaar)

  • colour.ILLUMINANTS_SDS: (@KelSolaar)

    • Name: colour.ILLUMINANT_SDS
  • colour.LIGHT_SOURCES_SDS: (@KelSolaar)

    • Name: colour.LIGHT_SOURCE_SDS
  • colour.STANDARD_OBSERVERS_CMFS: (@KelSolaar)

    • Name: colour.STANDARD_OBSERVER_CMFS
  • colour.colorimetry.D_ILLUMINANTS_S_SDS: (@KelSolaar)

    • Name: colour.colorimetry.D_ILLUMINANT_S_SDS
  • colour.SpectralDistribution.extrapolate: (@KelSolaar)

    • Signature: extrapolate(self, shape, extrapolator=None, extrapolator_kwargs=None, **kwargs)
  • colour.SpectralDistribution.interpolate: (@KelSolaar)

    • Signature: interpolate(self, shape, interpolator=None, interpolator_kwargs=None, **kwargs)
  • colour.SpectralDistribution.align: (@KelSolaar)

    • Signature: align(self, shape, interpolator=None, interpolator_kwargs=None, extrapolator=None, extrapolator_kwargs=None, **kwargs)
  • colour.MultiSpectralDistributions.extrapolate: (@KelSolaar)

    • Signature: extrapolate(self, shape, extrapolator=None, extrapolator_kwargs=None, **kwargs)
  • colour.MultiSpectralDistributions.interpolate: (@KelSolaar)

    • Signature: interpolate(self, shape, interpolator=None, interpolator_kwargs=None, **kwargs)
  • colour.MultiSpectralDistributions.align: (@KelSolaar)

    • Signature: align(self, shape, interpolator=None, interpolator_kwargs=None, extrapolator=None, extrapolator_kwargs=None, **kwargs)

colour.characterisation

  • colour.CAMERAS_RGB_SPECTRAL_SENSITIVITIES: (@KelSolaar)
    • Name: colour.CAMERA_RGB_SPECTRAL_SENSITIVITIES
  • colour.COLOURCHECKERS_SDS: (@KelSolaar)
    • Name: colour.COLOURCHECKER_SDS
  • colour.DISPLAYS_RGB_PRIMARIES: (@KelSolaar)
    • Name: colour.DISPLAY_RGB_PRIMARIES

colour.continuous

  • colour.continuous.Signal.interpolator_args: (@KelSolaar)
    • Name: colour.continuous.Signal.interpolator_kwargs
  • colour.continuous.Signal.extrapolator_args: (@KelSolaar)
    • Name: colour.continuous.Signal.extrapolator_kwargs
  • colour.continuous.MultiSignals.interpolator_args: (@KelSolaar)
    • Name: colour.continuous.MultiSignals.interpolator_kwargs
  • colour.continuous.MultiSignals.extrapolator_args: (@KelSolaar)
    • Name: colour.continuous.MultiSignals.extrapolator_kwargs

colour.corresponding

  • colour.BRENEMAN_EXPERIMENTS_PRIMARIES_CHROMATICITIES: (@KelSolaar)
    • Name: colour.BRENEMAN_EXPERIMENT_PRIMARIES_CHROMATICITIES

colour.io

  • colour.LUT1D.apply: (@KelSolaar)
    • Signature: apply(self, RGB, interpolator=LinearInterpolator, interpolator_kwargs=None, **kwargs)
  • colour.LUT3x1D.apply: (@KelSolaar)
    • Signature: apply(self, RGB, interpolator=LinearInterpolator, interpolator_kwargs=None, **kwargs)
  • colour.LUT3D.apply: (@KelSolaar)
    • Signature: apply(self, RGB, interpolator=table_interpolation_trilinear, interpolator_kwargs=None, **kwargs)
  • colour.LutSequence.apply: (@KelSolaar)
    • Signature: apply(self, RGB, interpolator_1D=LinearInterpolator, interpolator_1D_kwargs=None, interpolator_3D=table_interpolation_trilinear, interpolator_3D_kwargs=None, **kwargs)

colour.models

  • colour.models.ACES_RICD: (@KelSolaar)

    • Name: colour.characterisation.ACES_RICD
  • colour.OSA_UCS_to_XYZ: (@KelSolaar)

    • Signature: OSA_UCS_to_XYZ(Ljg, optimisation_kwargs=None, **kwargs)
  • colour.models.oetf_BT2020: (@KelSolaar)

    • Name: colour.models.eotf_inverse_BT2020

colour.notation

  • The colour.notation.RGB_to_HEX definition will now clip negative values and the whole input array will be normalised to the maximum value if values over 1 are encountered. (@KelSolaar)

colour.plotting

  • colour.plotting.plot_multi_colour_swatches: (@KelSolaar)

    • Signature: plot_multi_colour_swatches(colour_swatches, width=1, height=1, spacing=0, columns=None, direction='+y', text_kwargs=None, background_colour=(1.0, 1.0, 1.0), compare_swatches=None, **kwargs)
  • colour.plotting.plot_image: (@KelSolaar)

    • Signature: plot_image(image, imshow_kwargs=None, text_kwargs=None, **kwargs)
  • colour.plotting.plot_sds_in_chromaticity_diagram_CIE1931: (@KelSolaar)

    • Signature: plot_sds_in_chromaticity_diagram_CIE1931(sds, cmfs='CIE 1931 2 Degree Standard Observer', annotate_kwargs=None, chromaticity_diagram_callable_CIE1931=plot_chromaticity_diagram_CIE1931, **kwargs)
  • colour.plotting.plot_sds_in_chromaticity_diagram_CIE1960UCS: (@KelSolaar)

    • Signature: plot_sds_in_chromaticity_diagram_CIE1960UCS(sds, cmfs='CIE 1931 2 Degree Standard Observer', annotate_kwargs=None, chromaticity_diagram_callable_CIE1960UCS=plot_chromaticity_diagram_CIE1960UCS, **kwargs)
  • colour.plotting.plot_sds_in_chromaticity_diagram_CIE1976UCS: (@KelSolaar)

    • Signature: plot_sds_in_chromaticity_diagram_CIE1976UCS(sds, cmfs='CIE 1931 2 Degree Standard Observer', annotate_kwargs=None, chromaticity_diagram_callable_CIE1976UCS=plot_chromaticity_diagram_CIE1976UCS, **kwargs)
  • colour.plotting.plot_RGB_chromaticities_in_chromaticity_diagram_CIE1931: (@KelSolaar)

    • Signature: plot_RGB_chromaticities_in_chromaticity_diagram_CIE1931(RGB, colourspace='sRGB', chromaticity_diagram_callable_CIE1931=plot_RGB_colourspaces_in_chromaticity_diagram_CIE1931, scatter_kwargs=None, **kwargs)
  • colour.plotting.plot_RGB_chromaticities_in_chromaticity_diagram_CIE1960UCS: (@KelSolaar)

    • Signature: plot_RGB_chromaticities_in_chromaticity_diagram_CIE1960UCS(RGB, colourspace='sRGB', chromaticity_diagram_callable_CIE1960UCS=plot_RGB_colourspaces_in_chromaticity_diagram_CIE1960UCS, scatter_kwargs=None, **kwargs)
  • colour.plotting.plot_RGB_chromaticities_in_chromaticity_diagram_CIE1976UCS: (@KelSolaar)

    • Signature: plot_RGB_chromaticities_in_chromaticity_diagram_CIE1976UCS(RGB, colourspace='sRGB', chromaticity_diagram_callable_CIE1976UCS=plot_RGB_colourspaces_in_chromaticity_diagram_CIE1976UCS, scatter_kwargs=None, **kwargs)
  • colour.plotting.plot_ellipses_MacAdam1942_in_chromaticity_diagram_CIE1931: (@KelSolaar)

    • Signature: plot_ellipses_MacAdam1942_in_chromaticity_diagram_CIE1931(chromaticity_diagram_callable_CIE1931=plot_chromaticity_diagram_CIE1931, chromaticity_diagram_clipping=False, ellipse_kwargs=None, **kwargs)
  • colour.plotting.plot_ellipses_MacAdam1942_in_chromaticity_diagram_CIE1960UCS: (@KelSolaar)

    • Signature: plot_ellipses_MacAdam1942_in_chromaticity_diagram_CIE1960UCS(chromaticity_diagram_callable_CIE1960UCS=plot_chromaticity_diagram_CIE1960UCS, chromaticity_diagram_clipping=False, ellipse_kwargs=None, **kwargs)
  • colour.plotting.plot_ellipses_MacAdam1942_in_chromaticity_diagram_CIE1976UCS: (@KelSolaar)

    • Signature: plot_ellipses_MacAdam1942_in_chromaticity_diagram_CIE1976UCS(chromaticity_diagram_callable_CIE1976UCS=plot_chromaticity_diagram_CIE1976UCS, chromaticity_diagram_clipping=False, ellipse_kwargs=None, **kwargs)
  • colour.plotting.plot_constant_hue_loci: (@KelSolaar)

    • Signature: plot_constant_hue_loci(data, model, scatter_kwargs=None, **kwargs)
  • colour.plotting.plot_planckian_locus_in_chromaticity_diagram_CIE1931: (@KelSolaar)

    • Signature: plot_planckian_locus_in_chromaticity_diagram_CIE1931(illuminants=None, annotate_kwargs=None, chromaticity_diagram_callable_CIE1931=plot_chromaticity_diagram_CIE1931, planckian_locus_callable_CIE1931=plot_planckian_locus_CIE1931, **kwargs)
  • colour.plotting.plot_planckian_locus_in_chromaticity_diagram_CIE1960UCS: (@KelSolaar)

    • Signature: plot_planckian_locus_in_chromaticity_diagram_CIE1960UCS(illuminants=None, annotate_kwargs=None, chromaticity_diagram_callable_CIE1960UCS=plot_chromaticity_diagram_CIE1960UCS, planckian_locus_callable_CIE1960UCS=plot_planckian_locus_CIE1960UCS, **kwargs)
  • colour.plotting.quad:

    • Name: colour.geometry.primitive_vertices_quad_mpl
    • Signature: primitive_vertices_quad_mpl(width=1, height=1, depth=0, origin=np.array([0, 0]), axis='+z')
  • colour.plotting.grid:

    • Name: colour.geometry.primitive_vertices_grid_mpl
    • Signature: primitive_vertices_grid_mpl(width=1, height=1, depth=0, width_segments=1, height_segments=1, origin=np.array([0, 0]), axis='+z')
  • colour.plotting.cube:

    • Name: colour.geometry.primitive_vertices_cube_mpl
    • Signature: primitive_vertices_cube_mpl(width=1, height=1, depth=1, width_segments=1, height_segments=1, depth_segments=1, origin=np.array([0, 0, 0]), planes=None)

colour.recovery

  • colour.recovery.XYZ_to_sd_Meng2015: (@KelSolaar)
    • Signature: XYZ_to_sd_Meng2015(XYZ, cmfs=STANDARD_OBSERVERS_CMFS['CIE 1931 2 Degree Standard Observer'].copy().align(DEFAULT_SPECTRAL_SHAPE_MENG_2015), illuminant=sd_ones(DEFAULT_SPECTRAL_SHAPE_MENG_2015), optimisation_kwargs=None, **kwargs)

colour.temperature

  • colour.temperature.xy_to_CCT_CIE_D: (@KelSolaar)
    • Signature: xy_to_CCT_CIE_D(xy, optimisation_kwargs=None, **kwargs)
  • colour.temperature.CCT_to_xy_Hernandez1999: (@KelSolaar)
    • Signature: CCT_to_xy_Hernandez1999(CCT, optimisation_kwargs=None, **kwargs)
  • colour.temperature.xy_to_CCT_Kang2002: (@KelSolaar)
    • Signature: xy_to_CCT_Kang2002(xy, optimisation_kwargs=None, **kwargs)
  • colour.temperature.uv_to_CCT_Krystek1985: (@KelSolaar)
    • Signature: uv_to_CCT_Krystek1985(uv, optimisation_kwargs=None, **kwargs)
  • colour.temperature.CCT_to_xy_McCamy1992: (@KelSolaar)
    • Signature: CCT_to_xy_McCamy1992(CCT, optimisation_kwargs=None, **kwargs)

colour.utilities

  • colour.utilities.as_int_array: (@KelSolaar)

    • Signature: as_int_array(a, dtype=None)
  • colour.utilities.as_float_array: (@KelSolaar)

    • Signature: as_float_array(a, dtype=None)
  • colour.utilities.as_int: (@KelSolaar)

    • Signature: as_int(a, dtype=None)
  • colour.utilities.as_float: (@KelSolaar)

    • Signature: as_float(a, dtype=None)
  • colour.utilities.metric_mse: (@KelSolaar)

    • Signature: metric_mse(a, b, axis=None)
  • colour.utilities.metric_psnr: (@KelSolaar)

    • Signature: metric_psnr(a, b, max_a=1, axis=None)
  • colour.utilities.filter_warnings: (@KelSolaar)

    • Signature: filter_warnings(colour_runtime_warnings=None, colour_usage_warnings=None, colour_warnings=None, python_warnings=None)
  • colour.utilities.suppress_warnings: (@KelSolaar)

    • Signature: suppress_warnings(colour_runtime_warnings=None, colour_usage_warnings=None, colour_warnings=None, python_warnings=None)

colour.volume

  • colour.ILLUMINANTS_OPTIMAL_COLOUR_STIMULI: (@KelSolaar)
    • Name: colour.ILLUMINANT_OPTIMAL_COLOUR_STIMULI
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.