mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-26 01:04:29 +03:00
Tests for all bands and combinations
This commit is contained in:
parent
c5865f9abe
commit
b31c74a9cc
|
@ -95,26 +95,40 @@ class TestImageFilter(PillowTestCase):
|
|||
self.assertEqual(rankfilter.rank, 2)
|
||||
|
||||
def test_consistency_3x3(self):
|
||||
im = Image.open("Tests/images/hopper.bmp")
|
||||
emboss = im.filter(ImageFilter.Kernel((3, 3),
|
||||
(-1, -1, 0,
|
||||
-1, 0, 1,
|
||||
0, 1, 1), .3))
|
||||
source = Image.open("Tests/images/hopper.bmp")
|
||||
reference = Image.open("Tests/images/hopper_emboss.bmp")
|
||||
kernel = ImageFilter.Kernel((3, 3),
|
||||
(-1, -1, 0,
|
||||
-1, 0, 1,
|
||||
0, 1, 1), .3)
|
||||
source = source.split() * 2
|
||||
reference = reference.split() * 2
|
||||
|
||||
self.assert_image_equal(
|
||||
emboss, Image.open("Tests/images/hopper_emboss.bmp"))
|
||||
for mode in ['L', 'LA', 'RGB', 'CMYK']:
|
||||
print mode
|
||||
self.assert_image_equal(
|
||||
Image.merge(mode, source[:len(mode)]).filter(kernel),
|
||||
Image.merge(mode, reference[:len(mode)]),
|
||||
)
|
||||
|
||||
def test_consistency_5x5(self):
|
||||
im = Image.open("Tests/images/hopper.bmp")
|
||||
emboss = im.filter(ImageFilter.Kernel((5, 5),
|
||||
(-1, -1, -1, -1, 0,
|
||||
-1, -1, -1, 0, 1,
|
||||
-1, -1, 0, 1, 1,
|
||||
-1, 0, 1, 1, 1,
|
||||
0, 1, 1, 1, 1), 0.3))
|
||||
source = Image.open("Tests/images/hopper.bmp")
|
||||
reference = Image.open("Tests/images/hopper_emboss_more.bmp")
|
||||
kernel = ImageFilter.Kernel((5, 5),
|
||||
(-1, -1, -1, -1, 0,
|
||||
-1, -1, -1, 0, 1,
|
||||
-1, -1, 0, 1, 1,
|
||||
-1, 0, 1, 1, 1,
|
||||
0, 1, 1, 1, 1), 0.3)
|
||||
source = source.split() * 2
|
||||
reference = reference.split() * 2
|
||||
|
||||
self.assert_image_equal(
|
||||
emboss, Image.open("Tests/images/hopper_emboss_more.bmp"))
|
||||
for mode in ['L', 'LA', 'RGB', 'CMYK']:
|
||||
print mode
|
||||
self.assert_image_equal(
|
||||
Image.merge(mode, source[:len(mode)]).filter(kernel),
|
||||
Image.merge(mode, reference[:len(mode)]),
|
||||
)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
Loading…
Reference in New Issue
Block a user