forked from python-pillow/Pillow
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_image_point.py
43 lines (31 loc) · 1.32 KB
/
test_image_point.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
from helper import unittest, PillowTestCase, hopper
class TestImagePoint(PillowTestCase):
def test_sanity(self):
im = hopper()
self.assertRaises(ValueError, lambda: im.point(list(range(256))))
im.point(list(range(256))*3)
im.point(lambda x: x)
im = im.convert("I")
self.assertRaises(ValueError, lambda: im.point(list(range(256))))
im.point(lambda x: x*1)
im.point(lambda x: x+1)
im.point(lambda x: x*1+1)
self.assertRaises(TypeError, lambda: im.point(lambda x: x-1))
self.assertRaises(TypeError, lambda: im.point(lambda x: x/1))
def test_16bit_lut(self):
""" Tests for 16 bit -> 8 bit lut for converting I->L images
see https://github.com/python-pillow/Pillow/issues/440
"""
im = hopper("I")
im.point(list(range(256))*256, 'L')
def test_f_lut(self):
""" Tests for floating point lut of 8bit gray image """
im = hopper('L')
lut = [0.5 * float(x) for x in range(256)]
out = im.point(lut, 'F')
int_lut = [x//2 for x in range(256)]
self.assert_image_equal(out.convert('L'), im.point(int_lut, 'L'))
def test_f_mode(self):
self.assertRaises(ValueError, lambda: hopper('F').point(None))
if __name__ == '__main__':
unittest.main()