PaletteOptimiser

Changeset

55:e017e76791a0
2015-10-07 Paul Boddie raw files shortlog changelog graph Reduced the propagated error by half.
optimiser.py (file)
     1.1 --- a/optimiser.py	Wed Oct 07 00:49:40 2015 +0200
     1.2 +++ b/optimiser.py	Wed Oct 07 01:51:26 2015 +0200
     1.3 @@ -17,7 +17,7 @@
     1.4      return min(max(v, lower), upper)
     1.5  
     1.6  def clip(v):
     1.7 -    return within(v, 0, 255)
     1.8 +    return int(within(v, 0, 255))
     1.9  
    1.10  def distance(rgb1, rgb2):
    1.11      r1, g1, b1 = rgb1
    1.12 @@ -250,7 +250,7 @@
    1.13  
    1.14                  if y < height - 1:
    1.15                      rgbn = im.getpixel((x, y+1))
    1.16 -                    rgbn = tuple(map(lambda i: clip(i[0] + i[1] - i[2]), zip(rgbn, rgb, value)))
    1.17 +                    rgbn = tuple(map(lambda i: clip(i[0] + (i[1] - i[2]) / 2.0), zip(rgbn, rgb, value)))
    1.18                      im.putpixel((x, y+1), rgbn)
    1.19  
    1.20          im.save(output_filename)