Пример #1
0
    def test_nan_oetf_inverse_HLG_BT2100(self):
        """
        Tests :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\
oetf_inverse_HLG_BT2100` definition nan support.
        """

        oetf_inverse_HLG_BT2100(
            np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan]))
Пример #2
0
    def test_oetf_inverse_HLG_BT2100(self):
        """
        Tests :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\
oetf_inverse_HLG_BT2100` definition.
        """

        self.assertAlmostEqual(oetf_inverse_HLG_BT2100(0.0), 0.0, places=7)

        self.assertAlmostEqual(
            oetf_inverse_HLG_BT2100(0.212132034355964), 0.18 / 12, places=7)

        self.assertAlmostEqual(
            oetf_inverse_HLG_BT2100(0.999999995536569), 1.0, places=7)
Пример #3
0
    def test_domain_range_scale_oetf_inverse_HLG_BT2100(self):
        """
        Tests :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\
oetf_inverse_HLG_BT2100` definition domain and range scale support.
        """

        E_p = 0.212132034355964
        E = oetf_inverse_HLG_BT2100(E_p)

        d_r = (('reference', 1), (1, 1), (100, 100))
        for scale, factor in d_r:
            with domain_range_scale(scale):
                np.testing.assert_almost_equal(
                    oetf_inverse_HLG_BT2100(E_p * factor),
                    E * factor,
                    decimal=7)
Пример #4
0
    def test_n_dimensional_oetf_inverse_HLG_BT2100(self):
        """
        Tests :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\
oetf_inverse_HLG_BT2100` definition n-dimensional arrays support.
        """

        E_p = 0.212132034355964
        E = oetf_inverse_HLG_BT2100(E_p)

        E_p = np.tile(E_p, 6)
        E = np.tile(E, 6)
        np.testing.assert_almost_equal(
            oetf_inverse_HLG_BT2100(E_p), E, decimal=7)

        E_p = np.reshape(E_p, (2, 3))
        E = np.reshape(E, (2, 3))
        np.testing.assert_almost_equal(
            oetf_inverse_HLG_BT2100(E_p), E, decimal=7)

        E_p = np.reshape(E_p, (2, 3, 1))
        E = np.reshape(E, (2, 3, 1))
        np.testing.assert_almost_equal(
            oetf_inverse_HLG_BT2100(E_p), E, decimal=7)
Пример #5
0
def ICtCp_to_RGB(
    ICtCp: ArrayLike,
    method: Union[Literal["Dolby 2016", "ITU-R BT.2100-1 HLG",
                          "ITU-R BT.2100-1 PQ", "ITU-R BT.2100-2 HLG",
                          "ITU-R BT.2100-2 PQ", ], str, ] = "Dolby 2016",
    L_p: Floating = 10000,
) -> NDArray:
    """
    Convert from :math:`IC_TC_P` colour encoding to *ITU-R BT.2020*
    colourspace.

    Parameters
    ----------
    ICtCp
        :math:`IC_TC_P` colour encoding array.
    method
        Computation method. *Recommendation ITU-R BT.2100* defines multiple
        variants of the :math:`IC_TC_P` colour encoding:

        -   *ITU-R BT.2100-1*

            -   *SMPTE ST 2084:2014* inverse electro-optical transfer
                function (EOTF) and the :math:`IC_TC_P` matrix from
                :cite:`Dolby2016a`: *Dolby 2016*, *ITU-R BT.2100-1 PQ*,
                *ITU-R BT.2100-2 PQ* methods.
            -   *Recommendation ITU-R BT.2100* *Reference HLG* opto-electrical
                transfer function (OETF) and the :math:`IC_TC_P` matrix
                from :cite:`Dolby2016a`: *ITU-R BT.2100-1 HLG* method.

        -   *ITU-R BT.2100-2*

            -   *SMPTE ST 2084:2014* inverse electro-optical transfer
                function (EOTF) and the :math:`IC_TC_P` matrix from
                :cite:`Dolby2016a`: *Dolby 2016*, *ITU-R BT.2100-1 PQ*,
                *ITU-R BT.2100-2 PQ* methods.
            -   *Recommendation ITU-R BT.2100* *Reference HLG* opto-electrical
                transfer function (OETF) and a custom :math:`IC_TC_P`
                matrix from :cite:`InternationalTelecommunicationUnion2018`:
                *ITU-R BT.2100-2 HLG* method.

    L_p
        Display peak luminance :math:`cd/m^2` for *SMPTE ST 2084:2014*
        non-linear encoding. This parameter should stay at its default
        :math:`10000 cd/m^2` value for practical applications. It is exposed so
        that the definition can be used as a fitting function.

    Returns
    -------
    :class:`numpy.ndarray`
        *ITU-R BT.2020* colourspace array.

    Warnings
    --------
    The underlying *SMPTE ST 2084:2014* transfer function is an absolute
    transfer function.

    Notes
    -----
    -   The *ITU-R BT.2100-1 PQ* and *ITU-R BT.2100-2 PQ* methods are aliases
        for the *Dolby 2016* method.
    -   The underlying *SMPTE ST 2084:2014* transfer function is an absolute
        transfer function, thus the domain and range values for the *Reference*
        and *1* scales are only indicative that the data is not affected by
        scale transformations.

    +------------+-----------------------+------------------+
    | **Domain** | **Scale - Reference** | **Scale - 1**    |
    +============+=======================+==================+
    | ``ICtCp``  | ``I``  : [0, 1]       | ``I``  : [0, 1]  |
    |            |                       |                  |
    |            | ``CT`` : [-1, 1]      | ``CT`` : [-1, 1] |
    |            |                       |                  |
    |            | ``CP`` : [-1, 1]      | ``CP`` : [-1, 1] |
    +------------+-----------------------+------------------+

    +------------+-----------------------+------------------+
    | **Range**  | **Scale - Reference** | **Scale - 1**    |
    +============+=======================+==================+
    | ``RGB``    | ``UN``                | ``UN``           |
    +------------+-----------------------+------------------+

    References
    ----------
    :cite:`Dolby2016a`, :cite:`Lu2016c`

    Examples
    --------
    >>> ICtCp = np.array([0.07351364, 0.00475253, 0.09351596])
    >>> ICtCp_to_RGB(ICtCp)  # doctest: +ELLIPSIS
    array([ 0.4562052...,  0.0308107...,  0.0409195...])
    >>> ICtCp = np.array([0.62567899, -0.01984490, 0.35911259])
    >>> ICtCp_to_RGB(ICtCp, method='ITU-R BT.2100-2 HLG')  # doctest: +ELLIPSIS
    array([ 0.4562052...,  0.0308107...,  0.0409195...])
    """

    ICtCp = as_float_array(ICtCp)
    method = validate_method(
        method,
        [
            "Dolby 2016",
            "ITU-R BT.2100-1 HLG",
            "ITU-R BT.2100-1 PQ",
            "ITU-R BT.2100-2 HLG",
            "ITU-R BT.2100-2 PQ",
        ],
    )

    is_hlg_method = "hlg" in method
    is_BT2100_2_method = "2100-2" in method

    LMS_p = (vector_dot(MATRIX_ICTCP_ICTCP_TO_LMS_P_HLG_BT2100_2, ICtCp) if
             (is_hlg_method and is_BT2100_2_method) else vector_dot(
                 MATRIX_ICTCP_ICTCP_TO_LMS_P, ICtCp))

    with domain_range_scale("ignore"):
        LMS = (oetf_inverse_HLG_BT2100(LMS_p)
               if is_hlg_method else eotf_ST2084(LMS_p, L_p))

    RGB = vector_dot(MATRIX_ICTCP_LMS_TO_RGB, LMS)

    return RGB