mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-02-03 21:24:31 +03:00
serious test for kernel filters
This commit is contained in:
parent
5f5ac09158
commit
847dd67a41
BIN
Tests/images/hopper_emboss.bmp
Normal file
BIN
Tests/images/hopper_emboss.bmp
Normal file
Binary file not shown.
After Width: | Height: | Size: 48 KiB |
BIN
Tests/images/hopper_emboss_more.bmp
Normal file
BIN
Tests/images/hopper_emboss_more.bmp
Normal file
Binary file not shown.
After Width: | Height: | Size: 48 KiB |
|
@ -94,6 +94,28 @@ class TestImageFilter(PillowTestCase):
|
||||||
self.assertEqual(rankfilter.size, 1)
|
self.assertEqual(rankfilter.size, 1)
|
||||||
self.assertEqual(rankfilter.rank, 2)
|
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))
|
||||||
|
|
||||||
|
self.assert_image_equal(
|
||||||
|
emboss, Image.open("Tests/images/hopper_emboss.bmp"))
|
||||||
|
|
||||||
|
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))
|
||||||
|
|
||||||
|
self.assert_image_equal(
|
||||||
|
emboss, Image.open("Tests/images/hopper_emboss_more.bmp"))
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|
|
@ -92,6 +92,9 @@ ImagingFilter(Imaging im, int xsize, int ysize, const FLOAT32* kernel,
|
||||||
if (!imOut)
|
if (!imOut)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
// Add one time for rounding
|
||||||
|
offset += 0.5;
|
||||||
|
|
||||||
/* brute force kernel implementations */
|
/* brute force kernel implementations */
|
||||||
#define KERNEL3x3(image, kernel, d) ( \
|
#define KERNEL3x3(image, kernel, d) ( \
|
||||||
(int) image[y+1][x-d] * kernel[0] + \
|
(int) image[y+1][x-d] * kernel[0] + \
|
||||||
|
|
Loading…
Reference in New Issue
Block a user