From b126e6167772e61a831d0547681daff5d5cbccd1 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Fri, 14 Feb 2014 18:21:13 +0100 Subject: fix derp on whitepoint adj MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/curve.py | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) (limited to 'src/curve.py') diff --git a/src/curve.py b/src/curve.py index d3e2a2d..cc3de36 100644 --- a/src/curve.py +++ b/src/curve.py @@ -175,15 +175,27 @@ def temperature(temperature, algorithm, linear_rgb = True): r_curve[i], g_curve[i], b_curve[i] = R, G, B -def divide_by_maximum(): +def divide_by_maximum(rgb): ''' - Divide all colour components by the value of the most prominent colour component for each colour + Divide all colour components by the value of the most prominent colour component + + @param rgb:[float, float, float] The three colour components + @return :[float, float, float] The three colour components divided by the maximum + ''' + m = max([abs(x) for x in rgb]) + if m != 0: + return [x / m for x in rgb] + return rgb + + +def clip_whitepoint(rgb): + ''' + Clip all colour components to fit inside [0, 1] + + @param rgb:[float, float, float] The three colour components + @return :[float, float, float] The three colour components clipped ''' - for i in range(i_size): - m = max([abs(x) for x in (r_curve[i], g_curve[i], b_curve[i])]) - if m != 0: - for curve in (r_curve, g_curve, b_curve): - curve[i] /= m + return [min(max(0, x), 1) for x in rgb] def rgb_contrast(r, g, b): -- cgit v1.2.3-70-g09d2