[gegl] exposure: adjust clamping to avoid division by 0



commit a1c2b693e92c07c3af8b6a632fe5228422d23f3b
Author: Øyvind Kolås <pippin gimp org>
Date:   Wed Nov 15 01:39:13 2017 +0100

    exposure: adjust clamping to avoid division by 0
    
    The code contained MIN (reciprocal, 0.01) to avoid division by zero, resulting
    in a maximum gain of 100.0, this changes it to a maximum gain of 1000000.0,
    with some non-photographic sources such gains are entirely reasonable.

 operations/common/exposure.c |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)
---
diff --git a/operations/common/exposure.c b/operations/common/exposure.c
index 38d2bb0..1d1e355 100644
--- a/operations/common/exposure.c
+++ b/operations/common/exposure.c
@@ -145,7 +145,7 @@ process_rgb (GeglOperation       *op,
   out_pixel = out_buf;
 
   white = exp2f (exposure_negated);
-  diff = MAX (white - black_level, 0.01);
+  diff = MAX (white - black_level, 0.000001);
   gain = 1.0f / diff;
 
   for (i=0; i<n_pixels; i++)
@@ -182,7 +182,7 @@ process_rgba (GeglOperation       *op,
   out_pixel = out_buf;
   
   white = exp2f (exposure_negated);
-  diff = MAX (white - black_level, 0.01);
+  diff = MAX (white - black_level, 0.000001);
   gain = 1.0f / diff;
 
   for (i=0; i<n_pixels; i++)
@@ -220,7 +220,7 @@ process_y (GeglOperation       *op,
   out_pixel = out_buf;
 
   white = exp2f (exposure_negated);
-  diff = MAX (white - black_level, 0.01);
+  diff = MAX (white - black_level, 0.000001);
   gain = 1.0f / diff;
 
   for (i=0; i<n_pixels; i++)
@@ -255,7 +255,7 @@ process_ya (GeglOperation       *op,
   out_pixel = out_buf;
 
   white = exp2f (exposure_negated);
-  diff = MAX (white - black_level, 0.01);
+  diff = MAX (white - black_level, 0.000001);
   gain = 1.0f / diff;
 
   for (i=0; i<n_pixels; i++)
@@ -407,7 +407,7 @@ cl_process (GeglOperation       *op,
   cl_data_local = *params->cl_data_ptr;
 
   white = exp2f (exposure_negated);
-  diff = MAX (white - black_level, 0.01);
+  diff = MAX (white - black_level, 0.000001);
   gain = 1.0f / diff;
 
   cl_err |= gegl_clSetKernelArg(cl_data_local->kernel[0], 0, sizeof(cl_mem),   (void*)&in_tex);


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