Define box filter equal 1.0 on (-0.5, 0.5] range instead of [-0.5, 0.5)

This commit is contained in:
Alexander 2019-12-19 02:52:34 +03:00
parent 8aad32a010
commit 5b53b0489b
2 changed files with 6 additions and 1 deletions

View File

@ -212,6 +212,11 @@ class TestImagingCoreResampleAccuracy(PillowTestCase):
for channel in case.split(): for channel in case.split():
self.check_case(channel, self.make_sample(data, (12, 12))) self.check_case(channel, self.make_sample(data, (12, 12)))
def test_box_filter_correct_range(self):
im = Image.new("RGB", (8, 8), "#1688ff").resize((100, 100), Image.BOX)
ref = Image.new("RGB", (100, 100), "#1688ff")
self.assert_image_equal(im, ref)
class CoreResampleConsistencyTest(PillowTestCase): class CoreResampleConsistencyTest(PillowTestCase):
def make_case(self, mode, fill): def make_case(self, mode, fill):

View File

@ -13,7 +13,7 @@ struct filter {
static inline double box_filter(double x) static inline double box_filter(double x)
{ {
if (x >= -0.5 && x < 0.5) if (x > -0.5 && x <= 0.5)
return 1.0; return 1.0;
return 0.0; return 0.0;
} }