Beispiel #1
0
    def setUp(self):
        """
        Initialises common tests attributes.
        """

        p = np.array([0.73470, 0.26530, 0.00000, 1.00000, 0.00010, -0.07700])
        whitepoint = np.array([0.32168, 0.33767])
        RGB_to_XYZ_matrix = np.identity(3)
        XYZ_to_RGB_matrix = np.identity(3)
        self._colourspace = RGB_Colourspace(
            'RGB Colourspace', p, whitepoint, 'D60', RGB_to_XYZ_matrix,
            XYZ_to_RGB_matrix, lambda x: x, lambda x: x)
    def setUp(self):
        """Initialise the common tests attributes."""

        p = np.array([0.73470, 0.26530, 0.00000, 1.00000, 0.00010, -0.07700])
        whitepoint = np.array([0.32168, 0.33767])
        matrix_RGB_to_XYZ = np.identity(3)
        matrix_XYZ_to_RGB = np.identity(3)
        self._colourspace = RGB_Colourspace(
            "RGB Colourspace",
            p,
            whitepoint,
            "ACES",
            matrix_RGB_to_XYZ,
            matrix_XYZ_to_RGB,
            lambda x: x,
            lambda x: x,
        )
    def test_use_derived_transformation_matrices(self):
        """
        Tests :func:`colour.models.rgb.rgb_colourspace.RGB_Colourspace.range.\
use_derived_transformation_matrices` method.
        """

        p = np.array([0.73470, 0.26530, 0.00000, 1.00000, 0.00010, -0.07700])
        whitepoint = np.array([0.32168, 0.33767])
        RGB_to_XYZ_matrix = np.identity(3)
        XYZ_to_RGB_matrix = np.identity(3)
        colourspace = RGB_Colourspace('RGB Colourspace', p, whitepoint, 'D60',
                                      RGB_to_XYZ_matrix, XYZ_to_RGB_matrix)

        np.testing.assert_array_equal(colourspace.RGB_to_XYZ_matrix,
                                      np.identity(3))
        np.testing.assert_array_equal(colourspace.XYZ_to_RGB_matrix,
                                      np.identity(3))

        self.assertTrue(colourspace.use_derived_transformation_matrices())

        np.testing.assert_almost_equal(
            colourspace.RGB_to_XYZ_matrix,
            np.array(
                [[0.95255240, 0.00000000, 0.00009368],
                 [0.34396645, 0.72816610, -0.07213255],
                 [0.00000000, 0.00000000, 1.00882518]]),
            decimal=7)  # yapf: disable
        np.testing.assert_almost_equal(
            colourspace.XYZ_to_RGB_matrix,
            np.array(
                [[1.04981102, 0.00000000, -0.00009748],
                 [-0.49590302, 1.37331305, 0.09824004],
                 [0.00000000, 0.00000000, 0.99125202]]),
            decimal=7)  # yapf: disable

        colourspace.use_derived_RGB_to_XYZ_matrix = False
        np.testing.assert_array_equal(colourspace.RGB_to_XYZ_matrix,
                                      np.identity(3))
        colourspace.use_derived_XYZ_to_RGB_matrix = False
        np.testing.assert_array_equal(colourspace.XYZ_to_RGB_matrix,
                                      np.identity(3))
    def setUp(self):
        """
        Initialises common tests attributes.
        """

        p = np.array([0.73470, 0.26530, 0.00000, 1.00000, 0.00010, -0.07700])
        whitepoint = np.array([0.32168, 0.33767])
        RGB_to_XYZ_matrix = np.identity(3)
        XYZ_to_RGB_matrix = np.identity(3)
        self._colourspace = RGB_Colourspace(
            'RGB Colourspace', p, whitepoint, 'ACES', RGB_to_XYZ_matrix,
            XYZ_to_RGB_matrix, lambda x: x, lambda x: x)
Beispiel #5
0
XYZ_TO_RUSSELL_RGB_MATRIX = np.linalg.inv(RUSSELL_RGB_TO_XYZ_MATRIX)
"""
*CIE XYZ* colourspace to *Russell RGB* colourspace matrix.

XYZ_TO_RUSSELL_RGB_MATRIX : array_like, (3, 3)
"""

RUSSELL_RGB_TRANSFER_FUNCTION = lambda x: x**(1 / 2.2)
"""
Transfer function from linear to *Russell RGB* colourspace.

RUSSELL_RGB_TRANSFER_FUNCTION : object
"""

RUSSELL_RGB_INVERSE_TRANSFER_FUNCTION = lambda x: x**2.2
"""
Inverse transfer function from *Russell RGB* colourspace to linear.

RUSSELL_RGB_INVERSE_TRANSFER_FUNCTION : object
"""

RUSSELL_RGB_COLOURSPACE = RGB_Colourspace(
    'Russell RGB', RUSSELL_RGB_PRIMARIES, RUSSELL_RGB_WHITEPOINT,
    RUSSELL_RGB_TO_XYZ_MATRIX, XYZ_TO_RUSSELL_RGB_MATRIX,
    RUSSELL_RGB_TRANSFER_FUNCTION, RUSSELL_RGB_INVERSE_TRANSFER_FUNCTION)
"""
*Russell RGB* colourspace.

RUSSELL_RGB_COLOURSPACE : RGB_Colourspace
"""
Beispiel #6
0
S_LOG_TRANSFER_FUNCTION = lambda x: (
    (0.432699 * math.log10(x + 0.037584) + 0.616596) + 0.03)
"""
Transfer function from linear to *S-Log* colourspace.

S_LOG_TRANSFER_FUNCTION : object
"""

S_LOG_INVERSE_TRANSFER_FUNCTION = lambda x: (
    (math.pow(10, ((x - 0.616596 - 0.03) / 0.432699)) - 0.037584))
"""
Inverse transfer function from *S-Log* colourspace to linear.

S_LOG_INVERSE_TRANSFER_FUNCTION : object
"""

S_LOG_COLOURSPACE = RGB_Colourspace(
    'S-Log',
    S_LOG_PRIMARIES,
    S_LOG_WHITEPOINT,
    S_LOG_TO_XYZ_MATRIX,
    XYZ_TO_S_LOG_MATRIX,
    S_LOG_TRANSFER_FUNCTION,
    S_LOG_INVERSE_TRANSFER_FUNCTION)
"""
*S-Log* colourspace.

S_LOG_COLOURSPACE : RGB_Colourspace
"""
Beispiel #7
0
class TestRGB_Colourspace(unittest.TestCase):
    """
    Defines :class:`colour.colour.models.RGB_Colourspace` class units
    tests methods.
    """
    def setUp(self):
        """
        Initialises common tests attributes.
        """

        p = np.array([0.73470, 0.26530, 0.00000, 1.00000, 0.00010, -0.07700])
        whitepoint = np.array([0.32168, 0.33767])
        matrix_RGB_to_XYZ = np.identity(3)
        matrix_XYZ_to_RGB = np.identity(3)
        self._colourspace = RGB_Colourspace('RGB Colourspace', p, whitepoint,
                                            'ACES', matrix_RGB_to_XYZ,
                                            matrix_XYZ_to_RGB, lambda x: x,
                                            lambda x: x)

    def test_required_attributes(self):
        """
        Tests presence of required attributes.
        """

        required_attributes = ('name', 'primaries', 'whitepoint',
                               'whitepoint_name', 'matrix_RGB_to_XYZ',
                               'matrix_XYZ_to_RGB', 'cctf_encoding',
                               'cctf_decoding',
                               'use_derived_matrix_RGB_to_XYZ',
                               'use_derived_matrix_XYZ_to_RGB')

        for attribute in required_attributes:
            self.assertIn(attribute, dir(RGB_Colourspace))

    def test_required_methods(self):
        """
        Tests presence of required methods.
        """

        required_methods = ('__init__', '__str__', '__repr__',
                            'use_derived_transformation_matrices',
                            'chromatically_adapt', 'copy')

        for method in required_methods:
            self.assertIn(method, dir(RGB_Colourspace))

    def test__str__(self):
        """
        Tests :func:`colour.models.rgb.rgb_colourspace.RGB_Colourspace.__str__`
        method.
        """

        # Skipping unit test on Python 2.7.
        if six.PY2:  # pragma: no cover
            return

        self.assertEqual(
            re.sub(' at 0x\\w+>', '', str(self._colourspace)),
            textwrap.dedent("""
    RGB Colourspace
    ---------------

    Primaries          : [[  7.34700000e-01   2.65300000e-01]
                          [  0.00000000e+00   1.00000000e+00]
                          [  1.00000000e-04  -7.70000000e-02]]
    Whitepoint         : [ 0.32168  0.33767]
    Whitepoint Name    : ACES
    Encoding CCTF      : <function TestRGB_Colourspace.setUp.<locals>.<lambda>
    Decoding CCTF      : <function TestRGB_Colourspace.setUp.<locals>.<lambda>
    NPM                : [[ 1.  0.  0.]
                          [ 0.  1.  0.]
                          [ 0.  0.  1.]]
    NPM -1             : [[ 1.  0.  0.]
                          [ 0.  1.  0.]
                          [ 0.  0.  1.]]
    Derived NPM        : [[  9.52552396e-01   0.00000000e+00   9.36786317e-05]
                          [  3.43966450e-01   7.28166097e-01  -7.21325464e-02]
                          [  0.00000000e+00   0.00000000e+00   1.00882518e+00]]
    Derived NPM -1     : [[  1.04981102e+00   0.00000000e+00  -9.74845406e-05]
                          [ -4.95903023e-01   1.37331305e+00   9.82400361e-02]
                          [  0.00000000e+00   0.00000000e+00   9.91252018e-01]]
    Use Derived NPM    : False
    Use Derived NPM -1 : False""")[1:])

    def test__repr__(self):
        """
        Tests :func:`colour.models.rgb.rgb_colourspace.RGB_Colourspace.\
__repr__` method.
        """

        # Skipping unit test on Python 2.7.
        if six.PY2:  # pragma: no cover
            return

        self.assertEqual(
            re.sub(' at 0x\\w+>', '', repr(self._colourspace)),
            textwrap.dedent("""
        RGB_Colourspace(RGB Colourspace,
                        [[  7.34700000e-01,   2.65300000e-01],
                         [  0.00000000e+00,   1.00000000e+00],
                         [  1.00000000e-04,  -7.70000000e-02]],
                        [ 0.32168,  0.33767],
                        ACES,
                        [[ 1.,  0.,  0.],
                         [ 0.,  1.,  0.],
                         [ 0.,  0.,  1.]],
                        [[ 1.,  0.,  0.],
                         [ 0.,  1.,  0.],
                         [ 0.,  0.,  1.]],
                        <function TestRGB_Colourspace.setUp.<locals>.<lambda>,
                        <function TestRGB_Colourspace.setUp.<locals>.<lambda>,
                        False,
                        False)""")[1:])

    def test_use_derived_transformation_matrices(self):
        """
        Tests :func:`colour.models.rgb.rgb_colourspace.RGB_Colourspace.\
use_derived_transformation_matrices` method.
        """

        np.testing.assert_array_equal(self._colourspace.matrix_RGB_to_XYZ,
                                      np.identity(3))
        np.testing.assert_array_equal(self._colourspace.matrix_XYZ_to_RGB,
                                      np.identity(3))

        self.assertTrue(
            self._colourspace.use_derived_transformation_matrices())

        np.testing.assert_almost_equal(
            self._colourspace.matrix_RGB_to_XYZ,
            np.array([
                [0.95255240, 0.00000000, 0.00009368],
                [0.34396645, 0.72816610, -0.07213255],
                [0.00000000, 0.00000000, 1.00882518],
            ]),
            decimal=7)
        np.testing.assert_almost_equal(
            self._colourspace.matrix_XYZ_to_RGB,
            np.array([
                [1.04981102, 0.00000000, -0.00009748],
                [-0.49590302, 1.37331305, 0.09824004],
                [0.00000000, 0.00000000, 0.99125202],
            ]),
            decimal=7)

        self._colourspace.use_derived_matrix_RGB_to_XYZ = False
        np.testing.assert_array_equal(self._colourspace.matrix_RGB_to_XYZ,
                                      np.identity(3))
        self._colourspace.use_derived_matrix_XYZ_to_RGB = False
        np.testing.assert_array_equal(self._colourspace.matrix_XYZ_to_RGB,
                                      np.identity(3))

    def test_chromatically_adapt(self):
        """
        Tests :func:`colour.models.rgb.rgb_colourspace.RGB_Colourspace.\
chromatically_adapt` method.
        """

        whitepoint_t = np.array([0.31270, 0.32900])
        colourspace = self._colourspace.chromatically_adapt(
            whitepoint_t, 'D50', 'Bradford')

        np.testing.assert_array_almost_equal(colourspace.primaries,
                                             np.array([
                                                 [0.73485524, 0.26422533],
                                                 [-0.00617091, 1.01131496],
                                                 [0.01596756, -0.06423550],
                                             ]),
                                             decimal=7)
        np.testing.assert_array_almost_equal(colourspace.whitepoint,
                                             whitepoint_t,
                                             decimal=7)

        self.assertEqual(colourspace.whitepoint_name, 'D50')

        np.testing.assert_array_almost_equal(colourspace.primaries,
                                             chromatically_adapted_primaries(
                                                 self._colourspace.primaries,
                                                 self._colourspace.whitepoint,
                                                 whitepoint_t, 'Bradford'),
                                             decimal=7)

        np.testing.assert_array_almost_equal(colourspace.matrix_RGB_to_XYZ,
                                             normalised_primary_matrix(
                                                 colourspace.primaries,
                                                 colourspace.whitepoint),
                                             decimal=7)

        np.testing.assert_array_almost_equal(colourspace.matrix_XYZ_to_RGB,
                                             np.linalg.inv(
                                                 normalised_primary_matrix(
                                                     colourspace.primaries,
                                                     colourspace.whitepoint)),
                                             decimal=7)

    def test_copy(self):
        """
        Tests :func:`colour.models.rgb.rgb_colourspace.RGB_Colourspace.copy`
        method.
        """

        self.assertIsNot(self._colourspace.copy(), self)
ALEXA_WIDE_GAMUT_RGB_TRANSFER_FUNCTION = (
    _alexa_wide_gamut_rgb_transfer_function)
"""
Transfer function from linear to *ALEXA Wide Gamut RGB* colourspace.

ALEXA_WIDE_GAMUT_RGB_TRANSFER_FUNCTION : object
"""

ALEXA_WIDE_GAMUT_RGB_INVERSE_TRANSFER_FUNCTION = (
    _alexa_wide_gamut_rgb_inverse_transfer_function)
"""
Inverse transfer function from *ALEXA Wide Gamut RGB* colourspace to linear.

ALEXA_WIDE_GAMUT_RGB_INVERSE_TRANSFER_FUNCTION : object
"""

ALEXA_WIDE_GAMUT_RGB_COLOURSPACE = RGB_Colourspace(
    'ALEXA Wide Gamut RGB',
    ALEXA_WIDE_GAMUT_RGB_PRIMARIES,
    ALEXA_WIDE_GAMUT_RGB_WHITEPOINT,
    ALEXA_WIDE_GAMUT_RGB_TO_XYZ_MATRIX,
    XYZ_TO_ALEXA_WIDE_GAMUT_RGB_MATRIX,
    ALEXA_WIDE_GAMUT_RGB_TRANSFER_FUNCTION,
    ALEXA_WIDE_GAMUT_RGB_INVERSE_TRANSFER_FUNCTION)
"""
*ALEXA Wide Gamut RGB* colourspace.

ALEXA_WIDE_GAMUT_RGB_COLOURSPACE : RGB_Colourspace
"""
Beispiel #9
0
REC_709_OECF = _rec_709_OECF
"""
Opto-electronic conversion function of *Rec. 709* colourspace.

REC_709_OECF : object
"""

REC_709_EOCF = _rec_709_EOCF
"""
Electro-optical conversion function of *Rec. 709* colourspace.

REC_709_EOCF : object

Warning
-------
*Recommendation ITU-R BT.709-5* doesn't specify an electro-optical conversion
function. This definition is used for symmetry in unit tests and other
computations but should not be used as an *EOCF* for *Rec. 709* colourspace!
"""

REC_709_COLOURSPACE = RGB_Colourspace('Rec. 709', REC_709_PRIMARIES,
                                      REC_709_WHITEPOINT, REC_709_ILLUMINANT,
                                      REC_709_TO_XYZ_MATRIX,
                                      XYZ_TO_REC_709_MATRIX, REC_709_OECF,
                                      REC_709_EOCF)
"""
*Rec. 709* colourspace.

REC_709_COLOURSPACE : RGB_Colourspace
"""
Beispiel #10
0
class TestRGB_Colourspace(unittest.TestCase):
    """
    Defines :class:`colour.colour.models.RGB_Colourspace` class units
    tests methods.
    """

    def setUp(self):
        """
        Initialises common tests attributes.
        """

        p = np.array([0.73470, 0.26530, 0.00000, 1.00000, 0.00010, -0.07700])
        whitepoint = np.array([0.32168, 0.33767])
        RGB_to_XYZ_matrix = np.identity(3)
        XYZ_to_RGB_matrix = np.identity(3)
        self._colourspace = RGB_Colourspace(
            'RGB Colourspace', p, whitepoint, 'D60', RGB_to_XYZ_matrix,
            XYZ_to_RGB_matrix, lambda x: x, lambda x: x)

    def test_required_attributes(self):
        """
        Tests presence of required attributes.
        """

        required_attributes = ('name', 'primaries', 'whitepoint', 'illuminant',
                               'RGB_to_XYZ_matrix', 'XYZ_to_RGB_matrix',
                               'encoding_cctf', 'decoding_cctf',
                               'use_derived_RGB_to_XYZ_matrix',
                               'use_derived_XYZ_to_RGB_matrix')

        for attribute in required_attributes:
            self.assertIn(attribute, dir(RGB_Colourspace))

    def test_required_methods(self):
        """
        Tests presence of required methods.
        """

        required_methods = ('__str__', '__repr__',
                            'use_derived_transformation_matrices')

        for method in required_methods:
            self.assertIn(method, dir(RGB_Colourspace))

    def test__str__(self):
        """
        Tests :func:`colour.models.rgb.rgb_colourspace.RGB_Colourspace.__str__`
        method.
        """

        # Skipping unit test on Python 2.7.
        if six.PY2:
            return

        self.assertEqual(
            re.sub(' at 0x\w+>', '', str(self._colourspace)),
            textwrap.dedent("""
    RGB Colourspace
    ---------------

    Primaries          : [[  7.34700000e-01   2.65300000e-01]
                          [  0.00000000e+00   1.00000000e+00]
                          [  1.00000000e-04  -7.70000000e-02]]
    Whitepoint         : [ 0.32168  0.33767]
    Whitepoint Name    : D60
    Encoding CCTF      : <function TestRGB_Colourspace.setUp.<locals>.<lambda>
    Decoding CCTF      : <function TestRGB_Colourspace.setUp.<locals>.<lambda>
    NPM                : [[ 1.  0.  0.]
                          [ 0.  1.  0.]
                          [ 0.  0.  1.]]
    NPM -1             : [[ 1.  0.  0.]
                          [ 0.  1.  0.]
                          [ 0.  0.  1.]]
    Derived NPM        : [[  9.52552396e-01   0.00000000e+00   9.36786317e-05]
                          [  3.43966450e-01   7.28166097e-01  -7.21325464e-02]
                          [  0.00000000e+00   0.00000000e+00   1.00882518e+00]]
    Derived NPM -1     : [[  1.04981102e+00   0.00000000e+00  -9.74845406e-05]
                          [ -4.95903023e-01   1.37331305e+00   9.82400361e-02]
                          [  0.00000000e+00   0.00000000e+00   9.91252018e-01]]
    Use Derived NPM    : False
    Use Derived NPM -1 : False""")[1:])

    def test__repr__(self):
        """
        Tests :func:`colour.models.rgb.rgb_colourspace.RGB_Colourspace.\
__repr__` method.
        """

        # Skipping unit test on Python 2.7.
        if six.PY2:
            return

        self.assertEqual(
            re.sub(' at 0x\w+>', '', repr(self._colourspace)),
            textwrap.dedent("""
        RGB_Colourspace(RGB Colourspace,
                        [[  7.34700000e-01,   2.65300000e-01],
                         [  0.00000000e+00,   1.00000000e+00],
                         [  1.00000000e-04,  -7.70000000e-02]],
                        [ 0.32168,  0.33767],
                        D60,
                        [[ 1.,  0.,  0.],
                         [ 0.,  1.,  0.],
                         [ 0.,  0.,  1.]],
                        [[ 1.,  0.,  0.],
                         [ 0.,  1.,  0.],
                         [ 0.,  0.,  1.]],
                        <function TestRGB_Colourspace.setUp.<locals>.<lambda>,
                        <function TestRGB_Colourspace.setUp.<locals>.<lambda>,
                        False,
                        False)""")[1:])

    def test_use_derived_transformation_matrices(self):
        """
        Tests :func:`colour.models.rgb.rgb_colourspace.RGB_Colourspace.range.\
use_derived_transformation_matrices` method.
        """

        np.testing.assert_array_equal(self._colourspace.RGB_to_XYZ_matrix,
                                      np.identity(3))
        np.testing.assert_array_equal(self._colourspace.XYZ_to_RGB_matrix,
                                      np.identity(3))

        self.assertTrue(
            self._colourspace.use_derived_transformation_matrices())

        np.testing.assert_almost_equal(
            self._colourspace.RGB_to_XYZ_matrix,
            np.array([
                [0.95255240, 0.00000000, 0.00009368],
                [0.34396645, 0.72816610, -0.07213255],
                [0.00000000, 0.00000000, 1.00882518],
            ]),
            decimal=7)
        np.testing.assert_almost_equal(
            self._colourspace.XYZ_to_RGB_matrix,
            np.array([
                [1.04981102, 0.00000000, -0.00009748],
                [-0.49590302, 1.37331305, 0.09824004],
                [0.00000000, 0.00000000, 0.99125202],
            ]),
            decimal=7)

        self._colourspace.use_derived_RGB_to_XYZ_matrix = False
        np.testing.assert_array_equal(self._colourspace.RGB_to_XYZ_matrix,
                                      np.identity(3))
        self._colourspace.use_derived_XYZ_to_RGB_matrix = False
        np.testing.assert_array_equal(self._colourspace.XYZ_to_RGB_matrix,
                                      np.identity(3))
Beispiel #11
0
XYZ_TO_PAL_SECAM_RGB_MATRIX = np.linalg.inv(PAL_SECAM_RGB_TO_XYZ_MATRIX)
"""
*CIE XYZ* colourspace to *Pal/Secam RGB* colourspace matrix.

XYZ_TO_PAL_SECAM_RGB_MATRIX : array_like, (3, 3)
"""

PAL_SECAM_RGB_TRANSFER_FUNCTION = lambda x: x**(1 / 2.8)
"""
Transfer function from linear to *Pal/Secam RGB* colourspace.

PAL_SECAM_RGB_TRANSFER_FUNCTION : object
"""

PAL_SECAM_RGB_INVERSE_TRANSFER_FUNCTION = lambda x: x**2.8
"""
Inverse transfer function from *Pal/Secam RGB* colourspace to linear.

PAL_SECAM_RGB_INVERSE_TRANSFER_FUNCTION : object
"""

PAL_SECAM_RGB_COLOURSPACE = RGB_Colourspace(
    'Pal/Secam RGB', PAL_SECAM_RGB_PRIMARIES, PAL_SECAM_RGB_WHITEPOINT,
    PAL_SECAM_RGB_TO_XYZ_MATRIX, XYZ_TO_PAL_SECAM_RGB_MATRIX,
    PAL_SECAM_RGB_TRANSFER_FUNCTION, PAL_SECAM_RGB_INVERSE_TRANSFER_FUNCTION)
"""
*Pal/Secam RGB* colourspace.

PAL_SECAM_RGB_COLOURSPACE : RGB_Colourspace
"""
Beispiel #12
0
    b = REC_2020_CONSTANTS.beta(is_10_bits_system)
    return np.where(value < _rec_2020_OECF(b), value / 4.5,
                    ((value + (a - 1)) / a)**(1 / 0.45))


REC_2020_OECF = _rec_2020_OECF
"""
Opto-electronic conversion function of *Rec. 2020* colourspace.

REC_2020_OECF : object
"""

REC_2020_EOCF = _rec_2020_EOCF
"""
Electro-optical conversion function of *Rec. 2020* colourspace.

REC_2020_EOCF : object
"""

REC_2020_COLOURSPACE = RGB_Colourspace('Rec. 2020', REC_2020_PRIMARIES,
                                       REC_2020_WHITEPOINT,
                                       REC_2020_ILLUMINANT,
                                       REC_2020_TO_XYZ_MATRIX,
                                       XYZ_TO_REC_2020_MATRIX, REC_2020_OECF,
                                       REC_2020_EOCF)
"""
*Rec. 2020* colourspace.

REC_2020_COLOURSPACE : RGB_Colourspace
"""
Beispiel #13
0
    value = np.asarray(value)

    return value**2.2


MAX_RGB_OECF = _max_rgb_OECF
"""
Opto-electronic conversion function of *Max RGB* colourspace.

MAX_RGB_OECF : object
"""

MAX_RGB_EOCF = _max_rgb_EOCF
"""
Electro-optical conversion function of *Max RGB* colourspace.

MAX_RGB_EOCF : object
"""

MAX_RGB_COLOURSPACE = RGB_Colourspace('Max RGB', MAX_RGB_PRIMARIES,
                                      MAX_RGB_WHITEPOINT, MAX_RGB_ILLUMINANT,
                                      MAX_RGB_TO_XYZ_MATRIX,
                                      XYZ_TO_MAX_RGB_MATRIX, MAX_RGB_OECF,
                                      MAX_RGB_EOCF)
"""
*Max RGB* colourspace.

MAX_RGB_COLOURSPACE : RGB_Colourspace
"""
Beispiel #14
0
CINEMA_GAMUT_OECF = _cinema_gamut_OECF
"""
Opto-electronic conversion function of *Cinema Gamut* colourspace.

CINEMA_GAMUT_OECF : object
"""

CINEMA_GAMUT_EOCF = (
    _cinema_gamut_EOCF)
"""
Electro-optical conversion function of *Cinema Gamut* colourspace.

CINEMA_GAMUT_EOCF : object
"""

CINEMA_GAMUT_COLOURSPACE = RGB_Colourspace(
    'Cinema Gamut',
    CINEMA_GAMUT_PRIMARIES,
    CINEMA_GAMUT_WHITEPOINT,
    CINEMA_GAMUT_ILLUMINANT,
    CINEMA_GAMUT_TO_XYZ_MATRIX,
    XYZ_TO_CINEMA_GAMUT_MATRIX,
    CINEMA_GAMUT_OECF,
    CINEMA_GAMUT_EOCF)
"""
*Cinema Gamut* colourspace.

CINEMA_GAMUT_COLOURSPACE : RGB_Colourspace
"""
Beispiel #15
0
RED_LOG_FILM_OECF : object
"""

RED_LOG_FILM_EOCF = _red_log_film_to_linear
"""
Electro-optical conversion function of *REDLogFilm* to linear.

RED_LOG_FILM_EOCF : object
"""

RED_COLOR_COLOURSPACE = RGB_Colourspace(
    'REDcolor',
    RED_COLOR_PRIMARIES,
    RED_COLOR_WHITEPOINT,
    RED_COLOR_ILLUMINANT,
    RED_COLOR_TO_XYZ_MATRIX,
    XYZ_TO_RED_COLOR_MATRIX,
    RED_LOG_FILM_OECF,
    RED_LOG_FILM_EOCF)
"""
*REDcolor* colourspace.

RED_COLOR_COLOURSPACE : RGB_Colourspace
"""

RED_COLOR_2_PRIMARIES = np.array(
    [[0.8786825104761286, 0.3249640074099105],
     [0.3008887143674324, 0.6790547557905675],
     [0.0953986946056151, -0.0293793268343266]])
"""
Beispiel #16
0
    """

    return luminance_1976(value * 100) / 100


ECI_RGB_V2_OECF = _eci_rgb_v2_OECF
"""
Opto-electronic conversion function of *ECI RGB v2* colourspace.

ECI_RGB_V2_OECF : object
"""

ECI_RGB_V2_EOCF = _eci_rgb_v2_EOCF
"""
Electro-optical conversion function of *ECI RGB v2* colourspace.

ECI_RGB_V2_EOCF : object
"""

ECI_RGB_V2_COLOURSPACE = RGB_Colourspace('ECI RGB v2', ECI_RGB_V2_PRIMARIES,
                                         ECI_RGB_V2_WHITEPOINT,
                                         ECI_RGB_V_ILLUMINANT,
                                         ECI_RGB_V2_TO_XYZ_MATRIX,
                                         XYZ_TO_ECI_RGB_V2_MATRIX,
                                         ECI_RGB_V2_OECF, ECI_RGB_V2_EOCF)
"""
*ECI RGB v2* colourspace.

ECI_RGB_V2_COLOURSPACE : RGB_Colourspace
"""
Beispiel #17
0
*CIE XYZ* colourspace to *sRGB* colourspace matrix.

XYZ_TO_sRGB_MATRIX : array_like, (3, 3)
"""

sRGB_TRANSFER_FUNCTION = lambda x: (x * 12.92 if x <= 0.0031308 else 1.055 *
                                    (x**(1 / 2.4)) - 0.055)
"""
Transfer function from linear to *sRGB* colourspace.

sRGB_TRANSFER_FUNCTION : object
"""

sRGB_INVERSE_TRANSFER_FUNCTION = lambda x: (x / 12.92 if x <= 0.0031308 else
                                            ((x + 0.055) / 1.055)**2.4)
"""
Inverse transfer function from *sRGB* colourspace to linear.

sRGB_INVERSE_TRANSFER_FUNCTION : object
"""

sRGB_COLOURSPACE = RGB_Colourspace('sRGB', sRGB_PRIMARIES, sRGB_WHITEPOINT,
                                   sRGB_TO_XYZ_MATRIX, XYZ_TO_sRGB_MATRIX,
                                   sRGB_TRANSFER_FUNCTION,
                                   sRGB_INVERSE_TRANSFER_FUNCTION)
"""
*sRGB* colourspace.

sRGB_COLOURSPACE : RGB_Colourspace
"""
Beispiel #18
0
*CIE XYZ* colourspace to *NTSC RGB* colourspace matrix.

XYZ_TO_NTSC_RGB_MATRIX : array_like, (3, 3)
"""

NTSC_RGB_TRANSFER_FUNCTION = lambda x: x**(1 / 2.2)
"""
Transfer function from linear to *NTSC RGB* colourspace.

NTSC_RGB_TRANSFER_FUNCTION : object
"""

NTSC_RGB_INVERSE_TRANSFER_FUNCTION = lambda x: x**2.2
"""
Inverse transfer function from *NTSC RGB* colourspace to linear.

NTSC_RGB_INVERSE_TRANSFER_FUNCTION : object
"""

NTSC_RGB_COLOURSPACE = RGB_Colourspace('NTSC RGB', NTSC_RGB_PRIMARIES,
                                       NTSC_RGB_WHITEPOINT,
                                       NTSC_RGB_TO_XYZ_MATRIX,
                                       XYZ_TO_NTSC_RGB_MATRIX,
                                       NTSC_RGB_TRANSFER_FUNCTION,
                                       NTSC_RGB_INVERSE_TRANSFER_FUNCTION)
"""
*NTSC RGB* colourspace.

NTSC_RGB_COLOURSPACE : RGB_Colourspace
"""
Beispiel #19
0

XTREME_RGB_OECF = _xtreme_rgb_OECF
"""
Opto-electronic conversion function of *Xtreme RGB* colourspace.

XTREME_RGB_OECF : object
"""

XTREME_RGB_EOCF = _xtreme_rgb_EOCF
"""
Electro-optical conversion function of *Xtreme RGB* colourspace.

XTREME_RGB_EOCF : object
"""

XTREME_RGB_COLOURSPACE = RGB_Colourspace(
    'Xtreme RGB',
    XTREME_RGB_PRIMARIES,
    XTREME_RGB_WHITEPOINT,
    XTREME_RGB_ILLUMINANT,
    XTREME_RGB_TO_XYZ_MATRIX,
    XYZ_TO_XTREME_RGB_MATRIX,
    XTREME_RGB_OECF,
    XTREME_RGB_EOCF)
"""
*Xtreme RGB* colourspace.

XTREME_RGB_COLOURSPACE : RGB_Colourspace
"""
Beispiel #20
0
    value = np.asarray(value)

    return value**2.2


BEST_RGB_OECF = _best_rgb_OECF
"""
Opto-electronic conversion function of *Best RGB* colourspace.

BEST_RGB_OECF : object
"""

BEST_RGB_EOCF = _best_rgb_EOCF
"""
Electro-optical conversion function of *Best RGB* colourspace.

BEST_RGB_EOCF : object
"""

BEST_RGB_COLOURSPACE = RGB_Colourspace('Best RGB', BEST_RGB_PRIMARIES,
                                       BEST_RGB_WHITEPOINT,
                                       BEST_RGB_ILLUMINANT,
                                       BEST_RGB_TO_XYZ_MATRIX,
                                       XYZ_TO_BEST_RGB_MATRIX, BEST_RGB_OECF,
                                       BEST_RGB_EOCF)
"""
*Best RGB* colourspace.

BEST_RGB_COLOURSPACE : RGB_Colourspace
"""
Beispiel #21
0
    value = np.asarray(value)

    return value**2.2


NTSC_RGB_OECF = _ntsc_rgb_OECF
"""
Opto-electronic conversion function of *NTSC RGB* colourspace.

NTSC_RGB_OECF : object
"""

NTSC_RGB_EOCF = _ntsc_rgb_EOCF
"""
Electro-optical conversion function of *NTSC RGB* colourspace.

NTSC_RGB_EOCF : object
"""

NTSC_RGB_COLOURSPACE = RGB_Colourspace('NTSC RGB', NTSC_RGB_PRIMARIES,
                                       NTSC_RGB_WHITEPOINT,
                                       NTSC_RGB_ILLUMINANT,
                                       NTSC_RGB_TO_XYZ_MATRIX,
                                       XYZ_TO_NTSC_RGB_MATRIX, NTSC_RGB_OECF,
                                       NTSC_RGB_EOCF)
"""
*NTSC RGB* colourspace.

NTSC_RGB_COLOURSPACE : RGB_Colourspace
"""
Beispiel #22
0
    value = np.where(value < cut2, (value - 0.125) / 5.6,
                     np.power(10, ((value - d) / c)) - b)

    return value


V_LOG_OECF = _linear_to_v_log
"""
Opto-electronic conversion function of *V-Log*.

V_LOG_OECF : object
"""

V_LOG_EOCF = _v_log_to_linear
"""
Electro-optical conversion function of *V-Log* to linear.

V_LOG_EOCF : object
"""

V_GAMUT_COLOURSPACE = RGB_Colourspace('V-Gamut', V_GAMUT_PRIMARIES,
                                      V_GAMUT_WHITEPOINT, V_GAMUT_ILLUMINANT,
                                      V_GAMUT_TO_XYZ_MATRIX,
                                      XYZ_TO_V_GAMUT_MATRIX, V_LOG_OECF,
                                      V_LOG_EOCF)
"""
*V-Gamut* colourspace.

V_GAMUT_COLOURSPACE : RGB_Colourspace
"""
Beispiel #23
0
"""
*CIE XYZ* colourspace to *Ekta Space PS 5* colourspace matrix.

XYZ_TO_EKTA_SPACE_PS_5_MATRIX : array_like, (3, 3)
"""

EKTA_SPACE_PS_5_TRANSFER_FUNCTION = lambda x: x**(1 / 2.2)
"""
Transfer function from linear to *Ekta Space PS 5* colourspace.

EKTA_SPACE_PS_5_TRANSFER_FUNCTION : object
"""

EKTA_SPACE_PS_5_INVERSE_TRANSFER_FUNCTION = lambda x: x**2.2
"""
Inverse transfer function from *Ekta Space PS 5* colourspace to linear.

EKTA_SPACE_PS_5_INVERSE_TRANSFER_FUNCTION : object
"""

EKTA_SPACE_PS_5_COLOURSPACE = RGB_Colourspace(
    'Ekta Space PS 5', EKTA_SPACE_PS_5_PRIMARIES, EKTA_SPACE_PS_5_WHITEPOINT,
    EKTA_SPACE_PS_5_TO_XYZ_MATRIX, XYZ_TO_EKTA_SPACE_PS_5_MATRIX,
    EKTA_SPACE_PS_5_TRANSFER_FUNCTION,
    EKTA_SPACE_PS_5_INVERSE_TRANSFER_FUNCTION)
"""
*Ekta Space PS 5* colourspace.

EKTA_SPACE_PS_5_COLOURSPACE : RGB_Colourspace
"""
Beispiel #24
0
*CIE XYZ* colourspace to *Best RGB* colourspace matrix.

XYZ_TO_BEST_RGB_MATRIX : array_like, (3, 3)
"""

BEST_RGB_TRANSFER_FUNCTION = lambda x: x**(1 / 2.2)
"""
Transfer function from linear to *Best RGB* colourspace.

BEST_RGB_TRANSFER_FUNCTION : object
"""

BEST_RGB_INVERSE_TRANSFER_FUNCTION = lambda x: x**2.2
"""
Inverse transfer function from *Best RGB* colourspace to linear.

BEST_RGB_INVERSE_TRANSFER_FUNCTION : object
"""

BEST_RGB_COLOURSPACE = RGB_Colourspace('Best RGB', BEST_RGB_PRIMARIES,
                                       BEST_RGB_WHITEPOINT,
                                       BEST_RGB_TO_XYZ_MATRIX,
                                       XYZ_TO_BEST_RGB_MATRIX,
                                       BEST_RGB_TRANSFER_FUNCTION,
                                       BEST_RGB_INVERSE_TRANSFER_FUNCTION)
"""
*Best RGB* colourspace.

BEST_RGB_COLOURSPACE : RGB_Colourspace
"""
Beispiel #25
0
"""
Opto-electronic conversion function of *Ekta Space PS 5*
colourspace.

EKTA_SPACE_PS_5_OECF : object
"""

EKTA_SPACE_PS_5_EOCF = (
    _ekta_space_ps_5_EOCF)
"""
Electro-optical conversion function of *Ekta Space PS 5* colourspace to
linear.

EKTA_SPACE_PS_5_EOCF : object
"""

EKTA_SPACE_PS_5_COLOURSPACE = RGB_Colourspace(
    'Ekta Space PS 5',
    EKTA_SPACE_PS_5_PRIMARIES,
    EKTA_SPACE_PS_5_WHITEPOINT,
    EKTA_SPACE_PS_5_V_ILLUMINANT,
    EKTA_SPACE_PS_5_TO_XYZ_MATRIX,
    XYZ_TO_EKTA_SPACE_PS_5_MATRIX,
    EKTA_SPACE_PS_5_OECF,
    EKTA_SPACE_PS_5_EOCF)
"""
*Ekta Space PS 5* colourspace.

EKTA_SPACE_PS_5_COLOURSPACE : RGB_Colourspace
"""
Beispiel #26
0
    """

    value = np.asarray(value)

    return value**2.8


PAL_SECAM_RGB_OECF = _pal_secam_rgb_OECF
"""
Opto-electronic conversion function of *Pal/Secam RGB* colourspace.

PAL_SECAM_RGB_OECF : object
"""

PAL_SECAM_RGB_EOCF = (_pal_secam_rgb_EOCF)
"""
Electro-optical conversion function of *Pal/Secam RGB* colourspace.

PAL_SECAM_RGB_EOCF : object
"""

PAL_SECAM_RGB_COLOURSPACE = RGB_Colourspace(
    'Pal/Secam RGB', PAL_SECAM_RGB_PRIMARIES, PAL_SECAM_RGB_WHITEPOINT,
    PAL_SECAM_RGB_ILLUMINANT, PAL_SECAM_RGB_TO_XYZ_MATRIX,
    XYZ_TO_PAL_SECAM_RGB_MATRIX, PAL_SECAM_RGB_OECF, PAL_SECAM_RGB_EOCF)
"""
*Pal/Secam RGB* colourspace.

PAL_SECAM_RGB_COLOURSPACE : RGB_Colourspace
"""
Beispiel #27
0
XYZ_TO_ADOBE_RGB_1998_MATRIX = np.linalg.inv(ADOBE_RGB_1998_TO_XYZ_MATRIX)
"""
*CIE XYZ* colourspace to *Adobe RGB 1998* colourspace matrix.

XYZ_TO_ADOBE_RGB_1998_MATRIX : array_like, (3, 3)
"""

ADOBE_RGB_1998_TRANSFER_FUNCTION = lambda x: x**(1 / (563 / 256))
"""
Transfer function from linear to *Adobe RGB 1998* colourspace.

ADOBE_RGB_1998_TRANSFER_FUNCTION : object
"""

ADOBE_RGB_1998_INVERSE_TRANSFER_FUNCTION = lambda x: x**(563 / 256)
"""
Inverse transfer function from *Adobe RGB 1998* colourspace to linear.

ADOBE_RGB_1998_INVERSE_TRANSFER_FUNCTION : object
"""

ADOBE_RGB_1998_COLOURSPACE = RGB_Colourspace(
    'Adobe RGB 1998', ADOBE_RGB_1998_PRIMARIES, ADOBE_RGB_1998_WHITEPOINT,
    ADOBE_RGB_1998_TO_XYZ_MATRIX, XYZ_TO_ADOBE_RGB_1998_MATRIX,
    ADOBE_RGB_1998_TRANSFER_FUNCTION, ADOBE_RGB_1998_INVERSE_TRANSFER_FUNCTION)
"""
*Adobe RGB 1998* colourspace.

ADOBE_RGB_1998_COLOURSPACE : RGB_Colourspace
"""
Beispiel #28
0
"""
*CIE XYZ* colourspace to *ColorMatch RGB* colourspace matrix.

XYZ_TO_COLOR_MATCH_RGB_MATRIX : array_like, (3, 3)
"""

COLOR_MATCH_RGB_TRANSFER_FUNCTION = lambda x: x**(1 / 1.8)
"""
Transfer function from linear to *ColorMatch RGB* colourspace.

COLOR_MATCH_RGB_TRANSFER_FUNCTION : object
"""

COLOR_MATCH_RGB_INVERSE_TRANSFER_FUNCTION = lambda x: x**1.8
"""
Inverse transfer function from *ColorMatch RGB* colourspace to linear.

COLOR_MATCH_RGB_INVERSE_TRANSFER_FUNCTION : object
"""

COLOR_MATCH_RGB_COLOURSPACE = RGB_Colourspace(
    'ColorMatch RGB', COLOR_MATCH_RGB_PRIMARIES, COLOR_MATCH_RGB_WHITEPOINT,
    COLOR_MATCH_RGB_TO_XYZ_MATRIX, XYZ_TO_COLOR_MATCH_RGB_MATRIX,
    COLOR_MATCH_RGB_TRANSFER_FUNCTION,
    COLOR_MATCH_RGB_INVERSE_TRANSFER_FUNCTION)
"""
*ColorMatch RGB* colourspace.

COLOR_MATCH_RGB_COLOURSPACE : RGB_Colourspace
"""
Beispiel #29
0
XYZ_TO_SMPTE_C_RGB_MATRIX = np.linalg.inv(SMPTE_C_RGB_TO_XYZ_MATRIX)
"""
*CIE XYZ* colourspace to *SMPTE-C RGB* colourspace matrix.

XYZ_TO_SMPTE_C_RGB_MATRIX : array_like, (3, 3)
"""

SMPTE_C_RGB_TRANSFER_FUNCTION = lambda x: x**(1 / 2.2)
"""
Transfer function from linear to *SMPTE-C RGB* colourspace.

SMPTE_C_RGB_TRANSFER_FUNCTION : object
"""

SMPTE_C_RGB_INVERSE_TRANSFER_FUNCTION = lambda x: x**2.2
"""
Inverse transfer function from *SMPTE-C RGB* colourspace to linear.

SMPTE_C_RGB_INVERSE_TRANSFER_FUNCTION : object
"""

SMPTE_C_RGB_COLOURSPACE = RGB_Colourspace(
    'SMPTE-C RGB', SMPTE_C_RGB_PRIMARIES, SMPTE_C_RGB_WHITEPOINT,
    SMPTE_C_RGB_TO_XYZ_MATRIX, XYZ_TO_SMPTE_C_RGB_MATRIX,
    SMPTE_C_RGB_TRANSFER_FUNCTION, SMPTE_C_RGB_INVERSE_TRANSFER_FUNCTION)
"""
*SMPTE-C RGB* colourspace.

SMPTE_C_RGB_COLOURSPACE : RGB_Colourspace
"""
Beispiel #30
0
"""
Opto-electronic conversion function of *Adobe Wide Gamut RGB*
colourspace.

ADOBE_WIDE_GAMUT_RGB_OECF : object
"""

ADOBE_WIDE_GAMUT_RGB_EOCF = (
    _adobe_wide_gamut_rgb_EOCF)
"""
Electro-optical conversion function of *Adobe Wide Gamut RGB* colourspace to
linear.

ADOBE_WIDE_GAMUT_RGB_EOCF : object
"""

ADOBE_WIDE_GAMUT_RGB_COLOURSPACE = RGB_Colourspace(
    'Adobe Wide Gamut RGB',
    ADOBE_WIDE_GAMUT_RGB_PRIMARIES,
    ADOBE_WIDE_GAMUT_RGB_WHITEPOINT,
    ADOBE_WIDE_GAMUT_RGB_ILLUMINANT,
    ADOBE_WIDE_GAMUT_RGB_TO_XYZ_MATRIX,
    XYZ_TO_ADOBE_WIDE_GAMUT_RGB_MATRIX,
    ADOBE_WIDE_GAMUT_RGB_OECF,
    ADOBE_WIDE_GAMUT_RGB_EOCF)
"""
*Adobe Wide Gamut RGB* colourspace.

ADOBE_WIDE_GAMUT_RGB_COLOURSPACE : RGB_Colourspace
"""
Beispiel #31
0

ALEXA_LOG_C_OECF = _linear_to_alexa_log_c
"""
Opto-electronic conversion function of *ALEXA Log C*.

ALEXA_LOG_C_OECF : object
"""

ALEXA_LOG_C_EOCF = _alexa_log_c_to_linear
"""
Electro-optical conversion function of *ALEXA Log C* to linear.

ALEXA_LOG_C_EOCF : object
"""

ALEXA_WIDE_GAMUT_RGB_COLOURSPACE = RGB_Colourspace(
    'ALEXA Wide Gamut RGB',
    ALEXA_WIDE_GAMUT_RGB_PRIMARIES,
    ALEXA_WIDE_GAMUT_RGB_WHITEPOINT,
    ALEXA_WIDE_GAMUT_RGB_ILLUMINANT,
    ALEXA_WIDE_GAMUT_RGB_TO_XYZ_MATRIX,
    XYZ_TO_ALEXA_WIDE_GAMUT_RGB_MATRIX,
    ALEXA_LOG_C_OECF,
    ALEXA_LOG_C_EOCF)
"""
*ALEXA Wide Gamut RGB* colourspace.

ALEXA_WIDE_GAMUT_RGB_COLOURSPACE : RGB_Colourspace
"""
class TestRGB_Colourspace(unittest.TestCase):
    """
    Defines :class:`colour.colour.models.RGB_Colourspace` class units
    tests methods.
    """

    def setUp(self):
        """
        Initialises common tests attributes.
        """

        p = np.array([0.73470, 0.26530, 0.00000, 1.00000, 0.00010, -0.07700])
        whitepoint = np.array([0.32168, 0.33767])
        RGB_to_XYZ_matrix = np.identity(3)
        XYZ_to_RGB_matrix = np.identity(3)
        self._colourspace = RGB_Colourspace(
            'RGB Colourspace', p, whitepoint, 'ACES', RGB_to_XYZ_matrix,
            XYZ_to_RGB_matrix, lambda x: x, lambda x: x)

    def test_required_attributes(self):
        """
        Tests presence of required attributes.
        """

        required_attributes = ('name', 'primaries', 'whitepoint',
                               'whitepoint_name', 'RGB_to_XYZ_matrix',
                               'XYZ_to_RGB_matrix', 'encoding_cctf',
                               'decoding_cctf',
                               'use_derived_RGB_to_XYZ_matrix',
                               'use_derived_XYZ_to_RGB_matrix')

        for attribute in required_attributes:
            self.assertIn(attribute, dir(RGB_Colourspace))

    def test_required_methods(self):
        """
        Tests presence of required methods.
        """

        required_methods = ('__str__', '__repr__',
                            'use_derived_transformation_matrices',
                            'chromatically_adapt', 'copy')

        for method in required_methods:
            self.assertIn(method, dir(RGB_Colourspace))

    def test__str__(self):
        """
        Tests :func:`colour.models.rgb.rgb_colourspace.RGB_Colourspace.__str__`
        method.
        """

        # Skipping unit test on Python 2.7.
        if six.PY2:
            return

        self.assertEqual(
            re.sub(' at 0x\\w+>', '', str(self._colourspace)),
            textwrap.dedent("""
    RGB Colourspace
    ---------------

    Primaries          : [[  7.34700000e-01   2.65300000e-01]
                          [  0.00000000e+00   1.00000000e+00]
                          [  1.00000000e-04  -7.70000000e-02]]
    Whitepoint         : [ 0.32168  0.33767]
    Whitepoint Name    : ACES
    Encoding CCTF      : <function TestRGB_Colourspace.setUp.<locals>.<lambda>
    Decoding CCTF      : <function TestRGB_Colourspace.setUp.<locals>.<lambda>
    NPM                : [[ 1.  0.  0.]
                          [ 0.  1.  0.]
                          [ 0.  0.  1.]]
    NPM -1             : [[ 1.  0.  0.]
                          [ 0.  1.  0.]
                          [ 0.  0.  1.]]
    Derived NPM        : [[  9.52552396e-01   0.00000000e+00   9.36786317e-05]
                          [  3.43966450e-01   7.28166097e-01  -7.21325464e-02]
                          [  0.00000000e+00   0.00000000e+00   1.00882518e+00]]
    Derived NPM -1     : [[  1.04981102e+00   0.00000000e+00  -9.74845406e-05]
                          [ -4.95903023e-01   1.37331305e+00   9.82400361e-02]
                          [  0.00000000e+00   0.00000000e+00   9.91252018e-01]]
    Use Derived NPM    : False
    Use Derived NPM -1 : False""")[1:])

    def test__repr__(self):
        """
        Tests :func:`colour.models.rgb.rgb_colourspace.RGB_Colourspace.\
__repr__` method.
        """

        # Skipping unit test on Python 2.7.
        if six.PY2:
            return

        self.assertEqual(
            re.sub(' at 0x\\w+>', '', repr(self._colourspace)),
            textwrap.dedent("""
        RGB_Colourspace(RGB Colourspace,
                        [[  7.34700000e-01,   2.65300000e-01],
                         [  0.00000000e+00,   1.00000000e+00],
                         [  1.00000000e-04,  -7.70000000e-02]],
                        [ 0.32168,  0.33767],
                        ACES,
                        [[ 1.,  0.,  0.],
                         [ 0.,  1.,  0.],
                         [ 0.,  0.,  1.]],
                        [[ 1.,  0.,  0.],
                         [ 0.,  1.,  0.],
                         [ 0.,  0.,  1.]],
                        <function TestRGB_Colourspace.setUp.<locals>.<lambda>,
                        <function TestRGB_Colourspace.setUp.<locals>.<lambda>,
                        False,
                        False)""")[1:])

    def test_use_derived_transformation_matrices(self):
        """
        Tests :func:`colour.models.rgb.rgb_colourspace.RGB_Colourspace.\
use_derived_transformation_matrices` method.
        """

        np.testing.assert_array_equal(self._colourspace.RGB_to_XYZ_matrix,
                                      np.identity(3))
        np.testing.assert_array_equal(self._colourspace.XYZ_to_RGB_matrix,
                                      np.identity(3))

        self.assertTrue(
            self._colourspace.use_derived_transformation_matrices())

        np.testing.assert_almost_equal(
            self._colourspace.RGB_to_XYZ_matrix,
            np.array([
                [0.95255240, 0.00000000, 0.00009368],
                [0.34396645, 0.72816610, -0.07213255],
                [0.00000000, 0.00000000, 1.00882518],
            ]),
            decimal=7)
        np.testing.assert_almost_equal(
            self._colourspace.XYZ_to_RGB_matrix,
            np.array([
                [1.04981102, 0.00000000, -0.00009748],
                [-0.49590302, 1.37331305, 0.09824004],
                [0.00000000, 0.00000000, 0.99125202],
            ]),
            decimal=7)

        self._colourspace.use_derived_RGB_to_XYZ_matrix = False
        np.testing.assert_array_equal(self._colourspace.RGB_to_XYZ_matrix,
                                      np.identity(3))
        self._colourspace.use_derived_XYZ_to_RGB_matrix = False
        np.testing.assert_array_equal(self._colourspace.XYZ_to_RGB_matrix,
                                      np.identity(3))

    def test_chromatically_adapt(self):
        """
        Tests :func:`colour.models.rgb.rgb_colourspace.RGB_Colourspace.\
chromatically_adapt` method.
        """

        whitepoint_t = np.array([0.31270, 0.32900])
        colourspace = self._colourspace.chromatically_adapt(
            whitepoint_t, 'D50', 'Bradford')

        np.testing.assert_array_almost_equal(
            colourspace.primaries,
            np.array([
                [0.73485524, 0.26422533],
                [-0.00617091, 1.01131496],
                [0.01596756, -0.06423550],
            ]),
            decimal=7)
        np.testing.assert_array_almost_equal(
            colourspace.whitepoint, whitepoint_t, decimal=7)

        self.assertEqual(colourspace.whitepoint_name, 'D50')

        np.testing.assert_array_almost_equal(
            colourspace.primaries,
            chromatically_adapted_primaries(self._colourspace.primaries,
                                            self._colourspace.whitepoint,
                                            whitepoint_t, 'Bradford'),
            decimal=7)

        np.testing.assert_array_almost_equal(
            colourspace.RGB_to_XYZ_matrix,
            normalised_primary_matrix(colourspace.primaries,
                                      colourspace.whitepoint),
            decimal=7)

        np.testing.assert_array_almost_equal(
            colourspace.XYZ_to_RGB_matrix,
            np.linalg.inv(
                normalised_primary_matrix(colourspace.primaries,
                                          colourspace.whitepoint)),
            decimal=7)

    def test_copy(self):
        """
        Tests :func:`colour.models.rgb.rgb_colourspace.RGB_Colourspace.copy`
        method.
        """

        self.assertIsNot(self._colourspace.copy(), self)