# HG changeset patch # User Paul Boddie # Date 1444481836 -7200 # Node ID b147df07482fe86e9479a8979ba3e17de41fb577 # Parent 4cafde6aa7379453e718ed03fedc5722785c1294 Converted other channel operations to explicit RGB operations. diff -r 4cafde6aa737 -r b147df07482f optimiser.py --- a/optimiser.py Sat Oct 10 14:53:29 2015 +0200 +++ b/optimiser.py Sat Oct 10 14:57:16 2015 +0200 @@ -161,13 +161,15 @@ return x >= 0 and 1 or -1 def saturate_rgb(rgb, exp): - return tuple([saturate_value(x, exp) for x in rgb]) + r, g, b = rgb + return saturate_value(r, exp), saturate_value(g, exp), saturate_value(b, exp) def saturate_value(x, exp): return int(127.5 + sign(x - 127.5) * 127.5 * pow(abs(x - 127.5) / 127.5, exp)) def amplify_rgb(rgb, exp): - return tuple([amplify_value(x, exp) for x in rgb]) + r, g, b = rgb + return amplify_value(r, exp), amplify_value(g, exp), amplify_value(b, exp) def amplify_value(x, exp): return int(pow(x / 255.0, exp) * 255.0) @@ -339,12 +341,20 @@ if x < width - 1: rgbn = im.getpixel((x+1, y)) - rgbn = tuple(map(lambda i: clip(i[0] + (i[1] - i[2]) / 4.0), zip(rgbn, rgb, value))) + rgbn = ( + clip(rgbn[0] + (rgb[0] - value[0]) / 4.0), + clip(rgbn[1] + (rgb[1] - value[1]) / 4.0), + clip(rgbn[2] + (rgb[2] - value[2]) / 4.0) + ) im.putpixel((x+1, y), rgbn) if y < height - 1: rgbn = im.getpixel((x, y+1)) - rgbn = tuple(map(lambda i: clip(i[0] + (i[1] - i[2]) / 2.0), zip(rgbn, rgb, value))) + rgbn = ( + clip(rgbn[0] + (rgb[0] - value[0]) / 2.0), + clip(rgbn[1] + (rgb[1] - value[1]) / 2.0), + clip(rgbn[2] + (rgb[2] - value[2]) / 2.0) + ) im.putpixel((x, y+1), rgbn) def get_float(options, flag):