[gimp/pippin/linear-is-the-new-black: 13/13] app: brightness-contrast scale contrast around 50% gray



commit 8b308a17b506a7e5b0f58d00ebb065a74b9eb9c4
Author: Øyvind Kolås <pippin gimp org>
Date:   Wed Jan 4 02:01:00 2017 +0100

    app: brightness-contrast scale contrast around 50% gray
    
    In linear this means scaling results around 0.18 rather than 0.5

 app/operations/gimpbrightnesscontrastconfig.c    |   16 ++++++++--------
 app/operations/gimpoperationbrightnesscontrast.c |    2 +-
 2 files changed, 9 insertions(+), 9 deletions(-)
---
diff --git a/app/operations/gimpbrightnesscontrastconfig.c b/app/operations/gimpbrightnesscontrastconfig.c
index d3b3110..78b59be 100644
--- a/app/operations/gimpbrightnesscontrastconfig.c
+++ b/app/operations/gimpbrightnesscontrastconfig.c
@@ -185,7 +185,7 @@ gimp_brightness_contrast_config_to_levels_config (GimpBrightnessContrastConfig *
 
   if (config->brightness >= 0)
     {
-      value = -0.5 * slant + brightness * slant + 0.5;
+      value = -0.18 * slant + brightness * slant + 0.18;
 
       if (value < 0.0)
         {
@@ -195,45 +195,45 @@ gimp_brightness_contrast_config_to_levels_config (GimpBrightnessContrastConfig *
            * calculation of the brightness/contrast LUT in base/lut-funcs.h */
 
           levels->low_input[GIMP_HISTOGRAM_VALUE] =
-            (- brightness * slant + 0.5 * slant - 0.5) / (slant - brightness * slant);
+            (- brightness * slant + 0.18 * slant - 0.18) / (slant - brightness * slant);
         }
 
       levels->low_output[GIMP_HISTOGRAM_VALUE] = value;
 
-      value = 0.5 * slant + 0.5;
+      value = 0.82 * slant + 0.18;
 
       if (value > 1.0)
         {
           value = 1.0;
 
           levels->high_input[GIMP_HISTOGRAM_VALUE] =
-            (- brightness * slant + 0.5 * slant + 0.5) / (slant - brightness * slant);
+            (- brightness * slant + 0.18 * slant + 0.82) / (slant - brightness * slant);
         }
 
       levels->high_output[GIMP_HISTOGRAM_VALUE] = value;
     }
   else
     {
-      value = 0.5 - 0.5 * slant;
+      value = 0.18 - 0.18 * slant;
 
       if (value < 0.0)
         {
           value = 0.0;
 
           levels->low_input[GIMP_HISTOGRAM_VALUE] =
-            (0.5 * slant - 0.5) / (slant + brightness * slant);
+            (0.18 * slant - 0.18) / (slant + brightness * slant);
         }
 
       levels->low_output[GIMP_HISTOGRAM_VALUE] = value;
 
-      value = slant * brightness + slant * 0.5 + 0.5;
+      value = slant * brightness + slant * 0.82 + 0.18;
 
       if (value > 1.0)
         {
           value = 1.0;
 
           levels->high_input[GIMP_HISTOGRAM_VALUE] =
-            (0.5 * slant + 0.5) / (slant + brightness * slant);
+            (0.18 * slant + 0.82) / (slant + brightness * slant);
         }
 
       levels->high_output[GIMP_HISTOGRAM_VALUE] = value;
diff --git a/app/operations/gimpoperationbrightnesscontrast.c 
b/app/operations/gimpoperationbrightnesscontrast.c
index 274f290..656624c 100644
--- a/app/operations/gimpoperationbrightnesscontrast.c
+++ b/app/operations/gimpoperationbrightnesscontrast.c
@@ -102,7 +102,7 @@ gimp_operation_brightness_contrast_map (gfloat  value,
   else
     value = value + ((1.0 - value) * brightness);
 
-  value = (value - 0.5) * slant + 0.5;
+  value = (value - 0.18) * slant + 0.18;
 
   return value;
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]