1.1 --- a/optimiser.py Sat Oct 10 15:16:51 2015 +0200
1.2 +++ b/optimiser.py Sat Oct 10 15:24:01 2015 +0200
1.3 @@ -25,7 +25,6 @@
1.4 import EXIF
1.5 import PIL.Image
1.6 import itertools
1.7 -import math
1.8 import sys
1.9
1.10 corners = [
1.11 @@ -41,11 +40,6 @@
1.12 def clip(v):
1.13 return int(within(v, 0, 255))
1.14
1.15 -def distance(rgb1, rgb2):
1.16 - r1, g1, b1 = rgb1
1.17 - r2, g2, b2 = rgb2
1.18 - return math.sqrt(pow(r1 - r2, 2) + pow(g1 - g2, 2) + pow(b1 - b2, 2))
1.19 -
1.20 def restore(srgb):
1.21 r, g, b = srgb
1.22 return int(r * 255.0), int(g * 255.0), int(b * 255.0)
1.23 @@ -70,9 +64,9 @@
1.24 # Get the colour with components scaled from 0 to 1, plus the inverted
1.25 # component values.
1.26
1.27 - rgb = scale(rgb)
1.28 - rgbi = invert(rgb)
1.29 - pairs = zip(rgbi, rgb)
1.30 + srgb = scale(rgb)
1.31 + rgbi = invert(srgb)
1.32 + pairs = zip(rgbi, srgb)
1.33
1.34 # For each corner of the colour cube (primary and secondary colours plus
1.35 # black and white), calculate the corner value's contribution to the
1.36 @@ -124,7 +118,7 @@
1.37 out[0] += v * rgb[0]
1.38 out[1] += v * rgb[1]
1.39 out[2] += v * rgb[2]
1.40 - return out
1.41 + return tuple(map(int, out))
1.42
1.43 def pattern(rgb, chosen=None):
1.44
1.45 @@ -199,9 +193,9 @@
1.46 else:
1.47 c[value] += f
1.48
1.49 - c = [(n/width, value) for value, n in c.items()]
1.50 - c.sort(reverse=True)
1.51 - return c
1.52 + d = [(n/width, value) for value, n in c.items()]
1.53 + d.sort(reverse=True)
1.54 + return d
1.55
1.56 def get_combinations(c, n):
1.57