PaletteOptimiser

Change of optimiser.py

69:92dade312953
optimiser.py
     1.1 --- a/optimiser.py	Fri Oct 09 19:01:18 2015 +0200
     1.2 +++ b/optimiser.py	Fri Oct 09 21:58:23 2015 +0200
     1.3 @@ -39,7 +39,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 @@ -392,9 +392,14 @@
    1.13                  value = get_value(rgb, most)
    1.14                  im.putpixel((x, y), value)
    1.15  
    1.16 +                if x < width - 1:
    1.17 +                    rgbn = im.getpixel((x+1, y))
    1.18 +                    rgbn = tuple(map(lambda i: clip(i[0] + (i[1] - i[2]) / 4.0), zip(rgbn, rgb, value)))
    1.19 +                    im.putpixel((x+1, y), rgbn)
    1.20 +
    1.21                  if y < height - 1:
    1.22                      rgbn = im.getpixel((x, y+1))
    1.23 -                    rgbn = tuple(map(lambda i: clip(i[0] + i[1] - i[2]), zip(rgbn, rgb, value)))
    1.24 +                    rgbn = tuple(map(lambda i: clip(i[0] + (i[1] - i[2]) / 2.0), zip(rgbn, rgb, value)))
    1.25                      im.putpixel((x, y+1), rgbn)
    1.26  
    1.27          im.save(output_filename)