Exemplo n.º 1
0
    def test_palettize_seq(self):
        colors = np.array([[10, 20, 30], [20, 30, 40], [20, 30, 50],
                           [40, 40, 40], [90, 90, 0]],
                          dtype=np.uint8)
        index_x = np.array([[2, 2, 0], [1, 4, 4]])
        index_y = np.array([[4, 3], [1, 2]])
        index_z = np.array([[0, 0, 0, 0], [0, 2, 0, 4]])
        x = colors[index_x]
        y = colors[index_y]
        z = colors[index_z]

        index_seq, palette, trans = numpngw._palettize_seq([x, y, z])
        assert_array_equal(index_seq[0], index_x)
        assert_array_equal(index_seq[1], index_y)
        assert_array_equal(index_seq[2], index_z)
        assert_array_equal(palette, colors)
        assert_equal(trans, None)

        colors = np.array(
            [[10, 20, 30, 255], [20, 30, 40, 128], [20, 30, 50, 255],
             [40, 40, 40, 128], [40, 40, 40, 255], [90, 90, 0, 255]],
            dtype=np.uint8)
        index_x = np.array([[2, 2, 0], [1, 5, 4]])
        index_y = np.array([[3, 3, 3], [3, 3, 3], [3, 3, 3]])
        index_z = np.array([[0, 0, 0, 0], [5, 2, 0, 4]])
        x = colors[index_x]
        y = colors[index_y]
        z = colors[index_z]

        index_seq, palette, trans = numpngw._palettize_seq([x, y, z])
        assert_array_equal(index_seq[0], index_x)
        assert_array_equal(index_seq[1], index_y)
        assert_array_equal(index_seq[2], index_z)
        assert_array_equal(palette, colors[:, :3])
        assert_equal(trans, colors[:, 3])
Exemplo n.º 2
0
    def test_palettize_seq(self):
        colors = np.array([[10, 20, 30], [20, 30, 40], [20, 30, 50], [40, 40, 40], [90, 90, 0]], dtype=np.uint8)
        index_x = np.array([[2, 2, 0], [1, 4, 4]])
        index_y = np.array([[4, 3], [1, 2]])
        index_z = np.array([[0, 0, 0, 0], [0, 2, 0, 4]])
        x = colors[index_x]
        y = colors[index_y]
        z = colors[index_z]

        index_seq, palette, trans = numpngw._palettize_seq([x, y, z])
        assert_array_equal(index_seq[0], index_x)
        assert_array_equal(index_seq[1], index_y)
        assert_array_equal(index_seq[2], index_z)
        assert_array_equal(palette, colors)
        assert_equal(trans, None)

        colors = np.array(
            [
                [10, 20, 30, 255],
                [20, 30, 40, 128],
                [20, 30, 50, 255],
                [40, 40, 40, 128],
                [40, 40, 40, 255],
                [90, 90, 0, 255],
            ],
            dtype=np.uint8,
        )
        index_x = np.array([[2, 2, 0], [1, 5, 4]])
        index_y = np.array([[3, 3, 3], [3, 3, 3], [3, 3, 3]])
        index_z = np.array([[0, 0, 0, 0], [5, 2, 0, 4]])
        x = colors[index_x]
        y = colors[index_y]
        z = colors[index_z]

        index_seq, palette, trans = numpngw._palettize_seq([x, y, z])
        assert_array_equal(index_seq[0], index_x)
        assert_array_equal(index_seq[1], index_y)
        assert_array_equal(index_seq[2], index_z)
        assert_array_equal(palette, colors[:, :3])
        assert_equal(trans, colors[:, 3])