2012-10-16 00:26:38 +04:00
|
|
|
from PIL import Image
|
|
|
|
|
2020-01-27 14:46:52 +03:00
|
|
|
from .helper import hopper
|
2019-07-06 23:40:53 +03:00
|
|
|
|
2012-10-16 00:26:38 +04:00
|
|
|
|
2020-01-27 14:46:52 +03:00
|
|
|
def test_sanity():
|
|
|
|
im = hopper()
|
2012-10-16 00:26:38 +04:00
|
|
|
|
2020-01-27 14:46:52 +03:00
|
|
|
projection = im.getprojection()
|
2012-10-16 00:26:38 +04:00
|
|
|
|
2020-01-27 14:46:52 +03:00
|
|
|
assert len(projection) == 2
|
|
|
|
assert len(projection[0]) == im.size[0]
|
|
|
|
assert len(projection[1]) == im.size[1]
|
2012-10-16 00:26:38 +04:00
|
|
|
|
2020-01-27 14:46:52 +03:00
|
|
|
# 8-bit image
|
|
|
|
im = Image.new("L", (10, 10))
|
|
|
|
assert im.getprojection()[0] == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
|
|
|
|
assert im.getprojection()[1] == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
|
|
|
|
im.paste(255, (2, 4, 8, 6))
|
|
|
|
assert im.getprojection()[0] == [0, 0, 1, 1, 1, 1, 1, 1, 0, 0]
|
|
|
|
assert im.getprojection()[1] == [0, 0, 0, 0, 1, 1, 0, 0, 0, 0]
|
2012-10-16 00:26:38 +04:00
|
|
|
|
2020-01-27 14:46:52 +03:00
|
|
|
# 32-bit image
|
|
|
|
im = Image.new("RGB", (10, 10))
|
|
|
|
assert im.getprojection()[0] == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
|
|
|
|
assert im.getprojection()[1] == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
|
|
|
|
im.paste(255, (2, 4, 8, 6))
|
|
|
|
assert im.getprojection()[0] == [0, 0, 1, 1, 1, 1, 1, 1, 0, 0]
|
|
|
|
assert im.getprojection()[1] == [0, 0, 0, 0, 1, 1, 0, 0, 0, 0]
|