Merge branch 'master' into fast-filters

# Conflicts:
#	libImaging/Filter.c
This commit is contained in:
Alexander 2017-08-12 23:43:25 +03:00
commit 49492def9b
6 changed files with 55 additions and 30 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

View File

@ -94,6 +94,28 @@ class TestImageFilter(PillowTestCase):
self.assertEqual(rankfilter.size, 1)
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__':
unittest.main()

View File

@ -247,7 +247,7 @@ PyObject* WebPDecoderVersion_wrapper(PyObject* self, PyObject* args){
* The version of webp that ships with (0.1.3) Ubuntu 12.04 doesn't handle alpha well.
* Files that are valid with 0.3 are reported as being invalid.
*/
int WebPDecoderBuggyAlpha() {
int WebPDecoderBuggyAlpha(void) {
return WebPGetDecoderVersion()==0x0103;
}

View File

@ -136,6 +136,9 @@ ImagingFilter(Imaging im, int xsize, int ysize, const FLOAT32* kernel,
if (!imOut)
return NULL;
// Add one time for rounding
offset += 0.5;
#define KERNEL5x5(image, kernel, d) ( \
(int) image[y+2][x-d-d] * kernel[0] + \
(int) image[y+2][x-d] * kernel[1] + \