How to extract white balance multipliers? - RAW Shooting and Processing - CHDK Forum supplierdeeply

How to extract white balance multipliers?

  • 13 Replies
  • 15052 Views
How to extract white balance multipliers?
« on: 17 / May / 2010, 09:44:49 »
Advertisements
I have a PowerShot A590 IS and I want to extract it's tunsten white balance multipliers. I set the white balance to Tungsten on the camera, and took a few sample shots. The problem is I'm not getting consistent multipliers.

dcraw -v -i shows different multipliers for each image.
Camera multipliers: 1.586000 0.972000 1.586000 0.000000
Camera multipliers: 1.023000 0.805000 2.483000 0.000000
Camera multipliers: 1.006000 0.927000 2.258000 0.000000

and when I develop the same images with dcraw -v -w I get different multipliers than from the output of dcraw -v -i.
multipliers 1.631687 1.000000 1.631687 1.000000
multipliers 1.270807 1.000000 3.084472 1.000000
multipliers 1.085221 1.000000 2.435814 1.000000

and these are different still from the output of dng_validate.exe (run in WINE)
AsShotNeutral: 0.6305 1.0288 0.6305
AsShotNeutral: 0.9775 1.2422 0.4027
AsShotNeutral: 0.9940 1.0787 0.4429

What is going on? I thought white balance multipliers were supposed to be constant if you picked a fixed lighting type.

I've tried also tried getting the color balance information from the jpg's EXIF data but that didn't work either.
http://chdk.setepontos.com/index.php/topic,156.msg27340.html#msg27340


*

Offline whoever

  • ****
  • 280
  • IXUS950
Re: How to extract white balance multipliers?
« Reply #1 on: 17 / May / 2010, 10:31:01 »
dcraw -v -i shows
Camera multipliers: 1.586000 0.972000 1.586000 0.000000
and when I develop the same images with dcraw -v -w I get different multipliers than from the output of dcraw -v -i.
multipliers 1.631687 1.000000 1.631687 1.000000
They're the same, only differently scaled: {1.586000 0.972000 1.586000}/0.972000 = {1.631687 1.000000 1.631687}.
Quote
What is going on? I thought white balance multipliers were supposed to be constant if you picked a fixed lighting type.
Not quite. The camera "fine-tunes" WB, except when set to manual (i.e., when you have to first shoot a grey target).
Quote
I've tried also tried getting the color balance information from the jpg's EXIF data but that didn't work either.
The information is there and identical to AsShotNeutral. You must've looked in a wrong place.
« Last Edit: 17 / May / 2010, 10:34:57 by whoever »

Re: How to extract white balance multipliers?
« Reply #2 on: 17 / May / 2010, 12:10:56 »
They're the same, only differently scaled: {1.586000 0.972000 1.586000}/0.972000 = {1.631687 1.000000 1.631687}.
Oh, thanks! I see that the output of dng_validate is the reciprocal of the output of dcraw -v -i. That's strange.
1/{1.586000 0.972000 1.586000} = {0.6305 1.0288 0.6305}

Quote
Not quite. The camera "fine-tunes" WB, except when set to manual (i.e., when you have to first shoot a grey target).
OK. I tried out a custom white balance and the multiplier didn't change.

Quote
The information is there and identical to AsShotNeutral. You must've looked in a wrong place.
I tried two different ways to find it.
First I tried extracting the EXIF data using ShowEXIF, Tools->Save Exif Data to Current Directory
Then use ./dng_validate.exe -v -d 1024 Hg_ref.THM but I get the error:
Validating "Hg_ref.THM"...
*** Error: Unknown byte order ***
*** Error: File format is invalid ***

Secondly, I applied fudgey's patch for exiftool. But exiftool still doesn't show the data. I used grep so it's not a matter of looking in the wrong place; although I did eyeball the output too.

I have an A75 that is jpg only that I want to get white balance multipliers from, so if you could recommend another way I'd appreciate it.


*

Offline whoever

  • ****
  • 280
  • IXUS950
Re: How to extract white balance multipliers?
« Reply #3 on: 18 / May / 2010, 01:58:03 »
But exiftool still doesn't show the data. I used grep so it's not a matter of looking in the wrong place; although I did eyeball the output too.

exiftool -U -v your.jpg > parsed.txt

Open parsed.txt and scroll down to

   | | | 9)  CanonCameraInfoPowerShot (SubDirectory) -->
   | | | + [BinaryData directory, 592 bytes]
   | | | | ISO = 370
   | | | | Canon_CameraInfoPowerShot_0x0001 = 411
   | | | | Canon_CameraInfoPowerShot_0x0002 = -41
   ....

That's the data that MakerNote's tag 13 points to; Phil calls it CameraInfoPowerShot. It is a large array of 32-bit integers, the numbers in Canon_CameraInfoPowerShot_XXXX are indices into this array. Inspect entries 91-94 (hex 0x5B-0x5E). In my jpegs, e.g.:
   Canon_CameraInfoPowerShot_0x005b = 921
   Canon_CameraInfoPowerShot_0x005c = 1469
   Canon_CameraInfoPowerShot_0x005d = 1864
   Canon_CameraInfoPowerShot_0x005e = 921

Those are Canon WB multipliers for G, R, B, G.

Of course, it is possible that Canon has changed this info or its location. Looks unlikely to me, though. In fact, quite surprising that nobody appears to have investigated it.

Edit: The data appear to have moved a bit in recent cams. In S90, they appear to be at 80-83.
« Last Edit: 18 / May / 2010, 04:09:07 by whoever »


*

Offline vit40

  • ****
  • 276
Re: How to extract white balance multipliers?
« Reply #4 on: 18 / May / 2010, 05:46:22 »
Several month ago, I made a small utility (search my posts) to copy WB info from jpeg to a dng, that was converted from crw. Tried on three cameras and all of them had WB info on different location inside maker's note tag

Canon PowerShot A620      = 48
Canon PowerShot SX110 IS  = 80
Canon PowerShot A650 IS   = 91
 

Re: How to extract white balance multipliers?
« Reply #5 on: 18 / May / 2010, 06:19:53 »
My Canon.pm has CameraInfoPowerShot defined
Code: [Select]
        {
            Name => 'CanonCameraInfoPowerShot',
            # valid if format is int32u[138] or int32u[148]
            Condition => '$format eq "int32u" and ($count == 138 or $count == 148)',
            SubDirectory => {
                TagTable => 'Image::ExifTool::Canon::CameraInfoPowerShot',
            },
        },

But exiftool won't output CameraInfoPowerShot. However by taking the the output of dng_validate.exe and dividing it into 1000 like the patch shows: AsShotNeutral: 1.5361 1.1682 0.3630  ---> round(1000./[1.5361 1.1681 0.3630]) = 651 856 2755
I was able to find the multipliers at

  | | | | Canon_CameraInfoUnknown32_0x005e = 856
  | | | | Canon_CameraInfoUnknown32_0x005f = 651
  | | | | Canon_CameraInfoUnknown32_0x0060 = 2755
  | | | | Canon_CameraInfoUnknown32_0x0061 = 856

Unfortunately the output for my A75 has CanonCameraInfoUnknown16 and I can't find any grouping of numbers that look like white balance multipliers. Do you believe the white balance would be saved in the EXIF data for such an old camera?

*

Offline whoever

  • ****
  • 280
  • IXUS950
Re: How to extract white balance multipliers?
« Reply #6 on: 18 / May / 2010, 07:10:32 »
Well, as far as I can see, the WB info has been there at least since A610/A620 (that is at least for the last 5 years), and that its position in exif is really floating. Perhaps A75 is just too old? You are in a good position to investigate...

Re: How to extract white balance multipliers?
« Reply #7 on: 29 / January / 2016, 09:38:14 »
http://pastebin.com/c6H0wMEH

I though I found the RGB multipliers in this section:
Code: [Select]
  | | | | Canon_CameraInfoPowerShot_0x005b = 917
  | | | | Canon_CameraInfoPowerShot_0x005c = 1127
  | | | | Canon_CameraInfoPowerShot_0x005d = 2787
  | | | | Canon_CameraInfoPowerShot_0x005e = 917

But changing the AsShotNeutral field accordingly seems to produce the wrong result. Am I missing something?


Re: How to extract white balance multipliers?
« Reply #8 on: 31 / January / 2016, 02:31:09 »
I think the missing piece now is scaling the raw RGB values correctly, in this example 1037 805 2478.
I Tried :
exiftool -AsShotNeutral="1037 805 2478" "20080118 - IMG_0942.DNG"

&

exiftool -AsShotNeutral="0.41848 0.324858 1" "20080118 - IMG_0942.DNG"
(raw values divided by 2478)

Both produced extremely colors shifted color so I'm still looking for a solution.

EDIT: running
dcraw -v -r 1037 805 2478 805 "H:\!Photos\Self-taken\2005-2007\20080118 - IMG_0942.DNG"
produces a file with a WB matching the JPEG. Yay! Dcraw reports the multipliers as 1.288199 1.000000 3.078261. I try input this to the DNG AsShotNeutral field but this does not give me a match to JPEG WB.
« Last Edit: 31 / January / 2016, 04:33:14 by markanini »

Re: How to extract white balance multipliers?
« Reply #9 on: 31 / January / 2016, 04:37:38 »
I figured it out! The AsShotNeutral values are simply inverted related to G. For example take the raw 1037 805 2478 RGB values, scale them so that G is 1, in this case by diving by 805. This give us 1.288199 1.000000 3.078261. Now for R 1/1.288199 and for G 1/3.078261. The final command is:
exiftool -AsShotNeutral="0.776277 1 0.324858" "20080118 - IMG_0942.DNG"
Perfect match with JPEG!
« Last Edit: 31 / January / 2016, 05:22:10 by markanini »

 

Related Topics