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. This class enables significant time savings by performing 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. These files are directly available from Colour - Datasets under the record 4050598.
Attributes
sizelightness_scalecoefficientsinterpolator
Methods
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})
Methods
RGB_to_coefficients(RGB)Look up the specified RGB colourspace array and return the corresponding coefficients.
RGB_to_sd(RGB[, shape])Look up a specified RGB colourspace array and return the corresponding spectral distribution.
__init__()generate(colourspace[, cmfs, illuminant, ...])Generate the lookup table data for the specified RGB colourspace, colour matching functions, illuminant and resolution.
read(path)Load a lookup table from a *.coeff file.
write(path)Write the lookup table to a *.coeff file.
Attributes
coefficientsGetter for the Jakob and Hanika (2019) interpolator coefficients.
interpolatorGetter for the Jakob and Hanika (2019) interpolator.
lightness_scaleGetter for the Jakob and Hanika (2019) interpolator lightness scale.
sizeGetter for the Jakob and Hanika (2019) interpolator size.