colour.recovery.LUT3D_Jakob2019#

class colour.recovery.LUT3D_Jakob2019[source]#

Define a class for working with pre-computed lookup tables for the Jakob and Hanika (2019) spectral upsampling method. It allows significant time savings by performing the expensive numerical optimisation ahead of time and storing the results in a file.

The file format is compatible with the code and *.coeff files in the supplemental material published alongside the article. They are directly available from Colour - Datasets under the record 4050598.

Attributes

  • size

  • lightness_scale

  • coefficients

  • interpolator

Methods

  • __init__()

  • generate()

  • RGB_to_coefficients()

  • RGB_to_sd()

  • read()

  • write()

References

[JH19]

Examples

>>> import os
>>> import colour
>>> from colour import CCS_ILLUMINANTS, SDS_ILLUMINANTS, MSDS_CMFS
>>> from colour.colorimetry import sd_to_XYZ_integration
>>> from colour.models import RGB_COLOURSPACE_sRGB
>>> from colour.utilities import numpy_print_options
>>> cmfs = (
...     MSDS_CMFS["CIE 1931 2 Degree Standard Observer"]
...     .copy()
...     .align(SpectralShape(360, 780, 10))
... )
>>> illuminant = SDS_ILLUMINANTS["D65"].copy().align(cmfs.shape)
>>> LUT = LUT3D_Jakob2019()
>>> LUT.generate(RGB_COLOURSPACE_sRGB, cmfs, illuminant, 3, lambda x: x)
>>> path = os.path.join(
...     colour.__path__[0],
...     "recovery",
...     "tests",
...     "resources",
...     "sRGB_Jakob2019.coeff",
... )
>>> LUT.write(path)  
>>> LUT.read(path)  
>>> RGB = np.array([0.70573936, 0.19248266, 0.22354169])
>>> with numpy_print_options(suppress=True):
...     LUT.RGB_to_sd(RGB, cmfs.shape)  
SpectralDistribution([[ 360.        ,    0.7666803...],
                      [ 370.        ,    0.6251547...],
                      [ 380.        ,    0.4584310...],
                      [ 390.        ,    0.3161633...],
                      [ 400.        ,    0.2196155...],
                      [ 410.        ,    0.1596575...],
                      [ 420.        ,    0.1225525...],
                      [ 430.        ,    0.0989784...],
                      [ 440.        ,    0.0835782...],
                      [ 450.        ,    0.0733535...],
                      [ 460.        ,    0.0666049...],
                      [ 470.        ,    0.0623569...],
                      [ 480.        ,    0.06006  ...],
                      [ 490.        ,    0.0594383...],
                      [ 500.        ,    0.0604201...],
                      [ 510.        ,    0.0631195...],
                      [ 520.        ,    0.0678648...],
                      [ 530.        ,    0.0752834...],
                      [ 540.        ,    0.0864790...],
                      [ 550.        ,    0.1033773...],
                      [ 560.        ,    0.1293883...],
                      [ 570.        ,    0.1706018...],
                      [ 580.        ,    0.2374178...],
                      [ 590.        ,    0.3439472...],
                      [ 600.        ,    0.4950548...],
                      [ 610.        ,    0.6604253...],
                      [ 620.        ,    0.7914669...],
                      [ 630.        ,    0.8738724...],
                      [ 640.        ,    0.9213216...],
                      [ 650.        ,    0.9486880...],
                      [ 660.        ,    0.9650550...],
                      [ 670.        ,    0.9752838...],
                      [ 680.        ,    0.9819499...],
                      [ 690.        ,    0.9864585...],
                      [ 700.        ,    0.9896073...],
                      [ 710.        ,    0.9918680...],
                      [ 720.        ,    0.9935302...],
                      [ 730.        ,    0.9947778...],
                      [ 740.        ,    0.9957312...],
                      [ 750.        ,    0.9964714...],
                      [ 760.        ,    0.9970543...],
                      [ 770.        ,    0.9975190...],
                      [ 780.        ,    0.9978936...]],
                     SpragueInterpolator,
                     {},
                     Extrapolator,
                     {'method': 'Constant', 'left': None, 'right': None})
__init__() None[source]#
Return type:

None

Methods

RGB_to_coefficients(RGB)

Look up a given RGB colourspace array and return corresponding coefficients.

RGB_to_sd(RGB[, shape])

Look up a given RGB colourspace array and return the corresponding spectral distribution.

__init__()

generate(colourspace[, cmfs, illuminant, ...])

Generate the lookup table data for given RGB colourspace, colour matching functions, illuminant and given size.

read(path)

Load a lookup table from a *.coeff file.

write(path)

Write the lookup table to a *.coeff file.

Attributes

coefficients

Getter property for the Jakob and Hanika (2019) interpolator coefficients.

interpolator

Getter property for the Jakob and Hanika (2019) interpolator.

lightness_scale

Getter property for the Jakob and Hanika (2019) interpolator lightness scale.

size

Getter property for the Jakob and Hanika (2019) interpolator size, i.e. the sample count on one side of the 3D table.