colour.recovery.LUT3D_Jakob2019

class colour.recovery.LUT3D_Jakob2019[source]

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 optimization 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.models import RGB_COLOURSPACE_sRGB
>>> from colour.utilities import numpy_print_options
>>> cmfs = (
...     MSDS_CMFS_STANDARD_OBSERVER['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.7666362...],
                      [ 370.        ,    0.6251086...],
                      [ 380.        ,    0.4584017...],
                      [ 390.        ,    0.3161559...],
                      [ 400.        ,    0.2196213...],
                      [ 410.        ,    0.1596688...],
                      [ 420.        ,    0.1225656...],
                      [ 430.        ,    0.0989919...],
                      [ 440.        ,    0.0835916...],
                      [ 450.        ,    0.0733669...],
                      [ 460.        ,    0.0666183...],
                      [ 470.        ,    0.0623707...],
                      [ 480.        ,    0.0600743...],
                      [ 490.        ,    0.0594537...],
                      [ 500.        ,    0.0604370...],
                      [ 510.        ,    0.0631385...],
                      [ 520.        ,    0.0678869...],
                      [ 530.        ,    0.0753101...],
                      [ 540.        ,    0.0865126...],
                      [ 550.        ,    0.1034213...],
                      [ 560.        ,    0.1294488...],
                      [ 570.        ,    0.1706888...],
                      [ 580.        ,    0.2375459...],
                      [ 590.        ,    0.3441276...],
                      [ 600.        ,    0.4952667...],
                      [ 610.        ,    0.660606 ...],
                      [ 620.        ,    0.7915809...],
                      [ 630.        ,    0.8739343...],
                      [ 640.        ,    0.9213543...],
                      [ 650.        ,    0.9487058...],
                      [ 660.        ,    0.9650651...],
                      [ 670.        ,    0.9752897...],
                      [ 680.        ,    0.9819535...],
                      [ 690.        ,    0.9864608...],
                      [ 700.        ,    0.9896088...],
                      [ 710.        ,    0.9918690...],
                      [ 720.        ,    0.9935308...],
                      [ 730.        ,    0.9947782...],
                      [ 740.        ,    0.9957315...],
                      [ 750.        ,    0.9964717...],
                      [ 760.        ,    0.9970544...],
                      [ 770.        ,    0.9975191...],
                      [ 780.        ,    0.9978937...]],
                     interpolator=SpragueInterpolator,
                     interpolator_kwargs={},
                     extrapolator=Extrapolator,
                     extrapolator_kwargs={...})
__init__()[source]

Initialize self. See help(type(self)) for accurate signature.

Methods

RGB_to_coefficients(RGB)

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

RGB_to_sd(RGB[, shape])

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

__init__()

Initialize self.

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

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

read(path)

Loads a lookup table from a *.coeff file.

write(path)

Writes 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 samples count on one side of the 3D table.