Esempio n. 1
0
    def test_read_LUT(self):
        """Test :func:`colour.io.luts.__init__.read_LUT` definition."""

        LUT_1 = read_LUT(
            os.path.join(LUTS_DIRECTORY, "sony_spi1d", "eotf_sRGB_1D.spi1d"))

        np.testing.assert_almost_equal(
            LUT_1.table,
            np.array([
                -7.73990000e-03,
                5.16000000e-04,
                1.22181000e-02,
                3.96819000e-02,
                8.71438000e-02,
                1.57439400e-01,
                2.52950100e-01,
                3.75757900e-01,
                5.27729400e-01,
                7.10566500e-01,
                9.25840600e-01,
                1.17501630e00,
                1.45946870e00,
                1.78049680e00,
                2.13933380e00,
                2.53715520e00,
            ]),
        )
        self.assertEqual(LUT_1.name, "eotf sRGB 1D")
        self.assertEqual(LUT_1.dimensions, 1)
        np.testing.assert_array_equal(LUT_1.domain, np.array([-0.1, 1.5]))
        self.assertEqual(LUT_1.size, 16)
        self.assertListEqual(
            LUT_1.comments,
            ['Generated by "Colour 0.3.11".', '"colour.models.eotf_sRGB".'],
        )

        LUT_2 = read_LUT(
            os.path.join(LUTS_DIRECTORY, "resolve_cube", "LogC_Video.cube"))
        np.testing.assert_almost_equal(
            LUT_2[0].table,
            np.array([
                [0.00000000, 0.00000000, 0.00000000],
                [0.02708500, 0.02708500, 0.02708500],
                [0.06304900, 0.06304900, 0.06304900],
                [0.11314900, 0.11314900, 0.11314900],
                [0.18304900, 0.18304900, 0.18304900],
                [0.28981100, 0.28981100, 0.28981100],
                [0.41735300, 0.41735300, 0.41735300],
                [0.54523100, 0.54523100, 0.54523100],
                [0.67020500, 0.67020500, 0.67020500],
                [0.78963000, 0.78963000, 0.78963000],
                [0.88646800, 0.88646800, 0.88646800],
                [0.94549100, 0.94549100, 0.94549100],
                [0.97644900, 0.97644900, 0.97644900],
                [0.98924800, 0.98924800, 0.98924800],
                [0.99379700, 0.99379700, 0.99379700],
                [1.00000000, 1.00000000, 1.00000000],
            ]),
        )
        self.assertEqual(LUT_2[1].size, 4)
Esempio n. 2
0
    def test_write_LUT(self):
        """Test :func:`colour.io.luts.__init__.write_LUT` definition."""

        LUT_1_r = read_LUT(
            os.path.join(LUTS_DIRECTORY, "sony_spi1d", "eotf_sRGB_1D.spi1d"))

        write_LUT(
            LUT_1_r,
            os.path.join(self._temporary_directory, "eotf_sRGB_1D.spi1d"),
        )

        LUT_1_t = read_LUT(
            os.path.join(self._temporary_directory, "eotf_sRGB_1D.spi1d"))

        self.assertEqual(LUT_1_r, LUT_1_t)

        write_LUT(
            LUTSequence(LUT_1_r),
            os.path.join(self._temporary_directory, "eotf_sRGB_1D.spi1d"),
        )

        self.assertEqual(LUT_1_r, LUT_1_t)

        LUT_2_r = read_LUT(
            os.path.join(
                LUTS_DIRECTORY,
                "resolve_cube",
                "Three_Dimensional_Table_With_Shaper.cube",
            ))

        write_LUT(
            LUT_2_r,
            os.path.join(
                self._temporary_directory,
                "Three_Dimensional_Table_With_Shaper.cube",
            ),
        )

        LUT_2_t = read_LUT(
            os.path.join(
                self._temporary_directory,
                "Three_Dimensional_Table_With_Shaper.cube",
            ))

        self.assertEqual(LUT_2_r, LUT_2_t)
Esempio n. 3
0
    [-0.0640000, 0.6720000, 0.4480000, -0.0560000],
    [-0.0639375, 0.6180625, 0.5056875, -0.0598125],
    [-0.0625000, 0.5625000, 0.5625000, -0.0625000],
    [-0.0598125, 0.5056875, 0.6180625, -0.0639375],
    [-0.0560000, 0.4480000, 0.6720000, -0.0640000],
    [-0.0511875, 0.3898125, 0.7239375, -0.0625625],
    [-0.0455000, 0.3315000, 0.7735000, -0.0595000],
    [-0.0390625, 0.2734375, 0.8203125, -0.0546875],
    [-0.0320000, 0.2160000, 0.8640000, -0.0480000],
    [-0.0244375, 0.1595625, 0.9041875, -0.0393125],
    [-0.0165000, 0.1045000, 0.9405000, -0.0285000],
    [-0.0083125, 0.0511875, 0.9725625, -0.0154375],
])

LUT_TABLE = read_LUT(
    os.path.join(
        os.path.dirname(__file__), '..', '..', 'io', 'luts', 'tests',
        'resources', 'iridas_cube', 'Colour_Correct.cube')).table


class TestKernelNearestNeighbour(unittest.TestCase):
    """
    Defines :func:`colour.algebra.interpolation.kernel_nearest_neighbour`
    definition units tests methods.
    """

    def test_kernel_nearest(self):
        """
        Tests :func:`colour.algebra.interpolation.kernel_nearest_neighbour`
        definition.
        """
    [-0.0640000, 0.6720000, 0.4480000, -0.0560000],
    [-0.0639375, 0.6180625, 0.5056875, -0.0598125],
    [-0.0625000, 0.5625000, 0.5625000, -0.0625000],
    [-0.0598125, 0.5056875, 0.6180625, -0.0639375],
    [-0.0560000, 0.4480000, 0.6720000, -0.0640000],
    [-0.0511875, 0.3898125, 0.7239375, -0.0625625],
    [-0.0455000, 0.3315000, 0.7735000, -0.0595000],
    [-0.0390625, 0.2734375, 0.8203125, -0.0546875],
    [-0.0320000, 0.2160000, 0.8640000, -0.0480000],
    [-0.0244375, 0.1595625, 0.9041875, -0.0393125],
    [-0.0165000, 0.1045000, 0.9405000, -0.0285000],
    [-0.0083125, 0.0511875, 0.9725625, -0.0154375],
])

LUT_TABLE = read_LUT(
    os.path.join(
        os.path.dirname(__file__), '..', '..', 'io', 'luts', 'tests',
        'resources', 'iridas_cube', 'ColourCorrect.cube')).table


class TestKernelNearestNeighbour(unittest.TestCase):
    """
    Defines :func:`colour.algebra.interpolation.kernel_nearest_neighbour`
    definition units tests methods.
    """

    def test_kernel_nearest(self):
        """
        Tests :func:`colour.algebra.interpolation.kernel_nearest_neighbour`
        definition.
        """
Esempio n. 5
0
        [-0.0455000, 0.3315000, 0.7735000, -0.0595000],
        [-0.0390625, 0.2734375, 0.8203125, -0.0546875],
        [-0.0320000, 0.2160000, 0.8640000, -0.0480000],
        [-0.0244375, 0.1595625, 0.9041875, -0.0393125],
        [-0.0165000, 0.1045000, 0.9405000, -0.0285000],
        [-0.0083125, 0.0511875, 0.9725625, -0.0154375],
    ]
)

LUT_TABLE: NDArray = read_LUT(
    os.path.join(
        os.path.dirname(__file__),
        "..",
        "..",
        "io",
        "luts",
        "tests",
        "resources",
        "iridas_cube",
        "Colour_Correct.cube",
    )
).table  # type: ignore[union-attr]


class TestKernelNearestNeighbour(unittest.TestCase):
    """
    Define :func:`colour.algebra.interpolation.kernel_nearest_neighbour`
    definition unit tests methods.
    """

    def test_kernel_nearest(self):