From bb1332aa418415eab6b5d731d8a4c1b84b36db77 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Fri, 21 Feb 2014 02:57:28 +0100 Subject: rename negative to invert (mirror y) and add negative that reverses (mirror x) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- examples/comprehensive | 3 ++- info/blueshift.texinfo | 18 ++++++++++++++++-- src/curve.py | 19 ++++++++++++++++++- 3 files changed, 36 insertions(+), 4 deletions(-) diff --git a/examples/comprehensive b/examples/comprehensive index 9b9bf36..bcb20c1 100644 --- a/examples/comprehensive +++ b/examples/comprehensive @@ -3,7 +3,8 @@ # This example is complete with exceptions for less normal colour # curve modifiers: nothing else than CIE 1964 10 degree CMF for # colour temperature, not use of temporarly linear RGB curves, -# negative image, sigmoid correction, or free function modifier. +# negative image, inverted image, sigmoid correction, or free +# function modifier. # Geographical coodinates. diff --git a/info/blueshift.texinfo b/info/blueshift.texinfo index d32aba6..0360956 100644 --- a/info/blueshift.texinfo +++ b/info/blueshift.texinfo @@ -321,13 +321,27 @@ and @code{b} on the red, green and blue curves, respectively. @item negative() -Inverts the all values on the colour curves. +Reverse the colour curves on the encoding axis. +This creates a negative image with preserved gamma. @item negative(rgb) -Inverts the all values on the colour curves +Reverse the colour curves on the encoding axis if @code{rgb} is @code{True}. @item negative(r, g, b) +Reverse the red, green and blue curves on the +encoding axis if @code{r}, @code{g} and @code{b} +are @code{True}, respectively. + +@item invert() +Inverts the all values on the colour curves. +This creates a negative image with inverted gamma. + +@item invert(rgb) +Inverts the all values on the colour curves +if @code{rgb} is @code{True}. + +@item invert(r, g, b) Inverts the all values on the red, green and blue curves if @code{r}, @code{g} and @code{b} are @code{True}, respectively. diff --git a/src/curve.py b/src/curve.py index 6446a2a..001108f 100644 --- a/src/curve.py +++ b/src/curve.py @@ -336,7 +336,24 @@ def gamma(r, g = None, b = None): def negative(r = True, g = None, b = None): ''' - Invert the colour curves (negative image) + Revese the colour curves (negative image with gamma preservation) + + @param r:bool Whether to invert the red curve + @param g:bool? Whether to invert the green curve, defaults to `r` if `None` + @param b:bool? Whether to invert the blue curve, defaults to `r` if `None` + ''' + if g is None: g = r + if b is None: b = r + for (curve, setting) in curves(r, g, b): + if setting: + for i in range(i_size // 2): + j = i_size - 1 - i + curve[i], curve[j] = curve[j], curve[i] + + +def invert(r = True, g = None, b = None): + ''' + Invert the colour curves (negative image with gamma invertion) @param r:bool Whether to invert the red curve @param g:bool? Whether to invert the green curve, defaults to `r` if `None` -- cgit v1.2.3-70-g09d2