mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-04-25 03:23:41 +03:00
test for consistency
This commit is contained in:
parent
e13297b396
commit
9618ec98b8
|
@ -150,5 +150,22 @@ class TestImagingCoreResampleAccuracy(PillowTestCase):
|
||||||
self.make_sample(data, (12, 12)))
|
self.make_sample(data, (12, 12)))
|
||||||
|
|
||||||
|
|
||||||
|
class CoreResampleConsistencyTest(PillowTestCase):
|
||||||
|
|
||||||
|
def test_8u(self):
|
||||||
|
im = Image.new('RGB', (512, 9), (0, 64, 255))
|
||||||
|
im = im.resize((9, 512), Image.LANCZOS)
|
||||||
|
r, g, b = im.split()
|
||||||
|
|
||||||
|
for channel, color in [(r, 0), (g, 64), (b, 255)]:
|
||||||
|
px = channel.load()
|
||||||
|
for x in range(channel.size[0]):
|
||||||
|
for y in range(channel.size[1]):
|
||||||
|
if px[x, y] != color:
|
||||||
|
message = "{} != {} for pixel {}".format(
|
||||||
|
px[x, y], color, (x, y))
|
||||||
|
self.assertEqual(px[x, y], color, message)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|
|
@ -178,7 +178,7 @@ ImagingResampleHorizontal(Imaging imIn, int xsize, struct filter *filterp)
|
||||||
xmin = xbounds[xx * 2 + 0];
|
xmin = xbounds[xx * 2 + 0];
|
||||||
xmax = xbounds[xx * 2 + 1];
|
xmax = xbounds[xx * 2 + 1];
|
||||||
k = &kk[xx * kmax];
|
k = &kk[xx * kmax];
|
||||||
ss0 = 0;
|
ss0 = 1 << (PRECISION_BITS -1);
|
||||||
for (x = xmin; x < xmax; x++)
|
for (x = xmin; x < xmax; x++)
|
||||||
ss0 += ((UINT8) imIn->image8[yy][x]) * k[x - xmin];
|
ss0 += ((UINT8) imIn->image8[yy][x]) * k[x - xmin];
|
||||||
imOut->image8[yy][xx] = clip8(ss0);
|
imOut->image8[yy][xx] = clip8(ss0);
|
||||||
|
@ -192,7 +192,7 @@ ImagingResampleHorizontal(Imaging imIn, int xsize, struct filter *filterp)
|
||||||
xmin = xbounds[xx * 2 + 0];
|
xmin = xbounds[xx * 2 + 0];
|
||||||
xmax = xbounds[xx * 2 + 1];
|
xmax = xbounds[xx * 2 + 1];
|
||||||
k = &kk[xx * kmax];
|
k = &kk[xx * kmax];
|
||||||
ss0 = ss1 = 0;
|
ss0 = ss1 = 1 << (PRECISION_BITS -1);
|
||||||
for (x = xmin; x < xmax; x++) {
|
for (x = xmin; x < xmax; x++) {
|
||||||
ss0 += ((UINT8) imIn->image[yy][x*4 + 0]) * k[x - xmin];
|
ss0 += ((UINT8) imIn->image[yy][x*4 + 0]) * k[x - xmin];
|
||||||
ss1 += ((UINT8) imIn->image[yy][x*4 + 3]) * k[x - xmin];
|
ss1 += ((UINT8) imIn->image[yy][x*4 + 3]) * k[x - xmin];
|
||||||
|
@ -205,7 +205,7 @@ ImagingResampleHorizontal(Imaging imIn, int xsize, struct filter *filterp)
|
||||||
xmin = xbounds[xx * 2 + 0];
|
xmin = xbounds[xx * 2 + 0];
|
||||||
xmax = xbounds[xx * 2 + 1];
|
xmax = xbounds[xx * 2 + 1];
|
||||||
k = &kk[xx * kmax];
|
k = &kk[xx * kmax];
|
||||||
ss0 = ss1 = ss2 = 0;
|
ss0 = ss1 = ss2 = 1 << (PRECISION_BITS -1);
|
||||||
for (x = xmin; x < xmax; x++) {
|
for (x = xmin; x < xmax; x++) {
|
||||||
ss0 += ((UINT8) imIn->image[yy][x*4 + 0]) * k[x - xmin];
|
ss0 += ((UINT8) imIn->image[yy][x*4 + 0]) * k[x - xmin];
|
||||||
ss1 += ((UINT8) imIn->image[yy][x*4 + 1]) * k[x - xmin];
|
ss1 += ((UINT8) imIn->image[yy][x*4 + 1]) * k[x - xmin];
|
||||||
|
@ -220,7 +220,7 @@ ImagingResampleHorizontal(Imaging imIn, int xsize, struct filter *filterp)
|
||||||
xmin = xbounds[xx * 2 + 0];
|
xmin = xbounds[xx * 2 + 0];
|
||||||
xmax = xbounds[xx * 2 + 1];
|
xmax = xbounds[xx * 2 + 1];
|
||||||
k = &kk[xx * kmax];
|
k = &kk[xx * kmax];
|
||||||
ss0 = ss1 = ss2 = ss3 = 0;
|
ss0 = ss1 = ss2 = ss3 = 1 << (PRECISION_BITS -1);
|
||||||
for (x = xmin; x < xmax; x++) {
|
for (x = xmin; x < xmax; x++) {
|
||||||
ss0 += ((UINT8) imIn->image[yy][x*4 + 0]) * k[x - xmin];
|
ss0 += ((UINT8) imIn->image[yy][x*4 + 0]) * k[x - xmin];
|
||||||
ss1 += ((UINT8) imIn->image[yy][x*4 + 1]) * k[x - xmin];
|
ss1 += ((UINT8) imIn->image[yy][x*4 + 1]) * k[x - xmin];
|
||||||
|
|
Loading…
Reference in New Issue
Block a user