mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-26 09:14:27 +03:00
fix hamming filter
This commit is contained in:
parent
98de727575
commit
ad883961ac
|
@ -158,14 +158,12 @@ class TestImagingCoreResampleAccuracy(PillowTestCase):
|
|||
|
||||
def test_enlarge_hamming(self):
|
||||
for mode in ['RGBX', 'RGB', 'La', 'L']:
|
||||
case = self.make_case(mode, (4, 4), 0xe1)
|
||||
case = case.resize((8, 8), Image.HAMMING)
|
||||
data = ('e1 e1 ea d1'
|
||||
'e1 e1 ea d1'
|
||||
'ea ea f4 d9'
|
||||
'd1 d1 d9 c4')
|
||||
case = self.make_case(mode, (2, 2), 0xe1)
|
||||
case = case.resize((4, 4), Image.HAMMING)
|
||||
data = ('e1 d2'
|
||||
'd2 c5')
|
||||
for channel in case.split():
|
||||
self.check_case(channel, self.make_sample(data, (8, 8)))
|
||||
self.check_case(channel, self.make_sample(data, (4, 4)))
|
||||
|
||||
def test_enlarge_bicubic(self):
|
||||
for mode in ['RGBX', 'RGB', 'La', 'L']:
|
||||
|
|
|
@ -32,6 +32,8 @@ static inline double hamming_filter(double x)
|
|||
x = -x;
|
||||
if (x == 0.0)
|
||||
return 1.0;
|
||||
if (x >= 1.0)
|
||||
return 0.0;
|
||||
x = x * M_PI;
|
||||
return sin(x) / x * (0.54f + 0.46f * cos(x));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user