colour.matrix_idt#

colour.matrix_idt(sensitivities: RGB_CameraSensitivities, illuminant: SpectralDistribution, training_data: Optional[MultiSpectralDistributions] = None, cmfs: Optional[MultiSpectralDistributions] = None, optimisation_factory: Callable = optimisation_factory_rawtoaces_v1, optimisation_kwargs: Optional[Dict] = None, chromatic_adaptation_transform: Optional[Union[Literal['Bianco 2010', 'Bianco PC 2010', 'Bradford', 'CAT02 Brill 2008', 'CAT02', 'CAT16', 'CMCCAT2000', 'CMCCAT97', 'Fairchild', 'Sharp', 'Von Kries', 'XYZ Scaling'], str]] = 'CAT02', additional_data: bool = False) Union[Tuple[ndarray, ndarray, ndarray, ndarray], Tuple[ndarray, ndarray]][source]#

Compute an Input Device Transform (IDT) matrix for given camera RGB spectral sensitivities, illuminant, training data, standard observer colour matching functions and optimization settings according to RAW to ACES v1 and P-2013-001 procedures.

Parameters:
  • sensitivities (RGB_CameraSensitivities) – Camera RGB spectral sensitivities.

  • illuminant (SpectralDistribution) – Illuminant spectral distribution.

  • training_data (Optional[MultiSpectralDistributions]) – Training data multi-spectral distributions, defaults to using the RAW to ACES v1 190 patches.

  • cmfs (Optional[MultiSpectralDistributions]) – Standard observer colour matching functions, default to the CIE 1931 2 Degree Standard Observer.

  • optimisation_factory (Callable) – Callable producing the objective function and the CIE XYZ to optimisation colour model function.

  • optimisation_kwargs (Optional[Dict]) – Parameters for scipy.optimize.minimize() definition.

  • chromatic_adaptation_transform (Optional[Union[Literal['Bianco 2010', 'Bianco PC 2010', 'Bradford', 'CAT02 Brill 2008', 'CAT02', 'CAT16', 'CMCCAT2000', 'CMCCAT97', 'Fairchild', 'Sharp', 'Von Kries', 'XYZ Scaling'], str]]) – Chromatic adaptation transform, if None no chromatic adaptation is performed.

  • additional_data (bool) – If True, the XYZ and RGB tristimulus values are also returned.

Returns:

Tuple of Input Device Transform (IDT) matrix and white balance multipliers or tuple of Input Device Transform (IDT) matrix, white balance multipliers, XYZ and RGB tristimulus values.

Return type:

tuple

References

[DFI+17], [TheAoMPAaSciencesScienceaTCouncilAcademyCESACESPSubcommittee15]

Examples

Computing the Input Device Transform (IDT) matrix for a CANON EOS 5DMark II and CIE Illuminant D Series D55 using the method given in RAW to ACES v1:

>>> path = os.path.join(
...     RESOURCES_DIRECTORY_RAWTOACES,
...     'CANON_EOS_5DMark_II_RGB_Sensitivities.csv')
>>> sensitivities = sds_and_msds_to_msds(
...     read_sds_from_csv_file(path).values())
>>> illuminant = SDS_ILLUMINANTS['D55']
>>> M, RGB_w = matrix_idt(sensitivities, illuminant)
>>> np.around(M, 3)
array([[ 0.85 , -0.016,  0.151],
       [ 0.051,  1.126, -0.185],
       [ 0.02 , -0.194,  1.162]])
>>> RGB_w  
array([ 2.3414154...,  1.        ,  1.5163375...])

The RAW to ACES v1 matrix for the same camera and optimized by Ceres Solver is as follows:

0.864994 -0.026302 0.161308
0.056527 1.122997 -0.179524
0.023683 -0.202547 1.178864
>>> M, RGB_w = matrix_idt(
...     sensitivities, illuminant,
...     optimisation_factory=optimisation_factory_Jzazbz)
>>> np.around(M, 3)
array([[ 0.848, -0.016,  0.158],
       [ 0.053,  1.114, -0.175],
       [ 0.023, -0.225,  1.196]])
>>> RGB_w  
array([ 2.3414154...,  1.        ,  1.5163375...])