Exemplo n.º 1
0
    def test_wrong_size(self):
        with self.assertRaisesRegexp(ValueError, "should be a square"):
            load_hald_image(Image.new('RGB', (8, 10)))

        with self.assertRaisesRegexp(ValueError, "Can't detect hald size"):
            load_hald_image(Image.new('RGB', (7, 7)))

        with self.assertRaisesRegexp(ValueError, "Can't detect hald size"):
            load_hald_image(Image.new('RGB', (729, 729)))
Exemplo n.º 2
0
    def test_application(self):
        im = Image.new('RGB', (10, 10))
        hald = Image.open(resource('files', 'hald.4.png'))

        lut_numpy = load_hald_image(hald)
        self.assertEqual(lut_numpy.table.__class__.__name__, 'ndarray')
        im.filter(lut_numpy)

        with disable_numpy(loaders):
            lut_native = load_hald_image(hald)
        self.assertEqual(lut_native.table.__class__.__name__, 'list')
        im.filter(lut_native)
Exemplo n.º 3
0
    def test_application(self):
        im = Image.new('RGB', (10, 10))

        lut_numpy = amplify_lut(identity_table(5), 2.0)
        self.assertEqual(lut_numpy.table.__class__.__name__, 'ndarray')
        im.filter(lut_numpy)

        with disable_numpy(operations):
            lut_native = amplify_lut(identity_table(5), 2.0)
        self.assertEqual(lut_native.table.__class__.__name__, 'list')
        im.filter(lut_native)

        with disable_numpy(generators):
            args = identity_table(5)
        self.assertEqual(args.table.__class__.__name__, 'list')
        lut_numpy = amplify_lut(args, 2.0)
        self.assertEqual(lut_numpy.table.__class__.__name__, 'ndarray')
        im.filter(lut_numpy)

        args = identity_table(5)
        self.assertEqual(args.table.__class__.__name__, 'ndarray')
        with disable_numpy(operations):
            lut_native = amplify_lut(args, 2.0)
        self.assertEqual(lut_native.table.__class__.__name__, 'list')
        im.filter(lut_native)
Exemplo n.º 4
0
    def test_correctness(self):
        identity = identity_table(16)
        image = Image.open(resource('files', 'hald.4.png'))

        lut_numpy = load_hald_image(image)
        self.assertEqualLuts(lut_numpy, identity)

        with disable_numpy(loaders):
            lut_pillow = load_hald_image(image)
        self.assertEqualLuts(lut_pillow, identity)
Exemplo n.º 5
0
    def test_application(self):
        im = Image.new('RGB', (10, 10))

        lut_numpy = identity_table(5)
        self.assertEqual(lut_numpy.table.__class__.__name__, 'ndarray')
        im.filter(lut_numpy)

        with disable_numpy(generators):
            lut_native = identity_table(5)
        self.assertEqual(lut_native.table.__class__.__name__, 'list')
        im.filter(lut_native)
Exemplo n.º 6
0
    def test_application(self):
        im = Image.new('RGB', (10, 10))

        lut = load_cube_file([
            "LUT_3D_SIZE 2",
            "0    0 0.031",
            "0.96 0 0.031",
            "0    1 0.031",
            "0.96 1 0.031",
            "0    0 0.931",
            "0.96 0 0.931",
            "0    1 0.931",
            "0.96 1 0.931",
        ])
        self.assertEqual(lut.table.__class__.__name__, 'list')
        im.filter(lut)
Exemplo n.º 7
0
    def test_application(self):
        im = Image.new('RGB', (10, 10))

        lut_numpy = rgb_color_enhance(5, saturation=0.5)
        self.assertEqual(lut_numpy.table.__class__.__name__, 'ndarray')
        im.filter(lut_numpy)

        with disable_numpy(generators):
            lut_native = rgb_color_enhance(5, saturation=0.5)
        self.assertEqual(lut_native.table.__class__.__name__, 'list')
        im.filter(lut_native)

        lut_numpy = rgb_color_enhance(lut_native, saturation=0.5)
        self.assertEqual(lut_numpy.table.__class__.__name__, 'ndarray')
        im.filter(lut_numpy)

        with disable_numpy(generators):
            lut_native = rgb_color_enhance(lut_numpy, saturation=0.5)
        self.assertEqual(lut_native.table.__class__.__name__, 'list')
        im.filter(lut_native)
Exemplo n.º 8
0
 def test_simple_parse(self):
     lut = load_hald_image(Image.new('RGB', (64, 64)), target_mode='HSV')
     self.assertTrue(isinstance(lut, ImageFilter.Color3DLUT))
     self.assertEqual(tuple(lut.size), (16, 16, 16))
     self.assertEqual(lut.channels, 3)
     self.assertEqual(lut.mode, 'HSV')