From e56aed1a950cd4a3fe329b2021217f4d6cb2ae24 Mon Sep 17 00:00:00 2001 From: homm Date: Wed, 8 Oct 2014 15:05:48 +0400 Subject: [PATCH] round pixel values --- Tests/test_imageops_usm.py | 18 +++++++++--------- libImaging/UnsharpMask.c | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Tests/test_imageops_usm.py b/Tests/test_imageops_usm.py index d1bdacd52..5164af015 100644 --- a/Tests/test_imageops_usm.py +++ b/Tests/test_imageops_usm.py @@ -66,7 +66,7 @@ class TestImageOpsUsm(PillowTestCase): def test_blur_accuracy(self): - i = snakes._new(ImageOps.gaussian_blur(snakes, .9)) + i = snakes._new(ImageOps.gaussian_blur(snakes, 1)) # Alpha channel must match whole. self.assertEqual(i.split()[3], snakes.split()[3]) # These pixels surrounded with pixels with 255 intensity. @@ -77,14 +77,14 @@ class TestImageOpsUsm(PillowTestCase): self.assertEqual(i.im.getpixel((x, y))[c], 255) # Fuzzy match. gp = lambda x, y: i.im.getpixel((x, y)) - self.assertTrue(212 <= gp(7, 4)[0] <= 214) - self.assertTrue(212 <= gp(7, 5)[2] <= 214) - self.assertTrue(212 <= gp(7, 6)[2] <= 214) - self.assertTrue(212 <= gp(7, 7)[1] <= 214) - self.assertTrue(212 <= gp(8, 4)[0] <= 214) - self.assertTrue(212 <= gp(8, 5)[2] <= 214) - self.assertTrue(212 <= gp(8, 6)[2] <= 214) - self.assertTrue(212 <= gp(8, 7)[1] <= 214) + self.assertTrue(211 <= gp(7, 4)[0] <= 213) + self.assertTrue(211 <= gp(7, 5)[2] <= 213) + self.assertTrue(211 <= gp(7, 6)[2] <= 213) + self.assertTrue(211 <= gp(7, 7)[1] <= 213) + self.assertTrue(211 <= gp(8, 4)[0] <= 213) + self.assertTrue(211 <= gp(8, 5)[2] <= 213) + self.assertTrue(211 <= gp(8, 6)[2] <= 213) + self.assertTrue(211 <= gp(8, 7)[1] <= 213) if __name__ == '__main__': unittest.main() diff --git a/libImaging/UnsharpMask.c b/libImaging/UnsharpMask.c index e3e975ef0..0e0eb66e4 100644 --- a/libImaging/UnsharpMask.c +++ b/libImaging/UnsharpMask.c @@ -51,7 +51,7 @@ static inline UINT8 clip(double in) return (UINT8) 255; if (in <= 0.0) return (UINT8) 0; - return (UINT8) in; + return (UINT8) (in + 0.5); } static Imaging