Beep6581 / RawTherapee

A powerful cross-platform raw photo processing program
https://rawtherapee.com
GNU General Public License v3.0
2.94k stars 328 forks source link

White balance adjustements #1878

Closed Beep6581 closed 9 years ago

Beep6581 commented 9 years ago

Originally reported on Google Code with ID 1894

Here is a new patch for the "white balance"

He tries to solve the problems reported in "Improved WB" and "LMS Colgate"  (forum
RT)

First, thank you to Alias for having tested the matrix DNG for Panasonic DH2.

I made the following changes:
1) change in the code "dcraw.cc" values "rgb_cam" by those of Dcraw.

2) changes in the amplitude of the color temperature (1500-60000) instead of (2000-25000)
* Attention low values may cause artifacts / difficulties in some images, because this
value is outside the usual limits of manufacturers (Nik, Can, ..). I kept the algorithm
that calculates according to the Planck formula
* for high values (greater than 25000) I changed the algorithm.

3)I slightly modified the code for "spotWB" to make it more robust

4)Upon reflection, I put in "preferences", option that lets you change the normal balance
between red and blue set by "White Balance"
This can be useful when shooting conditions:
a) are far from the standard illuminant (underwater. ..)
b) are far from conditions where calibrations were performed
c) where the matrices or ICC profiles are unsuitable

Be carefull !!

Reported by jdesmis on 2013-05-31 12:19:20


Beep6581 commented 9 years ago
Jacques, thanks.

So you surpassed the 1666.7 low limit ?. Is it safe ?.

I think I have to ask here .. Is it supposed that the matrices in Dcraw.cc refer to
D65 lighting ?. So if we have a matrix built for D50 what should we do ?  Bradford
adaptation to D65 ?.

We had a related issue at http://code.google.com/p/rawtherapee/issues/detail?id=1783
where the matrix is now a copy of the custom dcp profile (D50)and the measures you
can find at post #11 indicate that the standard Dcraw (Adobe) matrix measures better...

Reported by iliasgiarimis on 2013-05-31 14:24:37

Beep6581 commented 9 years ago
I think that there are no problems (except that in some cases exceed the limits of the
camera manufacturers).

Below 4000K I use Planck's formula is valid above some K  (below 1000K probably no
usage in photography ?)

 //calculate spectral data for blackbody at temp!
double ColorTemp::blackbody_spect(double wavelength, double m1, double m2, double temp)
{
    double wlm = wavelength * 1e-9;   /* Wavelength in meters */
    return (3.7417715247e-16 * pow(wlm, -5.0)) /              //3.7417..= c1 = 2*Pi*h*c2
 where h=Planck constant, c=velocity of light
           (exp(1.438786e-2 / (wlm * temp)) - 1.0); //1.4387..= c2 = h*c/k  where k=Boltzmann
constant
}

For the "formula" and "adaptation" all is done from the "spectral data" (it is more
complex and a little slower)

The issue taken up by 1666.7 B.Lindbloom is not used in this case (I use also but not
for this purpose)

But it must be said, colorimetry and especially "white balance" are complex things

:)

Reported by jdesmis on 2013-05-31 15:22:33

Beep6581 commented 9 years ago
Will it have effect on color tints? (blue-yellow, red-cyan)

That was that my "issue".

Reported by Mescalamba on 2013-05-31 16:06:26

Beep6581 commented 9 years ago
Yes of course.

Normally, I think it should not change the settings chosen by the white balance, but
in some cases, those that I mentioned below, it is possible that these settings are
slightly inadequate.

Shooting conditions:
a) are far from the standard illuminant (underwater. ..)
b) are far from conditions where calibrations were performed
c) where the matrices or ICC profiles are unsuitable

You can then act on the "green-magenta" color .. as before and (new) the balance between
red and blue, acting in "preference" option. I did not put it in those settings available
for each photo, but "disengaged" option because it is likely to specific cases and
also reduct complexity for "normal" use.

Reported by jdesmis on 2013-05-31 16:25:42

Beep6581 commented 9 years ago
I have change the amount of correction "red-blue" and now issue 1839 seems solved

Reported by jdesmis on 2013-05-31 17:31:41


Beep6581 commented 9 years ago
Thanks Jacques, I've tried your patch a little bit and it's great! I have a few tricky
photographs that now look a lot better - I also tried the raw file from the forum from
user "karl", and it looks about right to me. :-)

However, I think the thumbnails aren't updated correctly when using temperatures to
the extreme, see this screenshot for instance: 
http://johanthor.smugmug.com/Other/RawTherapee/29731206_sXZMDM#!i=2546354352&k=TNxcCvZ&lb=1&s=A

Anyway, great progress!

Regards,
Johan

Reported by johan@birkagatan.com on 2013-05-31 18:29:25

Beep6581 commented 9 years ago
Hi Jacques, would it be more intuitive/useful if this is placed either in WB section
or near the channel mixer in the Color tab?

Reported by michaelezra000 on 2013-05-31 18:35:24

Beep6581 commented 9 years ago
I would like the opinion of other users.
Indeed in "preferences" is not very intuitive, and all the pictures are changed, but
it does not add complexity.
I think it would be better in the "white balance" section but normally disabled.

Reported by jdesmis on 2013-06-01 04:43:16

Beep6581 commented 9 years ago
Would a checkbox "Permit extreme WB settings" do the job ??. Sounds fine to me.

What do you think about a "Underwater" preset ??. Do we need spectral data for this?

Reported by iliasgiarimis on 2013-06-01 07:39:26

Beep6581 commented 9 years ago
Hi Jacques, one more comment - change to dcraw.cc should have a corresponding change
in the dcraw.patch, this will allow to reintroduce it after the next dcraw update.

Reported by michaelezra000 on 2013-06-01 21:09:41

Beep6581 commented 9 years ago
I'm working on the GUI and procedures "colortemp", which for me are a little "Chinese".

I introduced an additional slider "Equalizer red blue" which is normally disabled.
You can activate it by going to "Preferences" ... which should limit the use of the
slider to the people who really need it.

I deleted the amendment of the "3x3 matrix Dcraw.cc" and the results are better with
the usual matrix and opportunities to act on the new settings.
For image "P1010537.RW2" the following settings seem appropriate to me (of course I
do not know the original image)
T = 45000K
tint = 0.26
eq = 1.23

We must put some "Underwater preset", but again the GUI is a little Chinese for me.

But it is almost impossible to define standard spectral data, because the "underwater"
distribution is a function of many parameters (depth, water clarity, sunlight, etc.)

I book the patch as it is, it only works in "manual" mode ... and the thumbnails do
not seem "perfect", but we can see the features and quality of the algorithms (which
are empirical )

Reported by jdesmis on 2013-06-02 08:15:28


Beep6581 commented 9 years ago
Little change...it's better !

Reported by jdesmis on 2013-06-02 08:20:40


Beep6581 commented 9 years ago
The same with 2 "underwater preset"...which are mean setting

I did not find "png" with a dip ... I put the default "shade"

:)

Reported by jdesmis on 2013-06-02 09:54:07


Beep6581 commented 9 years ago
the same with the icons of a diver  :)

Reported by jdesmis on 2013-06-02 16:28:46


Beep6581 commented 9 years ago
You must add manually these files in images/light/actions/

For "light" environnement

Reported by jdesmis on 2013-06-02 16:33:21


Beep6581 commented 9 years ago
And for dark environnement  in images/dark/actions

Reported by jdesmis on 2013-06-02 16:34:28


Beep6581 commented 9 years ago
I corrected the icons to match the existing ones in brightness and transparency

Reported by michaelezra000 on 2013-06-02 17:19:08


Beep6581 commented 9 years ago
Michael thank's 

Some (little) modifications (labels, history...)

Reported by jdesmis on 2013-06-03 06:57:17


Beep6581 commented 9 years ago
By working on the patch you privately sent me, which has Preference parameters that
should go in the WB tool too, i'm planning to make a modification to handle those kind
of specilized parameter. For now, it won't be hidden, but I'll open a new issue for
that (or find one already opened).

Do you mind that i propose an icon too?

Reported by natureh.510 on 2013-06-03 12:23:43

Beep6581 commented 9 years ago
After discussion (in French) with Hombre, I moved the option was in "Preferences" to
put it in "White balance"

I created a subcategory "water" that should allow you to add if necessary other "presets"

No changes to algorithms  :)

Reported by jdesmis on 2013-06-04 07:07:59


Beep6581 commented 9 years ago
If no other comments I'll commit tomorrow :)

Reported by jdesmis on 2013-06-05 04:29:20

Beep6581 commented 9 years ago
Hi Jacques, I will post a few suggestions for the language file this evening.

Reported by michaelezra000 on 2013-06-05 11:18:09

Beep6581 commented 9 years ago
No problem..thank's :)

Reported by jdesmis on 2013-06-05 11:19:40

Beep6581 commented 9 years ago
Hi Jacques, sorry I did not get a chance to test this thoroughly before,
Language entries are OK, except may be it would be better to say "Equalizer for red
& blue".
TP_WBALANCE_EQREDBLUE;Equalizer for red & blue
TP_WBALANCE_EQREDBLUE_ENABLED;Enable Equalizer

I see a couple of functional issues:
1. When equalizer is disabled, the slider setting still has an effect
2. When Custom WB is selected from drop down, the equalizer value is not recalled (temperature
and tint is recalled)

Reported by michaelezra000 on 2013-06-06 04:19:08

Beep6581 commented 9 years ago
Here is a patch that takes into account the remarks made by Michael. Much of the changes
was made by Hombre on the interface (thank you to him) :)

I would not be here this weekend.

Reported by jdesmis on 2013-06-06 15:35:40


Beep6581 commented 9 years ago
Thanks Hombre &  Jacques!

1. I still see the issue that when Custom WB is selected from drop down, the equalizer
value is not recalled (temperature and tint is recalled). Steps to reproduce:
Set Equalzer to 1.2, then select Camera WB (Eq is set to 1.0), then select Custom WB
- Eq is still at 1.0, but it should reset to 1.2

2. In preferences 'All to Add' and 'All to Set' stopped working.
Then I clicked the column heading "Set" and it started working. 
2a. However, Equalizer red blue does not appear under WB. section
2b. 'Equalizer red blue' works only in Set mode

3. Suggestion for the tooltip:
TP_WBALANCE_EQREDBLUE_TOOLTIP;Allows to deviate from the normal behavior of "white
balance", via increase or decrease of the ratio between red and blue.\nThis can be
useful when shooting conditions:\na) are far from the standard illuminant (e.g. underwater)\nb)
are far from conditions where calibrations were performed\nc) where the matrices or
ICC profiles are unsuitable

4. These language entries are not being used:
PREFERENCES_EQREDBLUE;White balance adjustements channels red and blue
PREFERENCES_EQCHAN_SET;Settings delta Red and Blue channels (+ or -)

5. There are a few remaining printf statements which I am sure you were planing to
comment:)

Reported by michaelezra000 on 2013-06-07 01:44:30

Beep6581 commented 9 years ago
one more - please see comment 10

Reported by michaelezra000 on 2013-06-07 01:46:01

Beep6581 commented 9 years ago
Michael

Just before I go for the weekend.
I corrected 2) 3) 4)

1) it's very difficult for me...and I do not have time to do it now.

For comment # 10, there is no change in Dcraw.cc, nor in Dcraw.c I do not change the
matrix of Panasonic, it remains as it is.

Reported by jdesmis on 2013-06-07 05:24:07


Beep6581 commented 9 years ago
A last change...

I'm not sure it works all the time, but .. it was bad "copy paste"

We will meet again Monday  :)

Reported by jdesmis on 2013-06-07 07:00:28


Beep6581 commented 9 years ago
A little change

Reported by jdesmis on 2013-06-07 07:06:18


Beep6581 commented 9 years ago
Jacques, thanks, all issues are solved, including #1:)

about dcraw, I suppose we can take this out:
diff -r d9f5a97d961a rtengine/dcraw.cc
--- a/rtengine/dcraw.cc Mon Jun 03 16:32:08 2013 +0200
+++ b/rtengine/dcraw.cc Fri Jun 07 09:03:23 2013 +0200
@@ -6516,6 +6516,7 @@
    { 6360,-1557,-375,-4201,11504,3086,-1378,2518,5843 } },
    { "Panasonic DMC-GH2", 15, 0xf95, /* RT - Colin Walker */
    { 6855,-1765,-456,-4223,11600,2996,-1450,2602,5761 } },
+// { 7780,-2410,-806,-3913,11724,2484,-1018,2390,5298 } }, 
     { "Panasonic DMC-GH3", 144, 0,
    { 6559,-1752,-491,-3672,11407,2586,-962,1875,5130 } },
     { "Panasonic DMC-GX1", 143, 0,

I am ok for commit:)

Reported by michaelezra000 on 2013-06-07 16:21:43

Beep6581 commented 9 years ago
There is one small drawback I see from extending the WB temperature range, is that it
is more difficult to vary the temperature in the more frequently used range.

So may be if Hombre has some time in the future, Adjuster could be slowed down by pressing
the Ctrl key?

Reported by michaelezra000 on 2013-06-07 17:25:07

Beep6581 commented 9 years ago
Hi Jacques, would you like to commit?

Reported by michaelezra000 on 2013-06-21 02:23:11

Beep6581 commented 9 years ago
I'm in the final stage of GUI handling. I'll post a new patch here before next Monday.

Reported by natureh.510 on 2013-07-04 13:20:59

Beep6581 commented 9 years ago
The White Balance panel is more complicated to handle than expected. I need few more
time, sorry.

Reported by natureh.510 on 2013-07-07 19:37:41

Beep6581 commented 9 years ago
Hi Hombre, no problem whatsoever:)
I am curious, what are the changes that you are working on?

Reported by michaelezra000 on 2013-07-07 19:42:51

Beep6581 commented 9 years ago
I'm trying to make the Temp and Green values updates when moving the R/B Equalizer sliders,
while being in AutoWB mode. The problem I'm facing is initializing the values of the
White Balance panel when opening the image in a new Editor panel.

FYI, i'll be in Marocco for the next week (professional), so i'll have a limited access
to the web.

Reported by natureh.510 on 2013-07-07 23:17:32

Beep6581 commented 9 years ago
Here is the latest patch, which i think is committable. The only thing that annoys me
a little bite is the "Red/Blue" labels which seems to indicate that the moving the
slider to the left will make the image more red, and more blue when moved to the right,
while it's the contrary. Should we use "Blue/Red" labels?

Reported by natureh.510 on 2013-07-16 01:36:23


Beep6581 commented 9 years ago
Hi Hombre, thanks for the update!
As it is compiling, I am reading through code - any reason why this was removed from
options.cc, line 682?

if (keyFile.has_key ("Color Management", "Ciencamfloat")) rtSettings.ciecamfloat =
keyFile.get_boolean ("Color Management", "Ciecamfloat");

Reported by michaelezra000 on 2013-07-16 01:52:23

Beep6581 commented 9 years ago
I see this issue:
Open image with WB Method=Camera
Remember what was the Temperature value T1.
Change Red/blue from 1.000 to e.g. 1.200
 WB Method changes to Custom
Set WB Method=Camera
 Temperature = T1
 Red/Blue = 1.000 (OK)
Set WB Method=Custom
 Red/Blue = 1.200 (OK)
  Temperature = T2 !==T1 - NOT OK - when going back to Custom Temperature value changes.

Reported by michaelezra000 on 2013-07-16 02:02:57

Beep6581 commented 9 years ago
One more issue: 
with Auto WB thumbnail & preview have different color, unless cache is cleared for
this particular image.

Reported by michaelezra000 on 2013-07-16 02:21:33

Beep6581 commented 9 years ago
Re #39: This line was erroneous and useless; "ciecamfloat" is stored later in the list.

Re #40: fixed

Re #41: What do you mean by different color? I have a difference in exposure between
the thumbnail and the preview, but not in colors. I had to add more parameters to the
"cache\data" files, so the user will have to delete his cache first. Is it a problem?

Thanks for this review Michael :)

Reported by natureh.510 on 2013-07-17 23:47:08


Beep6581 commented 9 years ago
Hombre, great, all works well now.
about #41 - Its OK to request users to clean the cache, but we need to include in the
release notes.

There is an existing bug, before this patch that also lead me to this issue.
Here is illustration using the "blue horse" image:
http://imgur.com/9cDbpuu
We can treat this in a separate issue.

About the Red/Blue vs Blue/Red - I don't mind Blue/Red:)
<May be it is worth extending the adjuster by adding a thin color bar with gradient
at some point, also not in this issue. All WB adjusters would benefit from this feature.

Reported by michaelezra000 on 2013-07-18 02:13:59

Beep6581 commented 9 years ago
For the WB, i could have a quick look before committing, could you open the new issue
and explain how to reproduce?

For the colored adjuster, yeah, considering the - very - low active developers, i think
that "fanciness" can wait, even if i would be pleased to see it comming too. :)

Something that isn't clear for me is the modified dcraw file in this patch. Jacques,
is this really related to this issue?

I'll change the labels then, and will commit on saturday if nobody complains, if you're
okay Jacques.

Reported by natureh.510 on 2013-07-18 17:31:18

Beep6581 commented 9 years ago
Hi Hombre, I am away from workstation, but for the reproducing the issue, simply repeat
the WB settings as on the screenshot:
http://imgur.com/9cDbpuu

Reported by michaelezra000 on 2013-07-18 19:43:52

Beep6581 commented 9 years ago
for me it's OK

I've been away for several days without internet connections...
And now I am on holidays with my family  :)

Reported by jdesmis on 2013-07-21 06:46:12

Beep6581 commented 9 years ago
Jacques, have a great time:)

I am unclear on the changes to dcraw.cc and dcraw.patch that were committed with this
patch. changes to these two files don't seem consistent and as a result will not carry
over correctly when next dcraw version will be adapted.

Are these changes necessary? Can we undo them or redo consistently so dcraw.cc and
dcraw.patch are in synch?

Reported by michaelezra000 on 2013-07-21 11:42:21

Beep6581 commented 9 years ago
Hello Michael

I'm not sure I understand what you mean!

The change I made (dcraw) is simply to remove the amendment made by C.Walker on the
Panasonic DMC-GH2. It comes back to the original profile Dcraw. Maybe changing the
duo Dcraw / dcraw.patch is not good! but I do not see why!

Of course each profile is only effective for a given illuminant, and in this case,
the results "default" with the original profile Dcraw when shooting "underwater" is
much better than the requirements of the profile developed by C.Walker.

This raises once again the relevance of the profiles (ICC DCP) which can not satisfy
all situations: the cursor "blue red equalize" partially overcome these shortcomings.

It would be nice if users give their opinions.

:)

Reported by jdesmis on 2013-07-21 12:53:14

Beep6581 commented 9 years ago
Please summarize changes before marking as fixed.

Reported by entertheyoni on 2013-12-05 00:39:44

Beep6581 commented 9 years ago
Hello, can we close this, or is there anything that needs to be documented?

Reported by entertheyoni on 2014-11-06 12:26:10