# HG changeset patch # User Paul Boddie # Date 1444175486 -7200 # Node ID e017e76791a0602895f727aaa07f138a2af89b32 # Parent 075e5f1f12e316c69e5f2f4c83bcbbf5c3d10fbd Reduced the propagated error by half. diff -r 075e5f1f12e3 -r e017e76791a0 optimiser.py --- a/optimiser.py Wed Oct 07 00:49:40 2015 +0200 +++ b/optimiser.py Wed Oct 07 01:51:26 2015 +0200 @@ -17,7 +17,7 @@ return min(max(v, lower), upper) def clip(v): - return within(v, 0, 255) + return int(within(v, 0, 255)) def distance(rgb1, rgb2): r1, g1, b1 = rgb1 @@ -250,7 +250,7 @@ if y < height - 1: rgbn = im.getpixel((x, y+1)) - rgbn = tuple(map(lambda i: clip(i[0] + i[1] - i[2]), zip(rgbn, rgb, value))) + rgbn = tuple(map(lambda i: clip(i[0] + (i[1] - i[2]) / 2.0), zip(rgbn, rgb, value))) im.putpixel((x, y+1), rgbn) im.save(output_filename)