From 9f40107edaee5f2980ecd39eefc41cf3254d150b Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Mon, 10 Mar 2014 17:18:49 +0100 Subject: add cie_manipulate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/curve.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/curve.py') diff --git a/src/curve.py b/src/curve.py index 4ef52a4..cac2b53 100644 --- a/src/curve.py +++ b/src/curve.py @@ -473,6 +473,22 @@ def manipulate(r, g = None, b = None): curve[i] = f(curve[i]) +def cie_manipulate(f): + ''' + Manipulate the colour curves using a lambda function on the CIE xyY colour space + + @param f:(float)?→float Lambda function to manipulate the Y component, nothing is done if `f` is `None` + + The lambda functions thats a colour value and maps it to a new illumination value. + For example, if the value 0.5 is already mapped to 0.25, then if the function + maps 0.25 to 0.5, the value 0.5 will revert back to being mapped to 0.5. + ''' + if f is not None: + for i in range(i_size): + (x, y, Y) = srgb_to_ciexyy(r_curve[i], g_curve[i], b_curve[i]) + (r_curve[i], g_curve[i], b_curve[i]) = ciexyy_to_srgb(x, y, f(Y)) + + def lower_resolution(rx_colours = None, ry_colours = None, gx_colours = None, gy_colours = None, bx_colours = None, by_colours = None): ''' Emulates low colour resolution -- cgit v1.2.3-70-g09d2