# HG changeset patch # User Paul Boddie # Date 1444483441 -7200 # Node ID 7a5a1508ef30f51099b49857cce06fed3f9badc7 # Parent e0fe30d7b8b13f2108857d313baa3dae2a1235fd Removed a superfluous function, made naming and result changes for clarity. diff -r e0fe30d7b8b1 -r 7a5a1508ef30 optimiser.py --- a/optimiser.py Sat Oct 10 15:16:51 2015 +0200 +++ b/optimiser.py Sat Oct 10 15:24:01 2015 +0200 @@ -25,7 +25,6 @@ import EXIF import PIL.Image import itertools -import math import sys corners = [ @@ -41,11 +40,6 @@ def clip(v): return int(within(v, 0, 255)) -def distance(rgb1, rgb2): - r1, g1, b1 = rgb1 - r2, g2, b2 = rgb2 - return math.sqrt(pow(r1 - r2, 2) + pow(g1 - g2, 2) + pow(b1 - b2, 2)) - def restore(srgb): r, g, b = srgb return int(r * 255.0), int(g * 255.0), int(b * 255.0) @@ -70,9 +64,9 @@ # Get the colour with components scaled from 0 to 1, plus the inverted # component values. - rgb = scale(rgb) - rgbi = invert(rgb) - pairs = zip(rgbi, rgb) + srgb = scale(rgb) + rgbi = invert(srgb) + pairs = zip(rgbi, srgb) # For each corner of the colour cube (primary and secondary colours plus # black and white), calculate the corner value's contribution to the @@ -124,7 +118,7 @@ out[0] += v * rgb[0] out[1] += v * rgb[1] out[2] += v * rgb[2] - return out + return tuple(map(int, out)) def pattern(rgb, chosen=None): @@ -199,9 +193,9 @@ else: c[value] += f - c = [(n/width, value) for value, n in c.items()] - c.sort(reverse=True) - return c + d = [(n/width, value) for value, n in c.items()] + d.sort(reverse=True) + return d def get_combinations(c, n):