Ejemplo n.º 1
0
    def test_lower_items(self):
        """
        Tests :meth:`colour.utilities.data_structures.\
CaseInsensitiveMapping.lower_items` method.
        """

        mapping = CaseInsensitiveMapping(John='Doe', Jane='Doe')

        self.assertListEqual(sorted([item for item in mapping.lower_items()]),
                             [('jane', 'Doe'), ('john', 'Doe')])
Ejemplo n.º 2
0
    def test_copy(self):
        """
        Tests
        :meth:`colour.utilities.data_structures.CaseInsensitiveMapping.copy`
        method.
        """

        mapping1 = CaseInsensitiveMapping(John='Doe', Jane='Doe')
        mapping2 = mapping1.copy()
        self.assertEqual(mapping1, mapping2)
        self.assertNotEqual(id(mapping1), id(mapping2))
Ejemplo n.º 3
0
RGB_COLOURSPACES = CaseInsensitiveMapping({
    ACES_2065_1_COLOURSPACE.name:
    ACES_2065_1_COLOURSPACE,
    ACES_CC_COLOURSPACE.name:
    ACES_CC_COLOURSPACE,
    ACES_CCT_COLOURSPACE.name:
    ACES_CCT_COLOURSPACE,
    ACES_PROXY_COLOURSPACE.name:
    ACES_PROXY_COLOURSPACE,
    ACES_CG_COLOURSPACE.name:
    ACES_CG_COLOURSPACE,
    ADOBE_RGB_1998_COLOURSPACE.name:
    ADOBE_RGB_1998_COLOURSPACE,
    ADOBE_WIDE_GAMUT_RGB_COLOURSPACE.name:
    ADOBE_WIDE_GAMUT_RGB_COLOURSPACE,
    APPLE_RGB_COLOURSPACE.name:
    APPLE_RGB_COLOURSPACE,
    ALEXA_WIDE_GAMUT_COLOURSPACE.name:
    ALEXA_WIDE_GAMUT_COLOURSPACE,
    BEST_RGB_COLOURSPACE.name:
    BEST_RGB_COLOURSPACE,
    BETA_RGB_COLOURSPACE.name:
    BETA_RGB_COLOURSPACE,
    BT470_525_COLOURSPACE.name:
    BT470_525_COLOURSPACE,
    BT470_625_COLOURSPACE.name:
    BT470_625_COLOURSPACE,
    BT709_COLOURSPACE.name:
    BT709_COLOURSPACE,
    BT2020_COLOURSPACE.name:
    BT2020_COLOURSPACE,
    CIE_RGB_COLOURSPACE.name:
    CIE_RGB_COLOURSPACE,
    CINEMA_GAMUT_COLOURSPACE.name:
    CINEMA_GAMUT_COLOURSPACE,
    COLOR_MATCH_RGB_COLOURSPACE.name:
    COLOR_MATCH_RGB_COLOURSPACE,
    DCDM_XYZ_COLOURSPACE.name:
    DCDM_XYZ_COLOURSPACE,
    DCI_P3_COLOURSPACE.name:
    DCI_P3_COLOURSPACE,
    DCI_P3_P_COLOURSPACE.name:
    DCI_P3_P_COLOURSPACE,
    DJI_D_GAMUT_COLOURSPACE.name:
    DJI_D_GAMUT_COLOURSPACE,
    DON_RGB_4_COLOURSPACE.name:
    DON_RGB_4_COLOURSPACE,
    ECI_RGB_V2_COLOURSPACE.name:
    ECI_RGB_V2_COLOURSPACE,
    EKTA_SPACE_PS_5_COLOURSPACE.name:
    EKTA_SPACE_PS_5_COLOURSPACE,
    FILMLIGHT_E_GAMUT_COLOURSPACE.name:
    FILMLIGHT_E_GAMUT_COLOURSPACE,
    PROTUNE_NATIVE_COLOURSPACE.name:
    PROTUNE_NATIVE_COLOURSPACE,
    MAX_RGB_COLOURSPACE.name:
    MAX_RGB_COLOURSPACE,
    P3_D65_COLOURSPACE.name:
    P3_D65_COLOURSPACE,
    PAL_SECAM_COLOURSPACE.name:
    PAL_SECAM_COLOURSPACE,
    RED_COLOR_COLOURSPACE.name:
    RED_COLOR_COLOURSPACE,
    RED_COLOR_2_COLOURSPACE.name:
    RED_COLOR_2_COLOURSPACE,
    RED_COLOR_3_COLOURSPACE.name:
    RED_COLOR_3_COLOURSPACE,
    RED_COLOR_4_COLOURSPACE.name:
    RED_COLOR_4_COLOURSPACE,
    RED_WIDE_GAMUT_RGB_COLOURSPACE.name:
    RED_WIDE_GAMUT_RGB_COLOURSPACE,
    DRAGON_COLOR_COLOURSPACE.name:
    DRAGON_COLOR_COLOURSPACE,
    DRAGON_COLOR_2_COLOURSPACE.name:
    DRAGON_COLOR_2_COLOURSPACE,
    ROMM_RGB_COLOURSPACE.name:
    ROMM_RGB_COLOURSPACE,
    RIMM_RGB_COLOURSPACE.name:
    RIMM_RGB_COLOURSPACE,
    ERIMM_RGB_COLOURSPACE.name:
    ERIMM_RGB_COLOURSPACE,
    F_GAMUT_COLOURSPACE.name:
    F_GAMUT_COLOURSPACE,
    PROPHOTO_RGB_COLOURSPACE.name:
    PROPHOTO_RGB_COLOURSPACE,
    RUSSELL_RGB_COLOURSPACE.name:
    RUSSELL_RGB_COLOURSPACE,
    SHARP_RGB_COLOURSPACE.name:
    SHARP_RGB_COLOURSPACE,
    SMPTE_240M_COLOURSPACE.name:
    SMPTE_240M_COLOURSPACE,
    SMPTE_C_COLOURSPACE.name:
    SMPTE_C_COLOURSPACE,
    NTSC_1953_COLOURSPACE.name:
    NTSC_1953_COLOURSPACE,
    NTSC_1987_COLOURSPACE.name:
    NTSC_1987_COLOURSPACE,
    S_GAMUT_COLOURSPACE.name:
    S_GAMUT_COLOURSPACE,
    S_GAMUT3_COLOURSPACE.name:
    S_GAMUT3_COLOURSPACE,
    S_GAMUT3_CINE_COLOURSPACE.name:
    S_GAMUT3_CINE_COLOURSPACE,
    sRGB_COLOURSPACE.name:
    sRGB_COLOURSPACE,
    V_GAMUT_COLOURSPACE.name:
    V_GAMUT_COLOURSPACE,
    XTREME_RGB_COLOURSPACE.name:
    XTREME_RGB_COLOURSPACE
})
Ejemplo n.º 4
0
    values = np.copy(sd.values)
    values[0] = (1 + ALPHA_STEARNS) * values[0] - ALPHA_STEARNS * values[1]
    values[-1] = (1 + ALPHA_STEARNS) * values[-1] - ALPHA_STEARNS * values[-2]
    for i in range(1, len(values) - 1):
        values[i] = (-ALPHA_STEARNS * values[i - 1] +
                     (1 + 2 * ALPHA_STEARNS) * values[i] -
                     ALPHA_STEARNS * values[i + 1])

    sd.values = values

    return sd


BANDPASS_CORRECTION_METHODS = CaseInsensitiveMapping({
    'Stearns 1988': bandpass_correction_Stearns1988
})
BANDPASS_CORRECTION_METHODS.__doc__ = """
Supported spectral bandpass dependence correction methods.

BANDPASS_CORRECTION_METHODS : CaseInsensitiveMapping
    **{'Stearns 1988', }**
"""


def bandpass_correction(sd, method='Stearns 1988'):
    """
    Implements spectral bandpass dependence correction on given spectral
    distribution using given method.

    Parameters
Ejemplo n.º 5
0
    *CMCCAT2000* chromatic adaptation model induction factors.

    Parameters
    ----------
    F : numeric or array_like
        :math:`F` surround condition.

    References
    ----------
    :cite:`Li2002a`, :cite:`Westland2012k`
    """


CMCCAT2000_VIEWING_CONDITIONS = CaseInsensitiveMapping({
    'Average': CMCCAT2000_InductionFactors(1),
    'Dim': CMCCAT2000_InductionFactors(0.8),
    'Dark': CMCCAT2000_InductionFactors(0.8)
})
CMCCAT2000_VIEWING_CONDITIONS.__doc__ = """
Reference *CMCCAT2000* chromatic adaptation model viewing conditions.

References
----------
:cite:`Li2002a`, :cite:`Westland2012k`

CMCCAT2000_VIEWING_CONDITIONS : CaseInsensitiveMapping
    ('Average', 'Dim', 'Dark')
"""


def chromatic_adaptation_forward_CMCCAT2000(
Ejemplo n.º 6
0
# -*- coding: utf-8 -*-
"""
References
----------
-   :cite:`Darrodi2015a` : Darrodi, M. M., Finlayson, G., Goodman, T., &
    Mackiewicz, M. (2015). Reference data set for camera spectral sensitivity
    estimation. Journal of the Optical Society of America A, 32(3), 381.
    doi:10.1364/JOSAA.32.000381
"""

from __future__ import absolute_import

from .dslr import DSLR_CAMERAS_RGB_SPECTRAL_SENSITIVITIES
from colour.utilities import CaseInsensitiveMapping

CAMERAS_RGB_SPECTRAL_SENSITIVITIES = CaseInsensitiveMapping(
    DSLR_CAMERAS_RGB_SPECTRAL_SENSITIVITIES)
CAMERAS_RGB_SPECTRAL_SENSITIVITIES.__doc__ = """
Cameras *RGB* spectral sensitivities.

References
----------
:cite:`Darrodi2015a`

CAMERAS_RGB_SPECTRAL_SENSITIVITIES : CaseInsensitiveMapping
    **{Nikon 5100 (NPL), Sigma SDMerill (NPL)}**
"""

__all__ = ['CAMERAS_RGB_SPECTRAL_SENSITIVITIES']
Ejemplo n.º 7
0
    1.0
    >>> sd[530]  # doctest: +ELLIPSIS
    0.3678794...
    """

    wavelengths = shape.range()

    values = np.exp(-((wavelengths - peak_wavelength) / fwhm)**2)

    name = '{0}nm - {1} FWHM - Gaussian'.format(peak_wavelength, fwhm)

    return SpectralDistribution(values, wavelengths, name=name)


SD_GAUSSIAN_METHODS = CaseInsensitiveMapping({
    'Normal': sd_gaussian_normal,
    'FWHM': sd_gaussian_fwhm
})
SD_GAUSSIAN_METHODS.__doc__ = """
Supported gaussian spectral distribution computation methods.

SD_GAUSSIAN_METHODS : CaseInsensitiveMapping
    **{'Normal', 'FWHM'}**
"""


def sd_gaussian(mu_peak_wavelength,
                sigma_fwhm,
                shape=DEFAULT_SPECTRAL_SHAPE,
                method='Normal'):
    """
    Returns a gaussian spectral distribution of given spectral shape using
Ejemplo n.º 8
0
ALEXA_LOG_C_CURVE_BCL_DATA = CaseInsensitiveMapping({
    'SUP 3.x': {
        160: (0.0928, 0.8128),
        200: (0.0928, 0.8341),
        250: (0.0928, 0.8549),
        320: (0.0928, 0.8773),
        400: (0.0928, 0.8968),
        500: (0.0928, 0.9158),
        640: (0.0928, 0.9362),
        800: (0.0928, 0.9539),
        1000: (0.0928, 0.9711),
        1280: (0.0928, 0.9895),
        1600: (0.0928, 1.0000),
        2000: (0.0928, 1.0000),
        2560: (0.0928, 1.0000),
        3200: (0.0928, 1.0000)
    },
    'SUP 2.x': {
        160: (0.1083, 0.8110),
        200: (0.1115, 0.8320),
        250: (0.1146, 0.8524),
        320: (0.1181, 0.8743),
        400: (0.1213, 0.8935),
        500: (0.1245, 0.9121),
        640: (0.1280, 0.9320),
        800: (0.1311, 0.9494),
        1000: (0.1343, 0.9662),
        1280: (0.1378, 0.9841),
        1600: (0.1409, 0.9997)
    }
})
    'ILLUMINANTS_CIE_1931_2_DEGREE_STANDARD_OBSERVER',
    'ILLUMINANTS_CIE_1964_10_DEGREE_STANDARD_OBSERVER', 'ILLUMINANTS'
]

ILLUMINANTS_CIE_1931_2_DEGREE_STANDARD_OBSERVER = CaseInsensitiveMapping({
    'A': np.array([0.44758, 0.40745]),
    'B': np.array([0.34842, 0.35161]),
    'C': np.array([0.31006, 0.31616]),
    'D50': np.array([0.34570, 0.35850]),
    'D55': np.array([0.33243, 0.34744]),
    'D60': np.array([0.321626242047397, 0.337736995955436]),
    'D65': np.array([0.31270, 0.32900]),
    'D75': np.array([0.29903, 0.31488]),
    'E': np.array([1 / 3, 1 / 3]),
    'FL1': np.array([0.31310, 0.33710]),
    'FL2': np.array([0.37210, 0.37510]),
    'FL3': np.array([0.40910, 0.39410]),
    'FL4': np.array([0.44020, 0.40310]),
    'FL5': np.array([0.31380, 0.34520]),
    'FL6': np.array([0.37790, 0.38820]),
    'FL7': np.array([0.31290, 0.32920]),
    'FL8': np.array([0.34580, 0.35860]),
    'FL9': np.array([0.37410, 0.37270]),
    'FL10': np.array([0.34580, 0.35880]),
    'FL11': np.array([0.38050, 0.37690]),
    'FL12': np.array([0.43700, 0.40420])
})
"""
*CIE* illuminant chromaticity coordinates for
*CIE 1931 2 Degree Standard Observer*.
Ejemplo n.º 10
0
__all__ = [
    'R_MATRIX', 'RLAB_VIEWING_CONDITIONS', 'RLAB_D_FACTOR',
    'RLAB_ReferenceSpecification', 'RLAB_Specification', 'XYZ_to_RLAB'
]

R_MATRIX = np.array([[1.9569, -1.1882, 0.2313], [0.3612, 0.6388, 0.0000],
                     [0.0000, 0.0000, 1.0000]])
"""
RLAB colour appearance model precomputed helper matrix.

R_MATRIX : array_like, (3, 3)
"""

RLAB_VIEWING_CONDITIONS = CaseInsensitiveMapping({
    'Average': 1 / 2.3,
    'Dim': 1 / 2.9,
    'Dark': 1 / 3.5
})
"""
Reference RLAB colour appearance model viewing conditions.

RLAB_VIEWING_CONDITIONS : CaseInsensitiveMapping
    **{'Average', 'Dim', 'Dark'}**
"""

RLAB_D_FACTOR = CaseInsensitiveMapping({
    'Hard Copy Images':
    1,
    'Soft Copy Images':
    0,
    'Projected Transparencies, Dark Room':
Ejemplo n.º 11
0
__all__ += dataset.__all__
__all__ += [
    'chromatic_adaptation_matrix_VonKries', 'chromatic_adaptation_VonKries'
]
__all__ += ['chromatic_adaptation_Fairchild1990']
__all__ += [
    'CMCCAT2000_InductionFactors', 'CMCCAT2000_VIEWING_CONDITIONS',
    'chromatic_adaptation_forward_CMCCAT2000',
    'chromatic_adaptation_reverse_CMCCAT2000',
    'chromatic_adaptation_CMCCAT2000'
]
__all__ += ['chromatic_adaptation_CIE1994']

CHROMATIC_ADAPTATION_METHODS = CaseInsensitiveMapping({
    'CIE 1994': chromatic_adaptation_CIE1994,
    'CMCCAT2000': chromatic_adaptation_CMCCAT2000,
    'Fairchild 1990': chromatic_adaptation_Fairchild1990,
    'Von Kries': chromatic_adaptation_VonKries,
})
CHROMATIC_ADAPTATION_METHODS.__doc__ = """
Supported chromatic adaptation methods.

References
----------
:cite:`CIETC1-321994b`, :cite:`Fairchild1991a`, :cite:`Fairchild2013s`,
:cite:`Fairchild2013t`, :cite:`Li2002a`, :cite:`Westland2012k`

CHROMATIC_ADAPTATION_METHODS : CaseInsensitiveMapping
    **{'CIE 1994', 'CMCCAT2000', 'Fairchild 1990', 'Von Kries'}**
"""

Ejemplo n.º 12
0
SMITS_1999_SDS = CaseInsensitiveMapping({
    'white':
        SpectralDistribution(
            SMITS_1999_SDS_DATA['white'],
            name='white'),
    'cyan':
        SpectralDistribution(
            SMITS_1999_SDS_DATA['cyan'],
            name='cyan'),
    'magenta':
        SpectralDistribution(
            SMITS_1999_SDS_DATA['magenta'],
            name='magenta'),
    'yellow':
        SpectralDistribution(
            SMITS_1999_SDS_DATA['yellow'],
            name='yellow'),
    'red':
        SpectralDistribution(
            SMITS_1999_SDS_DATA['red'],
            name='red'),
    'green':
        SpectralDistribution(
            SMITS_1999_SDS_DATA['green'],
            name='green'),
    'blue':
        SpectralDistribution(
            SMITS_1999_SDS_DATA['blue'],
            name='blue')
})  # yapf: disable
SMITS_1999_SDS.__doc__ = """
Ejemplo n.º 13
0
        Maximum degree of adaptation :math:`F`.
    c : numeric or array_like
        Exponential non linearity :math:`c`.
    N_c : numeric or array_like
        Chromatic induction factor :math:`N_c`.

    References
    ----------
    :cite:`Fairchild2004c`, :cite:`Luo2013`, :cite:`Moroneya`,
    :cite:`Wikipedia2007a`
    """


CIECAM02_VIEWING_CONDITIONS = CaseInsensitiveMapping({
    'Average': CIECAM02_InductionFactors(1, 0.69, 1),
    'Dim': CIECAM02_InductionFactors(0.9, 0.59, 0.9),
    'Dark': CIECAM02_InductionFactors(0.8, 0.525, 0.8)
})
CIECAM02_VIEWING_CONDITIONS.__doc__ = """
Reference *CIECAM02* colour appearance model viewing conditions.

References
----------
:cite:`Fairchild2004c`, :cite:`Luo2013`, :cite:`Moroneya`,
:cite:`Wikipedia2007a`

CIECAM02_VIEWING_CONDITIONS : CaseInsensitiveMapping
    **{'Average', 'Dim', 'Dark'}**
"""

HUE_DATA_FOR_HUE_QUADRATURE = {
Ejemplo n.º 14
0
from __future__ import absolute_import

from colour.utilities import CaseInsensitiveMapping, filter_kwargs
from .barten1999 import (optical_MTF_Barten1999, pupil_diameter_Barten1999,
                         sigma_Barten1999, retinal_illuminance_Barten1999,
                         maximum_angular_size_Barten1999,
                         contrast_sensitivity_function_Barten1999)

__all__ = [
    'optical_MTF_Barten1999', 'pupil_diameter_Barten1999', 'sigma_Barten1999',
    'retinal_illuminance_Barten1999', 'maximum_angular_size_Barten1999',
    'contrast_sensitivity_function_Barten1999'
]

CONTRAST_SENSITIVITY_METHODS = CaseInsensitiveMapping({
    'Barten 1999': contrast_sensitivity_function_Barten1999,
})
CONTRAST_SENSITIVITY_METHODS.__doc__ = """
Supported contrast sensitivity methods.

References
----------
:cite:`Barten1999`, :cite:`Barten2003`, :cite:`Cowan2004`,
:cite:`InternationalTelecommunicationUnion2015`,

CONTRAST_SENSITIVITY_METHODS : CaseInsensitiveMapping
    **{'Barten 1999'}**
"""


def contrast_sensitivity_function(method='Barten 1999', **kwargs):
Ejemplo n.º 15
0
        *Lightness* induction factor :math:`F_L`.
    F_C : numeric or array_like
        *Chroma* induction factor :math:`F_C`.

    References
    ----------
    :cite:`Fairchild2013x`, :cite:`Luo1996b`, :cite:`Luo1996c`
    """


LLAB_VIEWING_CONDITIONS = CaseInsensitiveMapping({
    'Reference Samples & Images, Average Surround, Subtending > 4': (
        LLAB_InductionFactors(1, 3, 0, 1)),
    'Reference Samples & Images, Average Surround, Subtending < 4': (
        LLAB_InductionFactors(1, 3, 1, 1)),
    'Television & VDU Displays, Dim Surround': (LLAB_InductionFactors(
        0.7, 3.5, 1, 1)),
    'Cut Sheet Transparency, Dim Surround': (LLAB_InductionFactors(
        1, 5, 1, 1.1)),
    '35mm Projection Transparency, Dark Surround': (LLAB_InductionFactors(
        0.7, 4, 1, 1))
})
LLAB_VIEWING_CONDITIONS.__doc__ = """
Reference :math:`LLAB(l:c)` colour appearance model viewing conditions.

References
----------
:cite:`Fairchild2013x`, :cite:`Luo1996b`, :cite:`Luo1996c`

LLAB_VIEWING_CONDITIONS : CaseInsensitiveMapping
    **{'Reference Samples & Images, Average Surround, Subtending > 4',
    'Reference Samples & Images, Average Surround, Subtending < 4',
Ejemplo n.º 16
0
class CMCCAT2000_InductionFactors(
        namedtuple('CMCCAT2000_InductionFactors', ('F', ))):
    """
    CMCCAT2000 chromatic adaptation model induction factors.

    Parameters
    ----------
    F : numeric or array_like
        :math:`F` surround condition.
    """


CMCCAT2000_VIEWING_CONDITIONS = CaseInsensitiveMapping({
    'Average':
    CMCCAT2000_InductionFactors(1.),
    'Dim':
    CMCCAT2000_InductionFactors(0.8),
    'Dark':
    CMCCAT2000_InductionFactors(0.8)
})
"""
Reference CMCCAT2000 chromatic adaptation model viewing conditions.

CMCCAT2000_VIEWING_CONDITIONS : CaseInsensitiveMapping
    ('Average', 'Dim', 'Dark')
"""


def chromatic_adaptation_forward_CMCCAT2000(
    XYZ,
    XYZ_w,
    XYZ_wr,
Ejemplo n.º 17
0
CVD_MATRICES_MACHADO2010 = CaseInsensitiveMapping({
    'Protanomaly': {
        0.0:
            np.array([
                [1.000000, 0.000000, -0.000000],
                [0.000000, 1.000000, 0.000000],
                [-0.000000, -0.000000, 1.000000],
            ]),
        0.1:
            np.array([
                [0.856167, 0.182038, -0.038205],
                [0.029342, 0.955115, 0.015544],
                [-0.002880, -0.001563, 1.004443],
            ]),
        0.2:
            np.array([
                [0.734766, 0.334872, -0.069637],
                [0.051840, 0.919198, 0.028963],
                [-0.004928, -0.004209, 1.009137],
            ]),
        0.3:
            np.array([
                [0.630323, 0.465641, -0.095964],
                [0.069181, 0.890046, 0.040773],
                [-0.006308, -0.007724, 1.014032],
            ]),
        0.4:
            np.array([
                [0.539009, 0.579343, -0.118352],
                [0.082546, 0.866121, 0.051332],
                [-0.007136, -0.011959, 1.019095],
            ]),
        0.5:
            np.array([
                [0.458064, 0.679578, -0.137642],
                [0.092785, 0.846313, 0.060902],
                [-0.007494, -0.016807, 1.024301],
            ]),
        0.6:
            np.array([
                [0.385450, 0.769005, -0.154455],
                [0.100526, 0.829802, 0.069673],
                [-0.007442, -0.022190, 1.029632],
            ]),
        0.7:
            np.array([
                [0.319627, 0.849633, -0.169261],
                [0.106241, 0.815969, 0.077790],
                [-0.007025, -0.028051, 1.035076],
            ]),
        0.8:
            np.array([
                [0.259411, 0.923008, -0.182420],
                [0.110296, 0.804340, 0.085364],
                [-0.006276, -0.034346, 1.040622],
            ]),
        0.9:
            np.array([
                [0.203876, 0.990338, -0.194214],
                [0.112975, 0.794542, 0.092483],
                [-0.005222, -0.041043, 1.046265],
            ]),
        1.0:
            np.array([
                [0.152286, 1.052583, -0.204868],
                [0.114503, 0.786281, 0.099216],
                [-0.003882, -0.048116, 1.051998],
            ])
    },
    'Deuteranomaly': {
        0.0:
            np.array([
                [1.000000, 0.000000, -0.000000],
                [0.000000, 1.000000, 0.000000],
                [-0.000000, -0.000000, 1.000000],
            ]),
        0.1:
            np.array([
                [0.866435, 0.177704, -0.044139],
                [0.049567, 0.939063, 0.011370],
                [-0.003453, 0.007233, 0.996220],
            ]),
        0.2:
            np.array([
                [0.760729, 0.319078, -0.079807],
                [0.090568, 0.889315, 0.020117],
                [-0.006027, 0.013325, 0.992702],
            ]),
        0.3:
            np.array([
                [0.675425, 0.433850, -0.109275],
                [0.125303, 0.847755, 0.026942],
                [-0.007950, 0.018572, 0.989378],
            ]),
        0.4:
            np.array([
                [0.605511, 0.528560, -0.134071],
                [0.155318, 0.812366, 0.032316],
                [-0.009376, 0.023176, 0.986200],
            ]),
        0.5:
            np.array([
                [0.547494, 0.607765, -0.155259],
                [0.181692, 0.781742, 0.036566],
                [-0.010410, 0.027275, 0.983136],
            ]),
        0.6:
            np.array([
                [0.498864, 0.674741, -0.173604],
                [0.205199, 0.754872, 0.039929],
                [-0.011131, 0.030969, 0.980162],
            ]),
        0.7:
            np.array([
                [0.457771, 0.731899, -0.189670],
                [0.226409, 0.731012, 0.042579],
                [-0.011595, 0.034333, 0.977261],
            ]),
        0.8:
            np.array([
                [0.422823, 0.781057, -0.203881],
                [0.245752, 0.709602, 0.044646],
                [-0.011843, 0.037423, 0.974421],
            ]),
        0.9:
            np.array([
                [0.392952, 0.823610, -0.216562],
                [0.263559, 0.690210, 0.046232],
                [-0.011910, 0.040281, 0.971630],
            ]),
        1.0:
            np.array([
                [0.367322, 0.860646, -0.227968],
                [0.280085, 0.672501, 0.047413],
                [-0.011820, 0.042940, 0.968881],
            ])
    },
    'Tritanomaly': {
        0.0:
            np.array([
                [1.000000, 0.000000, -0.000000],
                [0.000000, 1.000000, 0.000000],
                [-0.000000, -0.000000, 1.000000],
            ]),
        0.1:
            np.array([
                [0.926670, 0.092514, -0.019184],
                [0.021191, 0.964503, 0.014306],
                [0.008437, 0.054813, 0.936750],
            ]),
        0.2:
            np.array([
                [0.895720, 0.133330, -0.029050],
                [0.029997, 0.945400, 0.024603],
                [0.013027, 0.104707, 0.882266],
            ]),
        0.3:
            np.array([
                [0.905871, 0.127791, -0.033662],
                [0.026856, 0.941251, 0.031893],
                [0.013410, 0.148296, 0.838294],
            ]),
        0.4:
            np.array([
                [0.948035, 0.089490, -0.037526],
                [0.014364, 0.946792, 0.038844],
                [0.010853, 0.193991, 0.795156],
            ]),
        0.5:
            np.array([
                [1.017277, 0.027029, -0.044306],
                [-0.006113, 0.958479, 0.047634],
                [0.006379, 0.248708, 0.744913],
            ]),
        0.6:
            np.array([
                [1.104996, -0.046633, -0.058363],
                [-0.032137, 0.971635, 0.060503],
                [0.001336, 0.317922, 0.680742],
            ]),
        0.7:
            np.array([
                [1.193214, -0.109812, -0.083402],
                [-0.058496, 0.979410, 0.079086],
                [-0.002346, 0.403492, 0.598854],
            ]),
        0.8:
            np.array([
                [1.257728, -0.139648, -0.118081],
                [-0.078003, 0.975409, 0.102594],
                [-0.003316, 0.501214, 0.502102],
            ]),
        0.9:
            np.array([
                [1.278864, -0.125333, -0.153531],
                [-0.084748, 0.957674, 0.127074],
                [-0.000989, 0.601151, 0.399838],
            ]),
        1.0:
            np.array([
                [1.255528, -0.076749, -0.178779],
                [-0.078411, 0.930809, 0.147602],
                [0.004733, 0.691367, 0.303900],
            ])
    }
})
Ejemplo n.º 18
0
    for result in experiment_results:
        XYZ_1 = xy_to_XYZ(Luv_uv_to_xy(result.uvp_t))
        XYZ_2 = chromatic_adaptation_VonKries(XYZ_1, XYZ_w, XYZ_wr, transform)
        uvp = Luv_to_uv(XYZ_to_Luv(XYZ_2, xy_wr), xy_wr)
        prediction.append(
            CorrespondingChromaticitiesPrediction(result.name, result.uvp_t,
                                                  result.uvp_m, uvp))

    return tuple(prediction)


CORRESPONDING_CHROMATICITIES_PREDICTION_MODELS = CaseInsensitiveMapping({
    'CIE 1994':
    corresponding_chromaticities_prediction_CIE1994,
    'CMCCAT2000':
    corresponding_chromaticities_prediction_CMCCAT2000,
    'Fairchild 1990':
    corresponding_chromaticities_prediction_Fairchild1990,
    'Von Kries':
    corresponding_chromaticities_prediction_VonKries
})
CORRESPONDING_CHROMATICITIES_PREDICTION_MODELS.__doc__ = """
Aggregated corresponding chromaticities prediction models.

References
----------
-   :cite:`Breneman1987b`
-   :cite:`CIETC1-321994b`
-   :cite:`Fairchild1991a`
-   :cite:`Fairchild2013s`
-   :cite:`Fairchild2013t`
-   :cite:`Li2002a`
Ejemplo n.º 19
0
    '.cube': 'Iridas Cube',
    '.spi1d': 'Sony SPI1D',
    '.spi3d': 'Sony SPI3D',
    '.csp': 'Cinespace'
})
"""
Extension to *LUT* format.

EXTENSION_TO_LUT_FORMAT_MAPPING : CaseInsensitiveMapping
    **{'.cube', '.spi1d'}**
"""

LUT_READ_METHODS = CaseInsensitiveMapping({
    'Cinespace': read_LUT_Cinespace,
    'Iridas Cube': read_LUT_IridasCube,
    'Resolve Cube': read_LUT_ResolveCube,
    'Sony SPI1D': read_LUT_SonySPI1D,
    'Sony SPI3D': read_LUT_SonySPI3D,
})
LUT_READ_METHODS.__doc__ = """
Supported *LUT* reading methods.

References
----------
:cite:`AdobeSystems2013b`, :cite:`Chamberlain2015`

LUT_READ_METHODS : CaseInsensitiveMapping
    **{'Cinespace', 'Iridas Cube', 'Resolve Cube', 'Sony SPI1D',
    'Sony SPI3D'}**
"""
Ejemplo n.º 20
0
    delta_A = a_1 - a_2
    delta_B = b_1 - b_2
    delta_H2 = delta_A * delta_A + delta_B * delta_B - delta_C * delta_C

    v_1 = delta_L / (l * s_l)
    v_2 = delta_C / (c * s_c)
    v_3 = s_h

    d_E = np.sqrt(v_1**2 + v_2**2 + (delta_H2 / (v_3 * v_3)))

    return d_E


DELTA_E_METHODS = CaseInsensitiveMapping({
    'CIE 1976': delta_E_CIE1976,
    'CIE 1994': delta_E_CIE1994,
    'CIE 2000': delta_E_CIE2000,
    'CMC': delta_E_CMC
})
"""
Supported *Delta E* computations methods.

DELTA_E_METHODS : CaseInsensitiveMapping
    **{'CIE 1976', 'CIE 1994', 'CIE 2000', 'CMC'}**

Aliases:

-   'cie1976': 'CIE 1976'
-   'cie1994': 'CIE 1994'
-   'cie2000': 'CIE 2000'
"""
DELTA_E_METHODS['cie1976'] = DELTA_E_METHODS['CIE 1976']
Ejemplo n.º 21
0
    >>> CCT_to_uv_Krystek1985(6504.38938305)  # doctest: +ELLIPSIS
    array([ 0.1837669...,  0.3093443...])
    """

    T = as_float_array(CCT)

    u = ((0.860117757 + 1.54118254 * 10e-4 * T + 1.28641212 * 10e-7 * T ** 2) /
         (1 + 8.42420235 * 10e-4 * T + 7.08145163 * 10e-7 * T ** 2))
    v = ((0.317398726 + 4.22806245 * 10e-5 * T + 4.20481691 * 10e-8 * T ** 2) /
         (1 - 2.89741816 * 10e-5 * T + 1.61456053 * 10e-7 * T ** 2))

    return tstack([u, v])


UV_TO_CCT_METHODS = CaseInsensitiveMapping({
    'Ohno 2013': uv_to_CCT_Ohno2013,
    'Robertson 1968': uv_to_CCT_Robertson1968
})
UV_TO_CCT_METHODS.__doc__ = """
Supported *CIE UCS* colourspace *uv* chromaticity coordinates to correlated
colour temperature :math:`T_{cp}` computation methods.

References
----------
:cite:`AdobeSystems2013`, :cite:`AdobeSystems2013a`, :cite:`Ohno2014a`,
:cite:`Wyszecki2000y`

UV_TO_CCT_METHODS : CaseInsensitiveMapping
    **{'Ohno 2013', 'Robertson 1968'}**

Aliases:
Ejemplo n.º 22
0
}
"""
CQS test colour samples indexes to names mapping.

VS_INDEXES_TO_NAMES : dict
"""

VS_APPROXIMATE_MUNSELL_NOTATIONS = CaseInsensitiveMapping({
    'VS1': '7.5P 4/10',
    'VS2': '10PB 4/10',
    'VS3': '5PB 4/2',
    'VS4': '7.5B 5/10',
    'VS5': '10B G6/8',
    'VS6': '2.5BG 6/10',
    'VS7': '2.5G 6/12',
    'VS8': '7.5GY 7/10',
    'VS9': '2.5GY 8/10',
    'VS10': '5Y 8.5/12',
    'VS11': '10YR 7/12',
    'VS12': '5YR 7/12',
    'VS13': '10R 6/12',
    'VS14': '5R 4/14',
    'VS15': '7.5RP 4/12'
})
"""
CQS test colour samples *Munsell* colour approximations.

VS_APPROXIMATE_MUNSELL_NOTATIONS : CaseInsensitiveMapping
"""

VS_SPDS_DATA = {
Ejemplo n.º 23
0
    Parameters
    ----------
    F : numeric or array_like
        Maximum degree of adaptation :math:`F`.
    c : numeric or array_like
        Exponential non linearity :math:`c`.
    N_c : numeric or array_like
        Chromatic induction factor :math:`N_c`.

    References
    ----------
    :cite:`Li2017`
    """


CAM16_VIEWING_CONDITIONS = CaseInsensitiveMapping(CIECAM02_VIEWING_CONDITIONS)
CAM16_VIEWING_CONDITIONS.__doc__ = """
Reference *CAM16* colour appearance model viewing conditions.

References
----------
:cite:`Li2017`

CAM16_VIEWING_CONDITIONS : CaseInsensitiveMapping
    **{'Average', 'Dim', 'Dark'}**
"""


class CAM16_Specification(
        namedtuple('CAM16_Specification',
                   ('J', 'C', 'h', 's', 'Q', 'M', 'H', 'HC'))):
Ejemplo n.º 24
0
    """

    values = np.copy(sd.values)
    values[0] = (1 + ALPHA_STEARNS) * values[0] - ALPHA_STEARNS * values[1]
    values[-1] = (1 + ALPHA_STEARNS) * values[-1] - ALPHA_STEARNS * values[-2]
    for i in range(1, len(values) - 1):
        values[i] = (-ALPHA_STEARNS * values[i - 1] +
                     (1 + 2 * ALPHA_STEARNS) * values[i] -
                     ALPHA_STEARNS * values[i + 1])

    sd.values = values

    return sd


BANDPASS_CORRECTION_METHODS = CaseInsensitiveMapping(
    {'Stearns 1988': bandpass_correction_Stearns1988})
BANDPASS_CORRECTION_METHODS.__doc__ = """
Supported spectral bandpass dependence correction methods.

BANDPASS_CORRECTION_METHODS : CaseInsensitiveMapping
    **{'Stearns 1988', }**
"""


def bandpass_correction(sd, method='Stearns 1988'):
    """
    Implements spectral bandpass dependence correction on given spectral
    distribution using given method.

    Parameters
    ----------
Ejemplo n.º 25
0
    >>> RGB = np.array([0.17224810, 0.09170660, 0.06416938])
    >>> polynomial_expansion_Vandermonde(RGB)  # doctest: +ELLIPSIS
    array([ 0.1722481 ,  0.0917066 ,  0.06416938,  1.        ])
    """

    a = as_float_array(a)

    a_e = np.transpose(np.vander(np.ravel(a), degree + 1))
    a_e = np.hstack(a_e.reshape(a_e.shape[0], -1, 3))

    return np.squeeze(a_e[:, 0:a_e.shape[-1] - a.shape[-1] + 1])


POLYNOMIAL_EXPANSION_METHODS = CaseInsensitiveMapping({
    'Cheung 2004': augmented_matrix_Cheung2004,
    'Finlayson 2015': polynomial_expansion_Finlayson2015,
    'Vandermonde': polynomial_expansion_Vandermonde,
})
POLYNOMIAL_EXPANSION_METHODS.__doc__ = """
Supported polynomial expansion methods.

References
----------
:cite:`Cheung2004`, :cite:`Finlayson2015`, :cite:`Westland2004`,
:cite:`Wikipedia2003e`

POLYNOMIAL_EXPANSION_METHODS : CaseInsensitiveMapping
    **{'Cheung 2004', 'Finlayson 2015', 'Vandermonde'}**
"""

Ejemplo n.º 26
0
    if method.lower() == 'hdr-cielab':
        maximum_perception = 247
    else:
        maximum_perception = 246

    L_hdr = reaction_rate_MichealisMenten(
        spow(Y, epsilon), maximum_perception, 2 ** epsilon) + 0.02

    return from_range_100(L_hdr)


LIGHTNESS_METHODS = CaseInsensitiveMapping({
    'Glasser 1958': lightness_Glasser1958,
    'Wyszecki 1963': lightness_Wyszecki1963,
    'CIE 1976': lightness_CIE1976,
    'Fairchild 2010': lightness_Fairchild2010,
    'Fairchild 2011': lightness_Fairchild2011
})
LIGHTNESS_METHODS.__doc__ = """
Supported *Lightness* computation methods.

References
----------
:cite:`CIETC1-482004m`, :cite:`Fairchild2010`, :cite:`Fairchild2011`,
:cite:`Glasser1958a`, :cite:`Wyszecki1963b`, :cite:`Wyszecki2000bd`

LIGHTNESS_METHODS : CaseInsensitiveMapping
    **{'Glasser 1958', 'Wyszecki 1963', 'CIE 1976', 'Fairchild 2010',
    'Fairchild 2011'}**
Ejemplo n.º 27
0
        730.0: (0.0108, 0.0009, 0.0011),
        735.0: (0.0097, 0.0011, 0.0010),
        740.0: (0.0091, 0.0009, 0.0010),
        745.0: (0.0093, 0.0010, 0.0012),
        750.0: (0.0083, 0.0011, 0.0013),
        755.0: (0.0073, 0.0013, 0.0012),
        760.0: (0.0081, 0.0015, 0.0016),
        765.0: (0.0067, 0.0018, 0.0015),
        770.0: (0.0070, 0.0021, 0.0028),
        775.0: (0.0073, 0.0015, 0.0046),
        780.0: (0.0066, 0.0018, 0.0058)
    }
}

CRT_DISPLAYS_RGB_PRIMARIES = CaseInsensitiveMapping({
    'Typical CRT Brainard 1997':
    RGB_DisplayPrimaries(
        CRT_DISPLAYS_RGB_PRIMARIES_DATA['Typical CRT Brainard 1997'],
        name='Typical CRT Brainard 1997')
})
"""
*CRT* displays *RGB* primaries multi-spectral power distributions.

References
----------
-   :cite:`Machado2010a`

CRT_DISPLAYS_RGB_PRIMARIES : CaseInsensitiveMapping
    **{'Typical CRT Brainard 1997'}**
"""
Ejemplo n.º 28
0
from .din99 import delta_E_DIN99

__all__ = ['delta_E_CAM02LCD', 'delta_E_CAM02SCD', 'delta_E_CAM02UCS']
__all__ += ['delta_E_CAM16LCD', 'delta_E_CAM16SCD', 'delta_E_CAM16UCS']
__all__ += [
    'delta_E_CIE1976', 'delta_E_CIE1994', 'delta_E_CIE2000', 'delta_E_CMC'
]
__all__ += ['delta_E_DIN99']

DELTA_E_METHODS = CaseInsensitiveMapping({
    'CIE 1976': delta_E_CIE1976,
    'CIE 1994': delta_E_CIE1994,
    'CIE 2000': delta_E_CIE2000,
    'CMC': delta_E_CMC,
    'CAM02-LCD': delta_E_CAM02LCD,
    'CAM02-SCD': delta_E_CAM02SCD,
    'CAM02-UCS': delta_E_CAM02UCS,
    'CAM16-LCD': delta_E_CAM16LCD,
    'CAM16-SCD': delta_E_CAM16SCD,
    'CAM16-UCS': delta_E_CAM16UCS,
    'DIN99': delta_E_DIN99,
})
DELTA_E_METHODS.__doc__ = """
Supported :math:`\\Delta E_{ab}` computation methods.

References
----------
:cite:`ASTMInternational2007`, :cite:`Li2017`, :cite:`Lindbloom2003c`,
:cite:`Lindbloom2011a`, :cite:`Lindbloom2009e`, :cite:`Lindbloom2009f`,
:cite:`Luo2006b`, :cite:`Melgosa2013b`, :cite:`Wikipedia2008b`
Ejemplo n.º 29
0
    Parameters
    ----------
    F : numeric or array_like
        Maximum degree of adaptation :math:`F`.
    c : numeric or array_like
        Exponential non linearity :math:`c`.
    N_c : numeric or array_like
        Chromatic induction factor :math:`N_c`.
    """


CIECAM02_VIEWING_CONDITIONS = CaseInsensitiveMapping({
    'Average':
    CIECAM02_InductionFactors(1, 0.69, 1),
    'Dim':
    CIECAM02_InductionFactors(0.9, 0.59, 0.95),
    'Dark':
    CIECAM02_InductionFactors(0.8, 0.525, 0.8)
})
"""
Reference CIECAM02 colour appearance model viewing conditions.

CIECAM02_VIEWING_CONDITIONS : CaseInsensitiveMapping
    **{'Average', 'Dim', 'Dark'}**
"""

HUE_DATA_FOR_HUE_QUADRATURE = {
    'h_i': np.array([20.14, 90.00, 164.25, 237.53, 380.14]),
    'e_i': np.array([0.8, 0.7, 1.0, 1.2, 0.8]),
    'H_i': np.array([0.0, 100.0, 200.0, 300.0, 400.0])
}
Ejemplo n.º 30
0
    >>> polynomial_expansion_Vandermonde(RGB)  # doctest: +ELLIPSIS
    array([ 0.1722481 ,  0.0917066 ,  0.06416938,  1.        ])
    """

    a = as_float_array(a)

    a_e = np.transpose(np.vander(np.ravel(a), degree + 1))
    a_e = np.hstack(a_e.reshape(a_e.shape[0], -1, 3))

    return np.squeeze(a_e[:, 0:a_e.shape[-1] - a.shape[-1] + 1])


POLYNOMIAL_EXPANSION_METHODS = CaseInsensitiveMapping({
    'Cheung 2004':
    matrix_augmented_Cheung2004,
    'Finlayson 2015':
    polynomial_expansion_Finlayson2015,
    'Vandermonde':
    polynomial_expansion_Vandermonde,
})
POLYNOMIAL_EXPANSION_METHODS.__doc__ = """
Supported polynomial expansion methods.

References
----------
:cite:`Cheung2004`, :cite:`Finlayson2015`, :cite:`Westland2004`,
:cite:`Wikipedia2003e`

POLYNOMIAL_EXPANSION_METHODS : CaseInsensitiveMapping
    **{'Cheung 2004', 'Finlayson 2015', 'Vandermonde'}**
"""
Ejemplo n.º 31
0
    x, y = tsplit(xy)
    Y = to_domain_100(Y)
    x_n, y_n = tsplit(xy_n)

    W = Y + 800 * (x_n - x) + 1700 * (y_n - y)
    T = (1000 if '1931' in observer else 900) * (x_n - x) - 650 * (y_n - y)

    WT = tstack([W, T])

    return from_range_100(WT)


WHITENESS_METHODS = CaseInsensitiveMapping({
    'Berger 1959': whiteness_Berger1959,
    'Taube 1960': whiteness_Taube1960,
    'Stensby 1968': whiteness_Stensby1968,
    'ASTM E313': whiteness_ASTME313,
    'Ganz 1979': whiteness_Ganz1979,
    'CIE 2004': whiteness_CIE2004
})
WHITENESS_METHODS.__doc__ = """
Supported *whiteness* computation methods.

References
----------
:cite:`CIETC1-482004k`, :cite:`X-Rite2012a`

WHITENESS_METHODS : CaseInsensitiveMapping
    **{'CIE 2004', 'Berger 1959', 'Taube 1960', 'Stensby 1968', 'ASTM E313',
    'Ganz 1979', 'CIE 2004'}**

Aliases:
Ejemplo n.º 32
0
    'JMh_CIECAM02_to_CAM02UCS', 'CAM02UCS_to_JMh_CIECAM02'
]


class Coefficients_UCS_Luo2006(
        namedtuple('Coefficients_UCS_Luo2006', ('K_L', 'c_1', 'c_2'))):
    """
    Defines the the class storing *Luo et al. (2006)* fitting coefficients for
    the *CAM02-LCD*, *CAM02-SCD*, and *CAM02-UCS* colourspaces.
    """


COEFFICIENTS_UCS_LUO2006 = CaseInsensitiveMapping({
    'CAM02-LCD':
    Coefficients_UCS_Luo2006(0.77, 0.007, 0.0053),
    'CAM02-SCD':
    Coefficients_UCS_Luo2006(1.24, 0.007, 0.0363),
    'CAM02-UCS':
    Coefficients_UCS_Luo2006(1.00, 0.007, 0.0228)
})
"""
*Luo et al. (2006)* fitting coefficients for the *CAM02-LCD*, *CAM02-SCD*, and
*CAM02-UCS* colourspaces.

COEFFICIENTS_UCS_LUO2006 : CaseInsensitiveMapping
    **{'CAM02-LCD', 'CAM02-SCD', 'CAM02-UCS'}**
"""


def JMh_CIECAM02_to_UCS_Luo2006(JMh, coefficients):
    """
    Converts from *CIECAM02* :math:`JMh` correlates array to one of the
Ejemplo n.º 33
0
]

R_MATRIX = np.array([
    [1.9569, -1.1882, 0.2313],
    [0.3612, 0.6388, 0.0000],
    [0.0000, 0.0000, 1.0000],
])
"""
*RLAB* colour appearance model precomputed helper matrix.

R_MATRIX : array_like, (3, 3)
"""

RLAB_VIEWING_CONDITIONS = CaseInsensitiveMapping({
    'Average': 1 / 2.3,
    'Dim': 1 / 2.9,
    'Dark': 1 / 3.5
})
RLAB_VIEWING_CONDITIONS.__doc__ = """
Reference *RLAB* colour appearance model viewing conditions.

References
----------
:cite:`Fairchild1996a`, :cite:`Fairchild2013w`

RLAB_VIEWING_CONDITIONS : CaseInsensitiveMapping
    **{'Average', 'Dim', 'Dark'}**
"""

RLAB_D_FACTOR = CaseInsensitiveMapping({
    'Hard Copy Images': 1,
Ejemplo n.º 34
0
    Examples
    --------
    >>> luminance_ASTM_D1535_08(3.74629715382)  # doctest: +ELLIPSIS
    10.1488096...
    """

    Y = 1.1914 * V - 0.22533 * (V * V) + 0.23352 * (V**3) - 0.020484 * (
        V**4) + 0.00081939 * (V**5)

    return Y


LUMINANCE_METHODS = CaseInsensitiveMapping({
    'Newhall 1943':
    luminance_newhall1943,
    'CIE 1976':
    luminance_1976,
    'ASTM D1535-08':
    luminance_ASTM_D1535_08
})
"""
Supported *luminance* computations methods.

LUMINANCE_METHODS : dict
    ('Newhall 1943', 'CIE 1976', 'ASTM D1535-08')

Aliases:

-   'cie1976': 'CIE 1976'
-   'astm2008': 'ASTM D1535-08'
"""
LUMINANCE_METHODS['cie1976'] = (LUMINANCE_METHODS['CIE 1976'])
Ejemplo n.º 35
0
        maximum_perception = 247
    else:
        maximum_perception = 246

    Y = np.exp(
        np.log(
            substrate_concentration_MichealisMenten(
                L_hdr - 0.02, maximum_perception, 2 ** epsilon)) / epsilon)

    return from_range_1(Y)


LUMINANCE_METHODS = CaseInsensitiveMapping({
    'Newhall 1943': luminance_Newhall1943,
    'ASTM D1535-08': luminance_ASTMD153508,
    'CIE 1976': luminance_CIE1976,
    'Fairchild 2010': luminance_Fairchild2010,
    'Fairchild 2011': luminance_Fairchild2011
})
LUMINANCE_METHODS.__doc__ = """
Supported *luminance* computation methods.

References
----------
:cite:`ASTMInternational2008a`, :cite:`CIETC1-482004m`, :cite:`Fairchild2010`,
:cite:`Fairchild2011`, :cite:`Newhall1943a`, :cite:`Wyszecki2000bd`

LUMINANCE_METHODS : CaseInsensitiveMapping
    **{'Newhall 1943', 'ASTM D1535-08', 'CIE 1976', 'Fairchild 2010'}**

Aliases:
Ejemplo n.º 36
0
    def __new__(cls, N_c, N_b, N_cb=None, N_bb=None):
        """
        Returns a new instance of the
        :class:`colour.appearance.Hunt_InductionFactors` class.
        """

        return super(Hunt_InductionFactors,
                     cls).__new__(cls, N_c, N_b, N_cb, N_bb)


HUNT_VIEWING_CONDITIONS = CaseInsensitiveMapping({
    'Small Areas, Uniform Background & Surrounds':
    Hunt_InductionFactors(1, 300),
    'Normal Scenes':
    Hunt_InductionFactors(1, 75),
    'Television & CRT, Dim Surrounds':
    Hunt_InductionFactors(1, 25),
    'Large Transparencies On Light Boxes':
    Hunt_InductionFactors(0.7, 25),
    'Projected Transparencies, Dark Surrounds':
    Hunt_InductionFactors(0.7, 10)
})
HUNT_VIEWING_CONDITIONS.__doc__ = """
Reference *Hunt* colour appearance model viewing conditions.

References
----------
:cite:`Fairchild2013u`, :cite:`Hunt2004b`

HUNT_VIEWING_CONDITIONS : CaseInsensitiveMapping
    **{'Small Areas, Uniform Background & Surrounds',
    'Normal Scenes',
Ejemplo n.º 37
0
__all__ += ['oetf_sRGB', 'oetf_reverse_sRGB']
__all__ += ['log_encoding_ViperLog', 'log_decoding_ViperLog']

LOG_ENCODING_CURVES = CaseInsensitiveMapping({
    'ACEScc': log_encoding_ACEScc,
    'ACEScct': log_encoding_ACEScct,
    'ACESproxy': log_encoding_ACESproxy,
    'ALEXA Log C': log_encoding_ALEXALogC,
    'Canon Log 2': log_encoding_CanonLog2,
    'Canon Log 3': log_encoding_CanonLog3,
    'Canon Log': log_encoding_CanonLog,
    'Cineon': log_encoding_Cineon,
    'D-Log': log_encoding_DJIDLog,
    'ERIMM RGB': log_encoding_ERIMMRGB,
    'Filmic Pro 6': log_encoding_FilmicPro6,
    'Log3G10': log_encoding_Log3G10,
    'Log3G12': log_encoding_Log3G12,
    'Panalog': log_encoding_Panalog,
    'PLog': log_encoding_PivotedLog,
    'Protune': log_encoding_Protune,
    'REDLog': log_encoding_REDLog,
    'REDLogFilm': log_encoding_REDLogFilm,
    'S-Log': log_encoding_SLog,
    'S-Log2': log_encoding_SLog2,
    'S-Log3': log_encoding_SLog3,
    'T-Log': log_encoding_FilmLightTLog,
    'V-Log': log_encoding_VLog,
    'ViperLog': log_encoding_ViperLog
})
LOG_ENCODING_CURVES.__doc__ = """
Supported *log* encoding curves.
Ejemplo n.º 38
0
    'CCS_LIGHT_SOURCES_NIST_PHILIPS_STANDARD_OBSERVER_10_DEGREE_CIE1964',
    'CCS_LIGHT_SOURCES_COMMON_STANDARD_OBSERVER_2_DEGREE_CIE1931',
    'CCS_LIGHT_SOURCES_COMMON_STANDARD_OBSERVER_10_DEGREE_CIE1964',
    'CCS_LIGHT_SOURCES'
]

CCS_LIGHT_SOURCES_RIT_STANDARD_OBSERVER_2_DEGREE_CIE1931 = (
    CaseInsensitiveMapping({
        'Natural':
        np.array([0.381585730647787, 0.359224138274067]),
        'Philips TL-84':
        np.array([0.378413599970988, 0.379290254544090]),
        'SA':
        np.array([0.447573030734154, 0.407438137156467]),
        'SC':
        np.array([0.310056734303928, 0.316145704789204]),
        'T8 Luxline Plus White':
        np.array([0.410492204086250, 0.388932529676840]),
        'T8 Polylux 3000':
        np.array([0.431706082207185, 0.413877736072647]),
        'T8 Polylux 4000':
        np.array([0.379219473139794, 0.384469085577631]),
        'Thorn Kolor-rite':
        np.array([0.381919124282806, 0.374309261641251])
    }))
"""
Chromaticity coordinates of the light sources from the *RIT* *PointerData.xls*
spreadsheet for the *CIE 1931 2 Degree Standard Observer*.

Warnings
--------
The chromaticity coordinates have been calculated from *PointerData.xls*
LIGHT_SOURCES_PROJECTORS_CIE_1964_10_DEGREE_STANDARD_OBSERVER = (
    CaseInsensitiveMapping({
        'Kinoton 75P': np.array([0.317086642148234, 0.336222428041514])
    }))
"""
Projectors and Xenon Arc Lamps. [3_]

LIGHT_SOURCES_PROJECTORS_CIE_1964_10_DEGREE_STANDARD_OBSERVER :
    CaseInsensitiveMapping
    **{'Kinoton 75P', }**
"""

LIGHT_SOURCES = CaseInsensitiveMapping({
    'CIE 1931 2 Degree Standard Observer':
        CaseInsensitiveMapping(
            LIGHT_SOURCES_RIT_CIE_1931_2_DEGREE_STANDARD_OBSERVER),
    'CIE 1964 10 Degree Standard Observer':
        CaseInsensitiveMapping(
            LIGHT_SOURCES_RIT_CIE_1964_10_DEGREE_STANDARD_OBSERVER)
})
LIGHT_SOURCES.__doc__ = """
Aggregated light sources chromaticity coordinates.

LIGHT_SOURCES : CaseInsensitiveMapping
    **{'CIE 1931 2 Degree Standard Observer',
    'CIE 1964 10 Degree Standard Observer'}**

Aliases:

-   'cie_2_1931': 'CIE 1931 2 Degree Standard Observer'
-   'cie_10_1964': 'CIE 1964 10 Degree Standard Observer'
"""
Ejemplo n.º 40
0
DNG_ILLUMINANTS_CORRELATED_COLOUR_TEMPERATURE = (CaseInsensitiveMapping({
    'Standard light A':
    2850,
    'Tungsten (incandescent light)':
    2850,
    'ISO studio tungsten':
    3200,
    'D50':
    5000,
    'D55':
    5500,
    'Daylight':
    5500,
    'Fine weather':
    5500,
    'Flash':
    5500,
    'Standard light B':
    5500,
    'D65':
    6500,
    'Standard light C':
    6500,
    'Cloudy weather':
    6500,
    'D75':
    7500,
    'Shade':
    7500,
    'Daylight fluorescent (D 5700 - 7100K)': (5700 + 7100) * 0.5,
    'Day white fluorescent (N 4600 - 5500K)': (4600 + 5400) * 0.5,
    'Cool white fluorescent (W 3800 - 4500K)': (3900 + 4500) * 0.5,
    'Fluorescent': (3900 + 4500) * 0.5,
    'White fluorescent (WW 3250 - 3800K)': (3200 + 3700) * 0.5,
    'Warm white fluorescent (L 2600 - 3250K)': (2600 + 3250) * 0.5
}))
Ejemplo n.º 41
0
        HUNTERLAB_ILLUMINANTS_CIE_1964_10_DEGREE_STANDARD_OBSERVER_DATA
    }))
"""
*Hunter L,a,b* illuminant dataset for *CIE 1964 10 Degree Standard Observer*.

References
----------
:cite:`HunterLab2008b`, :cite:`HunterLab2008c`

HUNTERLAB_ILLUMINANTS_CIE_1964_10_DEGREE_STANDARD_OBSERVER :
    CaseInsensitiveMapping
"""

HUNTERLAB_ILLUMINANTS = CaseInsensitiveMapping({
    'CIE 1931 2 Degree Standard Observer':
        HUNTERLAB_ILLUMINANTS_CIE_1931_2_DEGREE_STANDARD_OBSERVER,
    'CIE 1964 10 Degree Standard Observer':
        HUNTERLAB_ILLUMINANTS_CIE_1964_10_DEGREE_STANDARD_OBSERVER
})
HUNTERLAB_ILLUMINANTS.__doc__ = """
Aggregated *Hunter L,a,b* illuminant dataset.

References
----------
:cite:`HunterLab2008b`, :cite:`HunterLab2008c`

HUNTERLAB_ILLUMINANTS : CaseInsensitiveMapping
    **{'CIE 1931 2 Degree Standard Observer',
    'CIE 1964 10 Degree Standard Observer'}**

Aliases:
Ejemplo n.º 42
0
    'chromatic_adaptation_matrix_VonKries', 'chromatic_adaptation_VonKries'
]
__all__ += ['chromatic_adaptation_Fairchild1990']
__all__ += [
    'CMCCAT2000_InductionFactors', 'CMCCAT2000_VIEWING_CONDITIONS',
    'chromatic_adaptation_forward_CMCCAT2000',
    'chromatic_adaptation_reverse_CMCCAT2000',
    'chromatic_adaptation_CMCCAT2000'
]
__all__ += ['chromatic_adaptation_CIE1994']

CHROMATIC_ADAPTATION_METHODS = CaseInsensitiveMapping({
    'CIE 1994':
    chromatic_adaptation_CIE1994,
    'CMCCAT2000':
    chromatic_adaptation_CMCCAT2000,
    'Fairchild 1990':
    chromatic_adaptation_Fairchild1990,
    'Von Kries':
    chromatic_adaptation_VonKries,
})
CHROMATIC_ADAPTATION_METHODS.__doc__ = """
Supported chromatic adaptation methods.

References
----------
:cite:`CIETC1-321994b`, :cite:`Fairchild1991a`, :cite:`Fairchild2013s`,
:cite:`Fairchild2013t`, :cite:`Li2002a`, :cite:`Westland2012k`

CHROMATIC_ADAPTATION_METHODS : CaseInsensitiveMapping
    **{'CIE 1994', 'CMCCAT2000', 'Fairchild 1990', 'Von Kries'}**
"""
Ejemplo n.º 43
0
            0.00630978795372749960,
            0.00414367215817645990,
            0.00059244446107236802),
        680.0: (
            0.00528874383171553000,
            0.00183198958165669010,
            0.00468563680483140980)
    }
}  # yapf: disable

DSLR_CAMERAS_RGB_SPECTRAL_SENSITIVITIES = CaseInsensitiveMapping({
    'Nikon 5100 (NPL)':
        RGB_SpectralSensitivities(
            DSLR_CAMERAS_RGB_SPECTRAL_SENSITIVITIES_DATA['Nikon 5100 (NPL)'],
            name='Nikon 5100 (NPL)'),
    'Sigma SDMerill (NPL)':
        RGB_SpectralSensitivities(
            DSLR_CAMERAS_RGB_SPECTRAL_SENSITIVITIES_DATA[
                'Sigma SDMerill (NPL)'],
            name='Sigma SDMerill (NPL)')
})
"""
*DSLR* cameras *RGB* spectral sensitivities.

References
----------
:cite:`Darrodi2015a`

DSLR_CAMERAS_RGB_SPECTRAL_SENSITIVITIES : CaseInsensitiveMapping
    **{Nikon 5100 (NPL), Sigma SDMerill (NPL)}**
"""
Ejemplo n.º 44
0
__author__ = 'Colour Developers'
__copyright__ = 'Copyright (C) 2013-2018 - Colour Developers'
__license__ = 'New BSD License - http://opensource.org/licenses/BSD-3-Clause'
__maintainer__ = 'Colour Developers'
__email__ = '*****@*****.**'
__status__ = 'Development'

__all__ = [
    'YCBCR_WEIGHTS', 'YCbCr_ranges', 'RGB_to_YCbCr', 'YCbCr_to_RGB',
    'RGB_to_YcCbcCrc', 'YcCbcCrc_to_RGB'
]

YCBCR_WEIGHTS = CaseInsensitiveMapping({
    'ITU-R BT.601': np.array([0.2990, 0.1140]),
    'ITU-R BT.709': np.array([0.2126, 0.0722]),
    'ITU-R BT.2020': np.array([0.2627, 0.0593]),
    'SMPTE-240M': np.array([0.2122, 0.0865])
})
"""
Luma weightings presets.

References
----------
-   :cite:`InternationalTelecommunicationUnion2011e`
-   :cite:`InternationalTelecommunicationUnion2015i`
-   :cite:`InternationalTelecommunicationUnion2015h`
-   :cite:`SocietyofMotionPictureandTelevisionEngineers1999b`
-   :cite:`Wikipediaca`

YCBCR_WEIGHTS : dict
    **{'ITU-R BT.601', 'ITU-R BT.709', 'ITU-R BT.2020', 'SMPTE-240M}**
Ejemplo n.º 45
0
                                       0.5625 * spd.values[i - 1] +
                                       0.5625 * spd.values[i + 1] -
                                       0.0625 * spd.values[i + 3])

        # Discarding the additional 20nm padding intervals.
        spd.trim_wavelengths(
            SpectralShape(spd.shape.start + 20, spd.shape.end - 20, 10))

    XYZ = method(spd, cmfs, illuminant)

    return XYZ


SPECTRAL_TO_XYZ_METHODS = CaseInsensitiveMapping({
    'ASTM E308–15':
    spectral_to_XYZ_ASTME30815,
    'Integration':
    spectral_to_XYZ_integration
})
"""
Supported spectral power distribution to *CIE XYZ* tristimulus values
conversion methods

SPECTRAL_TO_XYZ_METHODS : CaseInsensitiveMapping
    **{'ASTM E308–15', 'Integration'}**

Aliases:

-   'astm2015': 'ASTM E308–15'
"""
SPECTRAL_TO_XYZ_METHODS['astm2015'] = (SPECTRAL_TO_XYZ_METHODS['ASTM E308–15'])
Ejemplo n.º 46
0
    0.3678794...
    """

    settings = {"name": f"{peak_wavelength}nm - {fwhm} FWHM - Gaussian"}
    settings.update(kwargs)

    wavelengths = shape.range()

    values = np.exp(-(((wavelengths - peak_wavelength) / fwhm)**2))

    return SpectralDistribution(values, wavelengths, **settings)


SD_GAUSSIAN_METHODS: CaseInsensitiveMapping = CaseInsensitiveMapping({
    "Normal":
    sd_gaussian_normal,
    "FWHM":
    sd_gaussian_fwhm
})
SD_GAUSSIAN_METHODS.__doc__ = """
Supported gaussian spectral distribution computation methods.
"""


def sd_gaussian(
    mu_peak_wavelength: Floating,
    sigma_fwhm: Floating,
    shape: SpectralShape = SPECTRAL_SHAPE_DEFAULT,
    method: Union[Literal["Normal", "FWHM"], str] = "Normal",
    **kwargs: Any,
) -> SpectralDistribution:
    """
Ejemplo n.º 47
0
def tristimulus_weighting_factors_ASTME202211(cmfs, illuminant, shape):
    """
    Returns a table of tristimulus weighting factors for given colour matching
    functions and illuminant using practise *ASTM E2022–11* method [1]_.

    The computed table of tristimulus weighting factors should be used with
    spectral data that has been corrected for spectral bandpass dependence.

    Parameters
    ----------
    cmfs : XYZ_ColourMatchingFunctions
        Standard observer colour matching functions.
    illuminant : SpectralPowerDistribution
        Illuminant spectral power distribution.
    shape : SpectralShape
        Shape used to build the table, only the interval is needed.

    Returns
    -------
    ndarray
        Tristimulus weighting factors table.

    Raises
    ------
    ValueError
        If the colour matching functions or illuminant intervals are not equal
        to 1 nm.

    Warning
    -------
    -   The tables of tristimulus weighting factors are cached in
        :attr:`_TRISTIMULUS_WEIGHTING_FACTORS_CACHE` attribute. Their
        identifier key is defined by the colour matching functions and
        illuminant names along the current shape such as:
        `CIE 1964 10 Degree Standard Observer, A, (360.0, 830.0, 10.0)`
        Considering the above, one should be mindful that using similar colour
        matching functions and illuminant names but with different spectral
        data will lead to unexpected behaviour.

    Notes
    -----
    -   Input colour matching functions and illuminant intervals are expected
        to be equal to 1 nm. If the illuminant data is not available at 1 nm
        interval, it needs to be interpolated using *CIE* recommendations:
        The method developed by Sprague (1880) should be used for interpolating
        functions having a uniformly spaced independent variable and a
        *Cubic Spline* method for non-uniformly spaced independent variable.

    Examples
    --------
    >>> from colour import (
    ...     CMFS,
    ...     CIE_standard_illuminant_A_function,
    ...     SpectralPowerDistribution,
    ...     SpectralShape)
    >>> cmfs = CMFS.get('CIE 1964 10 Degree Standard Observer')
    >>> wl = cmfs.shape.range()
    >>> A = SpectralPowerDistribution(
    ...     'A (360, 830, 1)',
    ...     dict(zip(wl, CIE_standard_illuminant_A_function(wl))))
    >>> tristimulus_weighting_factors_ASTME202211(  # doctest: +ELLIPSIS
    ...     cmfs, A, SpectralShape(360, 830, 20))
    array([[ -2.9816934...e-04,  -3.1709762...e-05,  -1.3301218...e-03],
           [ -8.7154955...e-03,  -8.9154168...e-04,  -4.0743684...e-02],
           [  5.9967988...e-02,   5.0203497...e-03,   2.5650183...e-01],
           [  7.7342255...e-01,   7.7983983...e-02,   3.6965732...e+00],
           [  1.9000905...e+00,   3.0370051...e-01,   9.7554195...e+00],
           [  1.9707727...e+00,   8.5528092...e-01,   1.1486732...e+01],
           [  7.1836236...e-01,   2.1457000...e+00,   6.7845806...e+00],
           [  4.2666758...e-02,   4.8985328...e+00,   2.3208000...e+00],
           [  1.5223302...e+00,   9.6471138...e+00,   7.4306714...e-01],
           [  5.6770329...e+00,   1.4460970...e+01,   1.9581949...e-01],
           [  1.2445174...e+01,   1.7474254...e+01,   5.1826979...e-03],
           [  2.0553577...e+01,   1.7583821...e+01,  -2.6512696...e-03],
           [  2.5331538...e+01,   1.4895703...e+01,   0.0000000...e+00],
           [  2.1571157...e+01,   1.0079661...e+01,   0.0000000...e+00],
           [  1.2178581...e+01,   5.0680655...e+00,   0.0000000...e+00],
           [  4.6675746...e+00,   1.8303239...e+00,   0.0000000...e+00],
           [  1.3236117...e+00,   5.1296946...e-01,   0.0000000...e+00],
           [  3.1753258...e-01,   1.2300847...e-01,   0.0000000...e+00],
           [  7.4634128...e-02,   2.9024389...e-02,   0.0000000...e+00],
           [  1.8299016...e-02,   7.1606335...e-03,   0.0000000...e+00],
           [  4.7942065...e-03,   1.8888730...e-03,   0.0000000...e+00],
           [  1.3293045...e-03,   5.2774591...e-04,   0.0000000...e+00],
           [  4.2546928...e-04,   1.7041978...e-04,   0.0000000...e+00],
           [  9.6251115...e-05,   3.8955295...e-05,   0.0000000...e+00]])
    """

    if cmfs.shape.interval != 1:
        raise ValueError('"{0}" shape "interval" must be 1!'.format(cmfs))

    if illuminant.shape.interval != 1:
        raise ValueError(
            '"{0}" shape "interval" must be 1!'.format(illuminant))

    global _TRISTIMULUS_WEIGHTING_FACTORS_CACHE
    if _TRISTIMULUS_WEIGHTING_FACTORS_CACHE is None:
        _TRISTIMULUS_WEIGHTING_FACTORS_CACHE = CaseInsensitiveMapping()

    name_twf = ', '.join((cmfs.name, illuminant.name, str(shape)))
    if name_twf in _TRISTIMULUS_WEIGHTING_FACTORS_CACHE:
        return _TRISTIMULUS_WEIGHTING_FACTORS_CACHE[name_twf]

    Y = cmfs.values
    S = illuminant.values

    W = S[::shape.interval, np.newaxis] * Y[::shape.interval, :]

    # First and last measurement intervals *Lagrange Coefficients*.
    c_c = lagrange_coefficients_ASTME202211(shape.interval, 'boundary')
    # Intermediate measurement intervals *Lagrange Coefficients*.
    c_b = lagrange_coefficients_ASTME202211(shape.interval, 'inner')

    # Total wavelengths count.
    w_c = len(Y)
    # Measurement interval interpolated values count.
    r_c = c_b.shape[0]
    # Last interval first interpolated wavelength.
    w_lif = w_c - (w_c - 1) % shape.interval - 1 - r_c

    # Intervals count.
    i_c = W.shape[0]
    i_cm = i_c - 1

    for i in range(3):
        # First interval.
        for j in range(r_c):
            for k in range(3):
                W[k, i] = W[k, i] + c_c[j, k] * S[j + 1] * Y[j + 1, i]

        # Last interval.
        for j in range(r_c):
            for k in range(i_cm, i_cm - 3, -1):
                W[k, i] = (W[k, i] + c_c[r_c - j - 1, i_cm - k] *
                           S[j + w_lif] * Y[j + w_lif, i])

        # Intermediate intervals.
        for j in range(i_c - 3):
            for k in range(r_c):
                w_i = (r_c + 1) * (j + 1) + 1 + k
                W[j, i] = W[j, i] + c_b[k, 0] * S[w_i] * Y[w_i, i]
                W[j + 1, i] = W[j + 1, i] + c_b[k, 1] * S[w_i] * Y[w_i, i]
                W[j + 2, i] = W[j + 2, i] + c_b[k, 2] * S[w_i] * Y[w_i, i]
                W[j + 3, i] = W[j + 3, i] + c_b[k, 3] * S[w_i] * Y[w_i, i]

        # Extrapolation of potential incomplete interval.
        for j in range(int(w_c - ((w_c - 1) % shape.interval)), w_c, 1):
            W[i_cm, i] = W[i_cm, i] + S[j] * Y[j, i]

    W *= 100 / np.sum(W, axis=0)[1]

    _TRISTIMULUS_WEIGHTING_FACTORS_CACHE[name_twf] = W

    return W
Ejemplo n.º 48
0
        *Lightness* induction factor :math:`F_L`.
    F_C : numeric or array_like
        *Chroma* induction factor :math:`F_C`.

    References
    ----------
    :cite:`Fairchild2013x`, :cite:`Luo1996b`, :cite:`Luo1996c`
    """


VIEWING_CONDITIONS_LLAB = CaseInsensitiveMapping({
    'Reference Samples & Images, Average Surround, Subtending > 4':
    (InductionFactors_LLAB(1, 3, 0, 1)),
    'Reference Samples & Images, Average Surround, Subtending < 4':
    (InductionFactors_LLAB(1, 3, 1, 1)),
    'Television & VDU Displays, Dim Surround':
    (InductionFactors_LLAB(0.7, 3.5, 1, 1)),
    'Cut Sheet Transparency, Dim Surround':
    (InductionFactors_LLAB(1, 5, 1, 1.1)),
    '35mm Projection Transparency, Dark Surround':
    (InductionFactors_LLAB(0.7, 4, 1, 1))
})
VIEWING_CONDITIONS_LLAB.__doc__ = """
Reference :math:`LLAB(l:c)` colour appearance model viewing conditions.

References
----------
:cite:`Fairchild2013x`, :cite:`Luo1996b`, :cite:`Luo1996c`

VIEWING_CONDITIONS_LLAB : CaseInsensitiveMapping
    **{'Reference Samples & Images, Average Surround, Subtending > 4',
    'Reference Samples & Images, Average Surround, Subtending < 4',
Ejemplo n.º 49
0
        for i in range(3, len(sd.domain) - 3, 2):
            sd[sd.wavelengths[i]] = (-0.0625 * sd.values[i - 3] +
                                     0.5625 * sd.values[i - 1] +
                                     0.5625 * sd.values[i + 1] -
                                     0.0625 * sd.values[i + 3])

        # Discarding the additional 20nm padding intervals.
        sd.trim(SpectralShape(sd.shape.start + 20, sd.shape.end - 20, 10))

    XYZ = method(sd, cmfs, illuminant)

    return XYZ


SD_TO_XYZ_METHODS = CaseInsensitiveMapping({
    'ASTM E308-15': sd_to_XYZ_ASTME30815,
    'Integration': sd_to_XYZ_integration
})
SD_TO_XYZ_METHODS.__doc__ = """
Supported spectral distribution to *CIE XYZ* tristimulus values conversion
methods.

References
----------
:cite:`ASTMInternational2011a`, :cite:`ASTMInternational2015b`,
:cite:`Wyszecki2000bf`

SD_TO_XYZ_METHODS : CaseInsensitiveMapping
    **{'ASTM E308-15', 'Integration'}**

Aliases:
Ejemplo n.º 50
0
ILLUMINANTS_CIE_1931_2_DEGREE_STANDARD_OBSERVER = CaseInsensitiveMapping({
    'A':
    np.array([0.44758, 0.40745]),
    'B':
    np.array([0.34842, 0.35161]),
    'C':
    np.array([0.31006, 0.31616]),
    'D50':
    np.array([0.34570, 0.35850]),
    'D55':
    np.array([0.33243, 0.34744]),
    'D60':
    np.array([0.321626242047397, 0.337736995955436]),
    'D65':
    np.array([0.31270, 0.32900]),
    'D75':
    np.array([0.29903, 0.31488]),
    'E':
    np.array([1 / 3, 1 / 3]),
    'FL1':
    np.array([0.31310, 0.33710]),
    'FL2':
    np.array([0.37210, 0.37510]),
    'FL3':
    np.array([0.40910, 0.39410]),
    'FL4':
    np.array([0.44020, 0.40310]),
    'FL5':
    np.array([0.31380, 0.34520]),
    'FL6':
    np.array([0.37790, 0.38820]),
    'FL7':
    np.array([0.31290, 0.32920]),
    'FL8':
    np.array([0.34580, 0.35860]),
    'FL9':
    np.array([0.37410, 0.37270]),
    'FL10':
    np.array([0.34580, 0.35880]),
    'FL11':
    np.array([0.38050, 0.37690]),
    'FL12':
    np.array([0.43700, 0.40420])
})
Ejemplo n.º 51
0
def tristimulus_weighting_factors_ASTME202211(cmfs, illuminant, shape):
    """
    Returns a table of tristimulus weighting factors for given colour matching
    functions and illuminant using practise *ASTM E2022-11* method.

    The computed table of tristimulus weighting factors should be used with
    spectral data that has been corrected for spectral bandpass dependence.

    Parameters
    ----------
    cmfs : XYZ_ColourMatchingFunctions
        Standard observer colour matching functions.
    illuminant : SpectralDistribution
        Illuminant spectral distribution.
    shape : SpectralShape
        Shape used to build the table, only the interval is needed.

    Returns
    -------
    ndarray
        Tristimulus weighting factors table.

    Raises
    ------
    ValueError
        If the colour matching functions or illuminant intervals are not equal
        to 1 nm.

    Warning
    -------
    -   The tables of tristimulus weighting factors are cached in
        :attr:`colour.colorimetry.tristimulus.\
_TRISTIMULUS_WEIGHTING_FACTORS_CACHE` attribute. Their identifier key is
        defined by the colour matching functions and illuminant names along
        the current shape such as:
        `CIE 1964 10 Degree Standard Observer, A, (360.0, 830.0, 10.0)`
        Considering the above, one should be mindful that using similar colour
        matching functions and illuminant names but with different spectral
        data will lead to unexpected behaviour.

    Notes
    -----
    -   Input colour matching functions and illuminant intervals are expected
        to be equal to 1 nm. If the illuminant data is not available at 1 nm
        interval, it needs to be interpolated using *CIE* recommendations:
        The method developed by *Sprague (1880)* should be used for
        interpolating functions having a uniformly spaced independent variable
        and a *Cubic Spline* method for non-uniformly spaced independent
        variable.

    References
    ----------
    :cite:`ASTMInternational2011a`

    Examples
    --------
    >>> from colour import (CMFS, sd_CIE_standard_illuminant_A,
    ...     SpectralDistribution, SpectralShape)
    >>> from colour.utilities import numpy_print_options
    >>> cmfs = CMFS['CIE 1964 10 Degree Standard Observer']
    >>> A = sd_CIE_standard_illuminant_A(cmfs.shape)
    >>> with numpy_print_options(suppress=True):
    ...     tristimulus_weighting_factors_ASTME202211(
    ...         cmfs, A, SpectralShape(360, 830, 20))
    ... # doctest: +ELLIPSIS
    array([[ -0.0002981...,  -0.0000317...,  -0.0013301...],
           [ -0.0087155...,  -0.0008915...,  -0.0407436...],
           [  0.0599679...,   0.0050203...,   0.2565018...],
           [  0.7734225...,   0.0779839...,   3.6965732...],
           [  1.9000905...,   0.3037005...,   9.7554195...],
           [  1.9707727...,   0.8552809...,  11.4867325...],
           [  0.7183623...,   2.1457000...,   6.7845806...],
           [  0.0426667...,   4.8985328...,   2.3208000...],
           [  1.5223302...,   9.6471138...,   0.7430671...],
           [  5.6770329...,  14.4609708...,   0.1958194...],
           [ 12.4451744...,  17.4742541...,   0.0051827...],
           [ 20.5535772...,  17.5838219...,  -0.0026512...],
           [ 25.3315384...,  14.8957035...,   0.       ...],
           [ 21.5711570...,  10.0796619...,   0.       ...],
           [ 12.1785817...,   5.0680655...,   0.       ...],
           [  4.6675746...,   1.8303239...,   0.       ...],
           [  1.3236117...,   0.5129694...,   0.       ...],
           [  0.3175325...,   0.1230084...,   0.       ...],
           [  0.0746341...,   0.0290243...,   0.       ...],
           [  0.0182990...,   0.0071606...,   0.       ...],
           [  0.0047942...,   0.0018888...,   0.       ...],
           [  0.0013293...,   0.0005277...,   0.       ...],
           [  0.0004254...,   0.0001704...,   0.       ...],
           [  0.0000962...,   0.0000389...,   0.       ...]])
    """

    if cmfs.shape.interval != 1:
        raise ValueError('"{0}" shape "interval" must be 1!'.format(cmfs))

    if illuminant.shape.interval != 1:
        raise ValueError(
            '"{0}" shape "interval" must be 1!'.format(illuminant))

    global _TRISTIMULUS_WEIGHTING_FACTORS_CACHE
    if _TRISTIMULUS_WEIGHTING_FACTORS_CACHE is None:
        _TRISTIMULUS_WEIGHTING_FACTORS_CACHE = CaseInsensitiveMapping()

    name_twf = ', '.join((cmfs.name, illuminant.name, str(shape)))
    if name_twf in _TRISTIMULUS_WEIGHTING_FACTORS_CACHE:
        return _TRISTIMULUS_WEIGHTING_FACTORS_CACHE[name_twf]

    Y = cmfs.values
    S = illuminant.values

    interval_i = DEFAULT_INT_DTYPE(shape.interval)
    W = S[::interval_i, np.newaxis] * Y[::interval_i, :]

    # First and last measurement intervals *Lagrange Coefficients*.
    c_c = lagrange_coefficients_ASTME202211(interval_i, 'boundary')
    # Intermediate measurement intervals *Lagrange Coefficients*.
    c_b = lagrange_coefficients_ASTME202211(interval_i, 'inner')

    # Total wavelengths count.
    w_c = len(Y)
    # Measurement interval interpolated values count.
    r_c = c_b.shape[0]
    # Last interval first interpolated wavelength.
    w_lif = w_c - (w_c - 1) % interval_i - 1 - r_c

    # Intervals count.
    i_c = W.shape[0]
    i_cm = i_c - 1

    for i in range(3):
        # First interval.
        for j in range(r_c):
            for k in range(3):
                W[k, i] = W[k, i] + c_c[j, k] * S[j + 1] * Y[j + 1, i]

        # Last interval.
        for j in range(r_c):
            for k in range(i_cm, i_cm - 3, -1):
                W[k, i] = (W[k, i] + c_c[r_c - j - 1, i_cm - k] *
                           S[j + w_lif] * Y[j + w_lif, i])

        # Intermediate intervals.
        for j in range(i_c - 3):
            for k in range(r_c):
                w_i = (r_c + 1) * (j + 1) + 1 + k
                W[j, i] = W[j, i] + c_b[k, 0] * S[w_i] * Y[w_i, i]
                W[j + 1, i] = W[j + 1, i] + c_b[k, 1] * S[w_i] * Y[w_i, i]
                W[j + 2, i] = W[j + 2, i] + c_b[k, 2] * S[w_i] * Y[w_i, i]
                W[j + 3, i] = W[j + 3, i] + c_b[k, 3] * S[w_i] * Y[w_i, i]

        # Extrapolation of potential incomplete interval.
        for j in range(DEFAULT_INT_DTYPE(w_c - ((w_c - 1) % interval_i)), w_c,
                       1):
            W[i_cm, i] = W[i_cm, i] + S[j] * Y[j, i]

    W *= 100 / np.sum(W, axis=0)[1]

    _TRISTIMULUS_WEIGHTING_FACTORS_CACHE[name_twf] = W

    return W
"""

COLORCHECKER24_AFTER_NOV2014 = ColourChecker(
    'ColorChecker24 - After November 2014', COLORCHECKER24_AFTER_NOV2014_DATA,
    COLORCHECKER24_AFTER_NOV2014_ILLUMINANT)
"""
Reference *ColourChecker* data from *X-Rite (2015)* and matching the
*ColourChecker* edition after November 2014.

COLORCHECKER24_AFTER_NOV2014 : ColourChecker
"""

COLOURCHECKERS = CaseInsensitiveMapping({
    'ColorChecker 1976': COLORCHECKER_1976,
    'ColorChecker 2005': COLORCHECKER_2005,
    'BabelColor Average': BABELCOLOR_AVERAGE,
    'ColorChecker24 - Before November 2014': COLORCHECKER24_BEFORE_NOV2014,
    'ColorChecker24 - After November 2014': COLORCHECKER24_AFTER_NOV2014,
})
COLOURCHECKERS.__doc__ = """
Aggregated *ColourCheckers* chromaticity coordinates.

References
----------
:cite:`BabelColor2012b`, :cite:`BabelColor2012c`, :cite:`X-Rite2015`

COLOURCHECKERS : CaseInsensitiveMapping
    **{'ColorChecker 1976', 'ColorChecker 2005', 'BabelColor Average',
    'ColorChecker24 - Before November 2014',
    'ColorChecker24 - After November 2014'}**
Ejemplo n.º 53
0
def lagrange_coefficients_ASTME202211(interval=10, interval_type='inner'):
    """
    Computes the *Lagrange Coefficients* for given interval size using practise
    *ASTM E2022-11* method.

    Parameters
    ----------
    interval : int
        Interval size in nm.
    interval_type : unicode, optional
        **{'inner', 'boundary'}**,
        If the interval is an *inner* interval *Lagrange Coefficients* are
        computed for degree 4. Degree 3 is used for a *boundary* interval.

    Returns
    -------
    ndarray
        *Lagrange Coefficients*.

    References
    ----------
    :cite:`ASTMInternational2011a`

    Examples
    --------
    >>> lagrange_coefficients_ASTME202211(10, 'inner')
    ... # doctest: +ELLIPSIS
    array([[-0.028...,  0.940...,  0.104..., -0.016...],
           [-0.048...,  0.864...,  0.216..., -0.032...],
           [-0.059...,  0.773...,  0.331..., -0.045...],
           [-0.064...,  0.672...,  0.448..., -0.056...],
           [-0.062...,  0.562...,  0.562..., -0.062...],
           [-0.056...,  0.448...,  0.672..., -0.064...],
           [-0.045...,  0.331...,  0.773..., -0.059...],
           [-0.032...,  0.216...,  0.864..., -0.048...],
           [-0.016...,  0.104...,  0.940..., -0.028...]])
    >>> lagrange_coefficients_ASTME202211(10, 'boundary')
    ... # doctest: +ELLIPSIS
    array([[ 0.85...,  0.19..., -0.04...],
           [ 0.72...,  0.36..., -0.08...],
           [ 0.59...,  0.51..., -0.10...],
           [ 0.48...,  0.64..., -0.12...],
           [ 0.37...,  0.75..., -0.12...],
           [ 0.28...,  0.84..., -0.12...],
           [ 0.19...,  0.91..., -0.10...],
           [ 0.12...,  0.96..., -0.08...],
           [ 0.05...,  0.99..., -0.04...]])
    """

    global _LAGRANGE_INTERPOLATING_COEFFICIENTS_CACHE
    if _LAGRANGE_INTERPOLATING_COEFFICIENTS_CACHE is None:
        _LAGRANGE_INTERPOLATING_COEFFICIENTS_CACHE = CaseInsensitiveMapping()

    name_lica = ', '.join((str(interval), interval_type))
    if name_lica in _LAGRANGE_INTERPOLATING_COEFFICIENTS_CACHE:
        return _LAGRANGE_INTERPOLATING_COEFFICIENTS_CACHE[name_lica]

    r_n = np.linspace(1 / interval, 1 - (1 / interval), interval - 1)
    d = 3
    if interval_type.lower() == 'inner':
        r_n += 1
        d = 4

    lica = _LAGRANGE_INTERPOLATING_COEFFICIENTS_CACHE[name_lica] = (
        as_float_array([lagrange_coefficients(r, d) for r in r_n]))

    return lica
Ejemplo n.º 54
0
    --------
    >>> import numpy as np
    >>> XYZ = np.array([95.00000000, 100.00000000, 105.00000000])
    >>> yellowness_ASTME313(XYZ)  # doctest: +ELLIPSIS
    11.0650000...
    """

    _X, Y, Z = tsplit(to_domain_100(XYZ))

    WI = 100 * (1 - (0.847 * Z) / Y)

    return from_range_100(WI)


YELLOWNESS_METHODS = CaseInsensitiveMapping({
    'ASTM D1925': yellowness_ASTMD1925,
    'ASTM E313': yellowness_ASTME313
})
YELLOWNESS_METHODS.__doc__ = """
Supported *yellowness* computation methods.

References
----------
:cite:`X-Rite2012a`

YELLOWNESS_METHODS : CaseInsensitiveMapping
    **{'ASTM E313', 'ASTM D1925'}**
"""


def yellowness(XYZ, method='ASTM E313'):
    """
Ejemplo n.º 55
0
    x, y = tsplit(xy)
    Y = to_domain_100(Y)
    x_n, y_n = tsplit(xy_n)

    W = Y + 800 * (x_n - x) + 1700 * (y_n - y)
    T = (1000 if '1931' in observer else 900) * (x_n - x) - 650 * (y_n - y)

    WT = tstack([W, T])

    return from_range_100(WT)


WHITENESS_METHODS = CaseInsensitiveMapping({
    'Berger 1959': whiteness_Berger1959,
    'Taube 1960': whiteness_Taube1960,
    'Stensby 1968': whiteness_Stensby1968,
    'ASTM E313': whiteness_ASTME313,
    'Ganz 1979': whiteness_Ganz1979,
    'CIE 2004': whiteness_CIE2004
})
WHITENESS_METHODS.__doc__ = """
Supported *whiteness* computations methods.

References
----------
:cite:`CIETC1-482004k`, :cite:`X-Rite2012a`

WHITENESS_METHODS : CaseInsensitiveMapping
    **{'CIE 2004', 'Berger 1959', 'Taube 1960', 'Stensby 1968', 'ASTM E313',
    'Ganz 1979', 'CIE 2004'}**

Aliases:
Ejemplo n.º 56
0
     [0.3295, 0.3331, 95],
     [0.3167, 0.3189, 95],
     [0.3148, 0.3195, 95],
     [0.3103, 0.3214, 95],
     [0.3006, 0.3259, 95],
     [0.2900, 0.3308, 95],
     [0.3127, 0.3290, 100]])  # yapf: disable
"""
*CIE Standard Illuminant D Series D65* *Optimal Colour Stimuli*.

D65_OPTIMAL_COLOUR_STIMULI : ndarray

References
----------
.. [4]  Wyszecki, G., & Stiles, W. S. (2000). Table II(3.7). In Color Science:
        Concepts and Methods, Quantitative Data and Formulae (pp. 778–779).
        Wiley. ISBN:978-0471399186
"""

ILLUMINANTS_OPTIMAL_COLOUR_STIMULI = CaseInsensitiveMapping({
    'A': A_OPTIMAL_COLOUR_STIMULI,
    'C': C_OPTIMAL_COLOUR_STIMULI,
    'D65': D65_OPTIMAL_COLOUR_STIMULI
})
"""
Illuminants *Optimal Colour Stimuli*.

ILLUMINANTS_OPTIMAL_COLOUR_STIMULI : CaseInsensitiveMapping
    **{'A', 'C', 'D65'}**
"""
Ejemplo n.º 57
0
:cite:`Bianco2010a`

BS_PC_CAT : array_like, (3, 3)

Notes
-----
-   This chromatic adaptation transform has no negative lobes.
"""

CHROMATIC_ADAPTATION_TRANSFORMS = CaseInsensitiveMapping({
    'XYZ Scaling': XYZ_SCALING_CAT,
    'Von Kries': VON_KRIES_CAT,
    'Bradford': BRADFORD_CAT,
    'Sharp': SHARP_CAT,
    'Fairchild': FAIRCHILD_CAT,
    'CMCCAT97': CMCCAT97_CAT,
    'CMCCAT2000': CMCCAT2000_CAT,
    'CAT02': CAT02_CAT,
    'CAT02_BRILL_CAT': CAT02_BRILL_CAT,
    'Bianco': BS_CAT,
    'Bianco PC': BS_PC_CAT
})
CHROMATIC_ADAPTATION_TRANSFORMS.__doc__ = """
Supported chromatic adaptation transforms.

References
----------
:cite:`Bianco2010a`, :cite:`Brill2008a`, :cite:`Fairchildb`, :cite:`Li2007e`,
:cite:`Lindbloom2009g`, :cite:`Westland2012g`, :cite:`Westland2012k`,
:cite:`Wikipedia2007`