Bug 279255 - white balance method "camera" does not use the camera's values
Summary: white balance method "camera" does not use the camera's values
Status: RESOLVED FIXED
Alias: None
Product: digikam
Classification: Applications
Component: Plugin-DImg-RAW (show other bugs)
Version: 2.8.0
Platform: Compiled Sources Linux
: NOR normal
Target Milestone: ---
Assignee: Digikam Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-08-03 05:16 UTC by S. Burmeister
Modified: 2016-07-15 18:55 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In: 5.1.0


Attachments
comparison digikam with libraw against dcraw (708.09 KB, image/png)
2011-08-06 07:39 UTC, S. Burmeister
Details
comparison dcraw against darktable (720.24 KB, image/png)
2011-08-06 07:42 UTC, S. Burmeister
Details
comparison dcraw against libdcraw_emu (614.31 KB, image/png)
2011-08-06 08:00 UTC, S. Burmeister
Details
Comparison: jpg, digikam, dcraw -w (901.96 KB, image/png)
2012-07-23 20:54 UTC, S. Burmeister
Details
comparison: dcraw, digikam, dcraw_emu (639.55 KB, image/png)
2012-07-24 08:34 UTC, S. Burmeister
Details
dcraw settings (16.39 KB, image/png)
2012-09-23 20:29 UTC, S. Burmeister
Details
raw settings 2 (27.30 KB, image/png)
2012-09-23 20:34 UTC, S. Burmeister
Details

Note You need to log in before you can comment on or make changes to this bug.
Description S. Burmeister 2011-08-03 05:16:51 UTC
Version:           2.0.0 (using KDE 4.7.0) 
OS:                Linux

If one issues dcaw on a RW2 picture with the "-w" option it shows the values for white balance the camera set.

If digikam is set to "camera" for the "white balance method" it should use those exact values.

However digikam's output shows that it uses different values.

dcraw:
Scaling with darkness 15, saturation 4095, and
multipliers 1.901141 1.000000 1.745247 1.000000

digikam:
Scaling with darkness 0, saturation 4080, and
multipliers 1,000000 0,526000 0,918000 0,526000

dcraw_emu from libkdcraw:
Scaling with darkness 0, saturation 4080, and
multipliers 1.901141 1.000000 1.745247 1.000000

As you can see digikam as well as dcraw_emu use the wrong values for darkness and saturation.

dcraw_emu uses the correct values for the multipliers while digikam does not use those absolute values, i.e. strictly speaking does not use the camera's white balance but only its ratio. Since this does make a difference it should only be used if the user enabled it!

In case the absolute white balance values blow a channel it might make sense to have a darker image but no blown channels – but only as option, e.g. "use value ratio".

Reproducible: Didn't try

Steps to Reproduce:
Isse dcaw -w, digikam and dcraw_emu on a RAW picture (RW2 in this case) and compare the values.

Actual Results:  
different values

Expected Results:  
same values.
Comment 1 S. Burmeister 2011-08-04 07:15:24 UTC
digiKam version 2.1.0
Exiv2 can write to Jp2: Yes
Exiv2 can write to Jpeg: Yes
Exiv2 can write to Pgf: Yes
Exiv2 can write to Png: Yes
Exiv2 can write to Tiff: Yes
Exiv2 supports XMP metadata: Yes
LibCImg: 130
LibClapack: internal library
LibExiv2: 0.20
LibJPEG: 62
LibJasper: 1.900.1
LibKDE: 4.7.00 (4.7.0)
LibKExiv2: 2.0.0
LibKGeoMap: 2.0.0
LibKdcraw: 2.0.0
LibLCMS: 119
LibPGF: 6.11.24 - internal library
LibPNG: 1.2.44
LibQt: 4.7.3
LibRaw: 0.13.7
LibTIFF: LIBTIFF, Version 3.9.4 Copyright (c) 1988-1996 Sam Leffler Copyright (c) 1991-1996 Silicon Graphics, Inc.
Marble Widget: 0.11.95 (0.12 RC 2)
Parallelized demosaicing: Yes
Database backend: QSQLITE
LibGphoto2: 2.4.10
LibKface: 2.0.0
LibKipi: 1.2.0
LibOpenCV: 2.2.0
Libface: 0.2
Comment 2 Alex Tutubalin 2011-08-06 06:32:22 UTC
The difference is because dark value has been (shoul be :) subtracted at the earlier stages.

Also, white balance settings should not affect the black/max values.

Anyway, if you see real problems with your images (the 15-unit difference should affect shadows and dark tones), please provide your  RW2 sample for download (use Mediafire or Dropbox or other file sharing service if needed).
Comment 3 S. Burmeister 2011-08-06 07:31:41 UTC
I can send you the RW2 I used for the screenshot by email.

The PPM on the left was done as mentioned above, i.e. only dcraw -w, not sure if it does anything else by default digikam does not.

The PGF on the right was created via digikam, no post-processing, no highlight rebuilding (set to solid white), just demosaicing and exporting as lossless PGF. Applying rebuilding for highlights makes it even darker.

As you can see the pictures do differ quite a bit.
Comment 4 Alex Tutubalin 2011-08-06 07:34:13 UTC
My email is lexa@lexa.ru

Generally, dcraw -w and dcraw_emu -c 0 -w should provide the same results bitwise. 
The -c 0 is to turn off auto-maximum feature missing in dcraw.
Comment 5 S. Burmeister 2011-08-06 07:39:05 UTC
Created attachment 62603 [details]
comparison digikam with libraw against dcraw
Comment 6 S. Burmeister 2011-08-06 07:42:05 UTC
Created attachment 62604 [details]
comparison dcraw against darktable

On the left dcraw with only -w and on the right darktable with white balance set to camera, no colour management or base curve applied.
Comment 7 S. Burmeister 2011-08-06 08:00:41 UTC
Created attachment 62607 [details]
comparison dcraw against libdcraw_emu

On the left dcraw -w -v on the right dcraw_emu -w -c 0 -v
Comment 8 Alex Tutubalin 2011-08-09 11:42:13 UTC
With (latest) stable LibRaw 0.13.7, the dcraw -w and dcraw_emu -c 0 -w produces bitwise same result from sample image you sent to me.

Checked with md5sum against .ppm files produced.
Comment 9 S. Burmeister 2012-07-23 20:38:20 UTC
I'm at this issue again with today's git checkout.

digiKam version 2.8.0
Exiv2 can write to Jp2: Yes
Exiv2 can write to Jpeg: Yes
Exiv2 can write to Pgf: Yes
Exiv2 can write to Png: Yes
Exiv2 can write to Tiff: Yes
Exiv2 supports XMP metadata: Yes
LibCImg: 130
LibClapack: internal library
LibExiv2: 0.22
LibJPEG: 62
LibJasper: 1.900.1
LibKDE: 4.8.4 (4.8.4) "release 513"
LibKExiv2: 2.1.1
LibKGeoMap: 2.0.0
LibKdcraw: 2.0.1
LibLCMS: 119
LibLensFun: 0.2.6-0 - internal library
LibLqr: internal library
LibPGF: 6.12.27 - internal library
LibPNG: 1.2.49
LibQt: 4.8.2
LibRaw: 0.14.4
LibTIFF: LIBTIFF, Version 3.9.5 Copyright (c) 1988-1996 Sam Leffler Copyright (c) 1991-1996 Silicon Graphics, Inc.
Marble Widget: 0.13.3 (stable release)
Parallelized PGF codec: No
Parallelized demosaicing: Yes
Database backend: QSQLITE
LibGphoto2: 2.4.11
LibKface: 2.0.0
LibKipi: 1.4.0
LibOpenCV: 2.3.1
Libface: 0.2

digikam uses:
Scaling with darkness 0, saturation 4095, and
multipliers 1,897338 1,000000 1,726236 1,000000

dcraw uses:
Scaling with darkness 15, saturation 4095, and
multipliers 1.897338 1.000000 1.726236 1.000000

As you can see in the earlier posts digikam used to subtract the darkness from the saturation, i.e. 4095 in dcraw became 4080 and the darkness was set to 0.

However, now it still sets the darkness to 0 but does not subtract it from the saturation.

Further:
Digikam (the RAW tool within the editor) is set to use amaze to decode yet digikam's output shows:
AHD interpolation...
Comment 10 S. Burmeister 2012-07-23 20:54:00 UTC
Created attachment 72711 [details]
Comparison: jpg, digikam, dcraw -w

The picture shows a comparison of the same picture:

from left to right:
1. JPG
2. RAW from digikam, WB set to camera, no post-processing
3. RAW from dcraw -w (use camera's WB)

2 and 3 should look the same – yet they do not.
Comment 11 S. Burmeister 2012-07-24 08:16:01 UTC
I compiled the current git libkdcraw to use dcraw_emu and it shows:
Scaling with darkness 0, saturation 4080, and
multipliers 1.897338 1.000000 1.726236 1.000000
Comment 12 S. Burmeister 2012-07-24 08:34:23 UTC
Created attachment 72718 [details]
comparison: dcraw, digikam, dcraw_emu

a comparison of the same image:

from left to right:

1. dcraw -w
2. digikam with "use camera's WB"
3. dcraw_emu -w -c 0

As you can see 1 and 2 look the same while digikam fails to use the correct settings.
Comment 13 S. Burmeister 2012-07-24 08:44:36 UTC
Installed libkdcraw from current git, i.e. the one that I used for the dcraw_emu test (which works as expected), but digikam does still use darkness 0 and saturation 4095.
Comment 14 Marcel Wiesweg 2012-09-22 12:23:44 UTC
I get it that for correct camera white balance, with dcraw_emu, "-w" is not enough, but "-c 0" is also required.
Alex: In the libraw_output_params_t struct, we set use_camera_wb which is equivalent to the "-w" option. What is to be set to achieve "-c 0"?
Comment 15 Alex Tutubalin 2012-09-22 12:35:02 UTC
-c in dcraw_emu sets params.adjust_maximum_thr value.
0 - disables automated maximum adjustment.
Comment 16 Alex Tutubalin 2012-09-22 12:37:15 UTC
From Libraw docs:

float adjust_maximum_thr;

This parameters controls auto-adjusting of maximum value based on channel_maximum[] data, calculated from real frame data. If calculated maximum is greater than adjust_maximum_thr*maximum, than maximum is set to calculated_maximum.

Default: 0.75. If you set this value above 0.99999, than default value will be used. If you set this value below 0.00001, than no maximum adjustment will be performed.

Adjusting maximum should not damage any picture (esp. if you use default value) and is very useful for correcting channel overflow problems (magenta clouds on landscape shots, green-blue highlights for indoor shots).
Comment 17 Marcel Wiesweg 2012-09-23 13:23:18 UTC
Sven: In the UI, the relevant option is called "Correct false colors in highlights". Please check that unchecking this option, and using camera wb gives the desired results.

For me, these two options seem to be independent and their relation in this bug report is coincidental, so assuming you get the bit-identical results, we can close.
Comment 18 Alex Tutubalin 2012-09-23 13:28:15 UTC
BTW, auto-maximum does not affects 'darknes'. This option auto-corrects 'maximum' only.
Comment 19 S. Burmeister 2012-09-23 20:29:28 UTC
Created attachment 74120 [details]
dcraw settings
Comment 20 S. Burmeister 2012-09-23 20:34:51 UTC
Created attachment 74121 [details]
raw settings 2
Comment 21 S. Burmeister 2012-09-23 20:45:06 UTC
According to comment 4 using "-w" for dcraw and "-w -c 0" should give the same values. This is not the case with Correct false colors in highlights disabled. (see screenshots)

According to comment 2 if a darkness of 15 is set to 0 the value has to be subtracted form the saturation. Digikam does not do so.

Hence to close this report digikam/"libs it uses" has to decide whether it wants to use a darkness of 0 if it is actually 15 or not. If it wants to use 0 it should subtract 15 from the saturation, as it did previously.
Comment 22 S. Burmeister 2012-09-23 20:46:45 UTC
The first sentence of my previous comment refers to digikam vs. dcraw. not dcraw emu.
Comment 23 S. Burmeister 2012-09-24 08:39:45 UTC
I think I understood now what you meant. This report is about white balance and using wrong darkness and saturation values has nothing to do with white balance but needs a new report.

The report that deals with subtracting darkness from saturation is bug 307313.
Comment 24 caulier.gilles 2013-12-05 23:20:06 UTC
Sven,

This file still valid ?

Gilles Caulier
Comment 25 caulier.gilles 2014-08-29 07:20:11 UTC
Sven,

We need a fresh feedback here, using last digiKam 4.2.0, and Libraw 0.16.

Gilles Caulier
Comment 26 caulier.gilles 2015-06-28 09:41:29 UTC
New digiKam 4.11.0 is available :

https://www.digikam.org/node/740

Can you reproduce the problem with this release ?

Gilles Caulier
Comment 27 caulier.gilles 2015-08-21 07:06:36 UTC
digiKam 4.12.0 is out :

https://www.digikam.org/node/741

We need a fresh feedback using this release please...
Thanks in advance.
Comment 28 caulier.gilles 2016-07-15 18:55:41 UTC
With digiKam 5.0.0, this problem is not reproducible.
I close this file now. Don't hesitate to re-open if necessary.
Gilles Caulier