Bug 142571 - Auto-exposure result is different from the preview
Summary: Auto-exposure result is different from the preview
Status: RESOLVED FIXED
Alias: None
Product: digikam
Classification: Applications
Component: Plugin-Editor-AutoColors (show other bugs)
Version: unspecified
Platform: Gentoo Packages Linux
: NOR normal
Target Milestone: ---
Assignee: Digikam Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-03-05 22:20 UTC by Frédéric COIFFIER
Modified: 2017-08-06 21:16 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In: 0.9.2
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Frédéric COIFFIER 2007-03-05 22:20:12 UTC
Version:           0.9.1-rc1 (using KDE KDE 3.5.6)
Installed from:    Gentoo Packages
Compiler:          gcc (GCC) 4.1.1 (Gentoo 4.1.1-r3) 
OS:                Linux

When the Auto-exposure mode is selected in Color correction, the preview seems good (lighter than the original, in my case). But, if I apply this correction, the result is different and darker.
Comment 1 Joerg Kuehne 2007-03-08 22:34:02 UTC
The Auto-exposure values calculated from prewiew picture are different from the values of the original picture (black/white point). 
Try the following patch. It works fine for me.

----------------------------------------------------

Index: libs/whitebalance/whitebalance.cpp
===================================================================
--- libs/whitebalance/whitebalance.cpp	(revision 640698)
+++ libs/whitebalance/whitebalance.cpp	(working copy)
@@ -179,18 +179,13 @@
        
     // Calculate optimal exposition and black level 
     
-    int    stop, i, scale, w, h;
-    double sum;
+    double sum, stop;
+    int i;
     uint   rgbMax = sb ? 65536 : 256;
     
-    w     = width  / 400;
-    h     = height / 400;
-    scale = QMAX(w, h);
-    scale = QMAX(1, scale);
-    
     // Cutoff at 0.5% of the histogram.
     
-    stop = ((uint)(width / scale)*(uint)(height / scale)) / 200;
+    stop = width * height / 200.0;
     
     for (i = rgbMax, sum = 0; (i >= 0) && (sum < stop); i--)
         sum += histogram->getValue(Digikam::ImageHistogram::ValueChannel, i);
@@ -198,10 +193,6 @@
     expo = -log((float)(i+1) / rgbMax) / log(2);
     DDebug() << "White level at:" << i << endl;
     
-    // Cutoff at 0.5% of the histogram. 
-    
-    stop = ((uint)(width / scale)*(uint)(height / scale)) / 200;
-    
     for (i = 1, sum = 0; (i < (int)rgbMax) && (sum < stop); i++)
         sum += histogram->getValue(Digikam::ImageHistogram::ValueChannel, i);

--------------------------------------------------

Jörg
Comment 2 caulier.gilles 2007-03-12 09:28:45 UTC
SVN commit 641661 by cgilles:

digikam from trunk : fix auto exposure computation algorithm. Patch from Joerg Kuehne.
BUG: 142571

 M  +4 -13     whitebalance.cpp  


--- trunk/extragear/graphics/digikam/libs/whitebalance/whitebalance.cpp #641660:641661
@@ -179,18 +179,13 @@
        
     // Calculate optimal exposition and black level 
     
-    int    stop, i, scale, w, h;
-    double sum;
+    int    i;
+    double sum, stop;
     uint   rgbMax = sb ? 65536 : 256;
-    
-    w     = width  / 400;
-    h     = height / 400;
-    scale = QMAX(w, h);
-    scale = QMAX(1, scale);
-    
+        
     // Cutoff at 0.5% of the histogram.
     
-    stop = ((uint)(width / scale)*(uint)(height / scale)) / 200;
+    stop = width * height / 200;
     
     for (i = rgbMax, sum = 0; (i >= 0) && (sum < stop); i--)
         sum += histogram->getValue(Digikam::ImageHistogram::ValueChannel, i);
@@ -198,10 +193,6 @@
     expo = -log((float)(i+1) / rgbMax) / log(2);
     DDebug() << "White level at:" << i << endl;
     
-    // Cutoff at 0.5% of the histogram. 
-    
-    stop = ((uint)(width / scale)*(uint)(height / scale)) / 200;
-    
     for (i = 1, sum = 0; (i < (int)rgbMax) && (sum < stop); i++)
         sum += histogram->getValue(Digikam::ImageHistogram::ValueChannel, i);