Author Topic: [rec_raw] Whitebalance AsShotNeutral in Raw-Header?  (Read 13218 times)

chmee

  • Contributor
  • Hero Member
  • *****
  • Posts: 1031
  • raw2cdng
[rec_raw] Whitebalance AsShotNeutral in Raw-Header?
« on: June 26, 2013, 08:29:47 PM »
the question is mainly in the subject. Are we able to read out the colortemperature or the XY-formed Data? I've seen there is some "reserved" room for some more data..

regards chmee

a1ex

  • Administrator
  • Hero Member
  • *****
  • Posts: 12461
Re: [rec_raw] Whitebalance AsShotNeutral in Raw-Header?
« Reply #1 on: June 26, 2013, 10:04:22 PM »
It can be read, but there are a bunch of formats, and I don't know how to convert between them.

CHDK DNG code uses RGB multipliers. I don't know how to get them for white balances other than custom.

chmee

  • Contributor
  • Hero Member
  • *****
  • Posts: 1031
  • raw2cdng
Re: [rec_raw] Whitebalance AsShotNeutral in Raw-Header?
« Reply #2 on: June 27, 2013, 07:53:46 AM »
AsShotNeutral in DNG-Tag-Header is a 3-rational-value-entry - f.e. 0.4145 1 0.6259 (Colortemp ~5500). Playing with 10bit log i see, i cant remove false colors with slightly moving blacklevel, but with changing the whitebalance a.k.a AsShotNeutral-values.. by now i'm not into it as well, but to get some values measured with the first frame would be a good start to reengineer - if the body give some values instead of calculating them from the blacklevel?! if i have read that right, the blacklevel can be a 3-value entry as well, for every component..

(i have to look into the chdk-dng.code)
(btw resolve handles 10bit|log quite well and automatically adjusts ev and whitebalance)

regards chmee

marekk

  • Senior
  • ****
  • Posts: 331
  • www.oddajmisie.com
Re: [rec_raw] Whitebalance AsShotNeutral in Raw-Header?
« Reply #3 on: June 30, 2013, 01:19:36 PM »
We can get this info from CR2 exif. I think values for Daylight, Shade, Cloudy are fixed.. The question is how to get actual values of "WB RGGB Levels As Shot" and "Color Temp As Shot" directly from the body an convert them to DNG AsShotNeutral format..
 

Code: [Select]
Color Data Version              : 9 (60D/1100D)
WB RGGB Levels As Shot          : 1967 1024 1024 1796
Color Temp As Shot              : 4518
WB RGGB Levels Auto             : 1967 1024 1024 1796
Color Temp Auto                 : 4518
WB RGGB Levels Measured         : 1857 1023 1024 1825
Color Temp Measured             : 4286
WB RGGB Levels Daylight         : 2162 1024 1024 1641
Color Temp Daylight             : 5200
WB RGGB Levels Shade            : 2503 1024 1024 1391
Color Temp Shade                : 7000
WB RGGB Levels Cloudy           : 2330 1024 1024 1507
Color Temp Cloudy               : 6000
WB RGGB Levels Tungsten         : 1531 1024 1024 2497
Color Temp Tungsten             : 3200
WB RGGB Levels Fluorescent      : 1964 1024 1024 2325
Color Temp Fluorescent          : 3807
WB RGGB Levels Kelvin           : 2208 1024 1024 1603
Color Temp Kelvin               : 5380
WB RGGB Levels Flash            : 2405 1024 1024 1494
Color Temp Flash                : 6236

chmee

  • Contributor
  • Hero Member
  • *****
  • Posts: 1031
  • raw2cdng
Re: [rec_raw] Whitebalance AsShotNeutral in Raw-Header?
« Reply #4 on: June 30, 2013, 04:30:26 PM »
We have a quadrupel of values f.e. daylight:

2162 1024 1024 1641 (RGGB) i think we can merge G1 and G2 into one value. -> so changing into a tripel 2162 1024 1641. if i look into quoted values, we set one value (G) as absolute 1, we set R and B into relation to G.. should work..

(1024/2162) (1024/1024) (1024/1641) -> 0.473635 1 0.624 (5200°K)
(its not far away from the values i wrote above :) )

But i'm asking for the values AsShot measured right before the recording (or with the first frame). i think, it could be worth, saving them into the raw_rec_header..

(edit) In the chdk-source theres (line110) the generation of the array (3*rational = 6*int) and in save_dng fields [2] and [4] are statically changed (line567/568)
Code: [Select]
static int cam_AsShotNeutral[]          = {1000,1000,1000,1000,1000,1000};
//..
cam_AsShotNeutral[2] = 2477; /* 5D3 6000K */
cam_AsShotNeutral[4] = 1462;
cam_AsShotNeutral[] = {1000,1000,2477,1000,1462,1000};
GRB? instead of RGB?

2477 1024 1462 -> (5D3@6000°K) -> 0.41340 1 0.70041
data from marekks list (60D/1100D) -> 2330 1024 1507 -> 0.43948 1 0.67949


marekk

  • Senior
  • ****
  • Posts: 331
  • www.oddajmisie.com
Re: [rec_raw] Whitebalance AsShotNeutral in Raw-Header?
« Reply #5 on: July 01, 2013, 01:53:00 PM »
I converted CR2 to DNG using Adobe DNG Converter and it looks like your calculations are good.

CR2:
Code: [Select]
WB RGGB Levels As Shot          : 2341 1024 1024 1608
Color Temp As Shot              : 5615

DNG:
Code: [Select]
As Shot Neutral                 : 0.43742 1 0.636816
-----
Code: [Select]
Color Matrix 1                  : 0.7428 -0.1897 -0.0491 -0.3505 1.0963 0.2929 -0.0337 0.1242 0.6413
Color Matrix 2                  : 0.6719 -0.0994 -0.0925 -0.4408 1.2426 0.2211 -0.0887 0.2129 0.6051

I think that values set for WB RGGB and As Shot Neutral are related to ColorMatrix.
DCRAW has info only about Color Matrix 2 for 60D and I set values for ColorMatrix in raw.c based on dcraw setting. It looks like 60D sets different ColorMatrix than dcraw....

Chdk code for dng reads actual values for WB and saves it as follows:
Code: [Select]
    get_property_case(camera_info.props.wb_adj, &wb, sizeof(wb)); 
    cam_AsShotNeutral[1]=wb[1];
    cam_AsShotNeutral[3]=wb[0];
    cam_AsShotNeutral[5]=wb[2];

If found this info on Adobe forum:
Quote
When you have the White Balance set to As Shot, the white reference is usually the "as-shot neutral" (as explained in the DNG spec, "AsShotNeutral specifies the selected white balance at time of capture, encoded as the coordinates of a perfectly neutral color in linear reference space values."). The translation from this so-called AsShotNeutral to temperature & tint values depends on the ColorMatrix tags, which in turn depends on the profile being used.
 
So when you change the profile, you potentially change the color matrix (or matrices) being used, which in turn potentially changes the translation to temp/tint values.
 
If you specify a custom temp/tint for the WB, then you are setting the white reference based on temp/tint values (i.e., effectively xy coordinates), as opposed to the AsShotNeutral.

chmee

  • Contributor
  • Hero Member
  • *****
  • Posts: 1031
  • raw2cdng
Re: [rec_raw] Whitebalance AsShotNeutral in Raw-Header?
« Reply #6 on: July 01, 2013, 05:36:58 PM »
:) nice finding. thx.

[CHDK] ah. thats why i ve been unsure about the value-order..

regards chmee

marekk

  • Senior
  • ****
  • Posts: 331
  • www.oddajmisie.com
Re: [rec_raw] Whitebalance AsShotNeutral in Raw-Header?
« Reply #7 on: July 01, 2013, 05:43:02 PM »
I think we should to set also a:
Calibration Illuminant 1        : Standard Light A
Calibration Illuminant 2        : D65

This two parameters are included for example in Iconoskop DNG files (different values).

Standard Light a is 17, D65 is 21.

chmee

  • Contributor
  • Hero Member
  • *****
  • Posts: 1031
  • raw2cdng
Re: [rec_raw] Whitebalance AsShotNeutral in Raw-Header?
« Reply #8 on: July 01, 2013, 08:17:44 PM »
i think i've set this two illuminants for the color matrices in my cdng's.. but if we have to recalculate the color matrices  :o holy boly.. i'm not ready yet, but if its only numbers, we can handle that :)

marekk

  • Senior
  • ****
  • Posts: 331
  • www.oddajmisie.com
Re: [rec_raw] Whitebalance AsShotNeutral in Raw-Header?
« Reply #9 on: July 01, 2013, 09:23:35 PM »
I think "As Shot Neutral" in chdk-dng.c is set incorrectly, GRB as you wrote.

If we would like to preserve 6000K it should be:

static int cam_AsShotNeutral[]          = {100000,100000,100000,100000,100000,100000};
cam_AsShotNeutral[0] = 41340;
cam_AsShotNeutral[4] = 70041;

I tested it with daylight settings for 60D's DNG and there is a huge difference.
Default settings:
https://www.dropbox.com/s/u5cdmfkhgp0idgr/def.jpg

Modified:
https://www.dropbox.com/s/ay3qdivya3h1ajc/wb.jpg



i think i've set this two illuminants for the color matrices in my cdng's.. but if we have to recalculate the color matrices  :o holy boly.. i'm not ready yet, but if its only numbers, we can handle that :)

chmee

  • Contributor
  • Hero Member
  • *****
  • Posts: 1031
  • raw2cdng
Re: [rec_raw] Whitebalance AsShotNeutral in Raw-Header?
« Reply #10 on: July 01, 2013, 10:19:18 PM »
brilliant. thats a huge step forward. but we have to wake up 1%, a1ex or g3gg0 for implementing the measured data :)

regards chmee

IliasG

  • Member
  • ***
  • Posts: 124
Re: [rec_raw] Whitebalance AsShotNeutral in Raw-Header?
« Reply #11 on: July 01, 2013, 11:36:12 PM »
i think i've set this two illuminants for the color matrices in my cdng's.. but if we have to recalculate the color matrices  :o holy boly.. i'm not ready yet, but if its only numbers, we can handle that :)

No need to recalculate, you can find them ready in exif data of DNG converted CR2s or in Adobe's standard dcp profiles for each model.
In fact Dcraw matrices is a copy of Adobe's D65 matrices.

IliasG

  • Member
  • ***
  • Posts: 124
Re: [rec_raw] Whitebalance AsShotNeutral in Raw-Header?
« Reply #12 on: July 01, 2013, 11:48:00 PM »
brilliant. thats a huge step forward. but we have to wake up 1%, a1ex or g3gg0 for implementing the measured data :)

regards chmee


I didn't read the DNG specs but as I understand it the "As shot neutral" tag contains the as shot multipliers and not the measured ones. If the camera WB setting is at auto those two are the same, but if we have manually set WB there can be a great difference. I would prefer both but if the available space is only enough for one I vote for the measured WB.

a1ex

  • Administrator
  • Hero Member
  • *****
  • Posts: 12461
Re: [rec_raw] Whitebalance AsShotNeutral in Raw-Header?
« Reply #13 on: July 02, 2013, 08:15:59 AM »
These numbers are camera-specific, right?

For getting the current WB setting, please see reply #1.

chmee

  • Contributor
  • Hero Member
  • *****
  • Posts: 1031
  • raw2cdng
Re: [rec_raw] Whitebalance AsShotNeutral in Raw-Header?
« Reply #14 on: July 25, 2013, 11:22:32 AM »
@a1ex is it possible to simulate one photo-shot (without a pictureoutput) right before the movie-recording begins? saving the exifs from this shot as separated file with the same name as the raw-file?

Example:
M15-1212.raw
M15-1212.exif

or much simpler
M15-1212.raw
M15-1212.CR2

(merging of CR2-Metadata then in the converter)


regards chmee

marekk

  • Senior
  • ****
  • Posts: 331
  • www.oddajmisie.com
Re: [rec_raw] Whitebalance AsShotNeutral in Raw-Header?
« Reply #15 on: August 03, 2013, 11:50:39 AM »
I shot some raw movies in Prague last week and now I'm trying to process tens of shots and it's really difficult to manually set white balance for each movie...

chmee

  • Contributor
  • Hero Member
  • *****
  • Posts: 1031
  • raw2cdng
Re: [rec_raw] Whitebalance AsShotNeutral in Raw-Header?
« Reply #16 on: August 03, 2013, 11:23:05 PM »
I#m working on that.. :)

g3gg0

  • Developer
  • Hero Member
  • *****
  • Posts: 3157
Re: [rec_raw] Whitebalance AsShotNeutral in Raw-Header?
« Reply #17 on: August 04, 2013, 01:06:17 AM »
its implemented in the new .mlv version of raw_rec
Help us with datasheets - Help us with register dumps
magic lantern: 1Magic9991E1eWbGvrsx186GovYCXFbppY, server expenses: paypal@g3gg0.de
ONLY donate for things we have done, not for things you expect!

chmee

  • Contributor
  • Hero Member
  • *****
  • Posts: 1031
  • raw2cdng
Re: [rec_raw] Whitebalance AsShotNeutral in Raw-Header?
« Reply #18 on: August 04, 2013, 02:15:52 AM »
g3gg0 point us to the thread or some infos on that!
lol. found. (whitebalance. is it or will it be implemented?)
http://www.magiclantern.fm/forum/index.php?topic=7122.0

regards chmee

a1ex

  • Administrator
  • Hero Member
  • *****
  • Posts: 12461
Re: [rec_raw] Whitebalance AsShotNeutral in Raw-Header?
« Reply #19 on: August 04, 2013, 09:05:29 AM »
Only the easy part is implemented (saving the internal WB info from Canon). The hard part (how to put that info in a DNG) is not ;)

chmee

  • Contributor
  • Hero Member
  • *****
  • Posts: 1031
  • raw2cdng
Re: [rec_raw] Whitebalance AsShotNeutral in Raw-Header?
« Reply #20 on: August 04, 2013, 11:49:45 AM »
:) im ready to write a mlv2cdng converter :)

chmee

  • Contributor
  • Hero Member
  • *****
  • Posts: 1031
  • raw2cdng
Re: [rec_raw] Whitebalance AsShotNeutral in Raw-Header?
« Reply #21 on: August 12, 2013, 07:40:22 PM »
so, i did a trial in raw2cdng v1.3.0 with raw-files. all experience will be taken into the mlv-converter..
http://www.magiclantern.fm/forum/index.php?topic=5618.250

regards chmee

Jip-Hop

  • Freshman
  • **
  • Posts: 91
Re: [rec_raw] Whitebalance AsShotNeutral in Raw-Header?
« Reply #22 on: July 02, 2019, 01:31:41 AM »
There's this feature request for Auto White Balance in MLV App: https://github.com/ilia3101/MLV-App/issues/168. But it would be great if the MLV files already came with the measured white balance when the camera is set to Auto White Balance. So I figured the in-camera measured white balance must be in the exif data. I thought perhaps I can make my EOS M take a picture before starting RAW video recording. So I can have access to the measured white balance, and apply it from the photo to the video. Which is exactly what chmee suggested.

@a1ex is it possible to simulate one photo-shot (without a pictureoutput) right before the movie-recording begins? saving the exifs from this shot as separated file with the same name as the raw-file?

Example:
M15-1212.raw
M15-1212.exif

or much simpler
M15-1212.raw
M15-1212.CR2

(merging of CR2-Metadata then in the converter)


regards chmee

Seems like you guys almost cracked this puzzle in 2013! Where did it go from here? Would love to know if this turned out to be impossible or still worth looking into.