cam_mul array to Temperature and Tint and back

Hi guys,

is there some way how calculate Temperature and Tint value from camera white balance array and back?

I have
cam_mul = {1413, 1024, 2110, 1024};

and I know that it is for Temperature 3200 Kelvin.

For white balance I am using cameraWbCoeff = {1413/512, 1024/512, 2110/512, 1024/512}; and RAW after all changes is OK. But I need change required temperature like as in ACR or UFraw.

I am using Canon EOS-1DX

Thank you for advice

Best Regards Ladislav


Thank for reply.

Thank for reply.

I looked to DNG SDK but I am not able move cam_mul[] to DNG SDK required parameters dng_xy_coord. Calculated temperature is different than on camera.

What is right way how convert cam_mul to xy or XYZ?

Thank you

Calculated temperature *will*

Calculated temperature *will* differ from camera because camera and LibRaw uses different color profile (because color profile is used for xy-calculation)

The only way to check results is to compare to Adobe software (Lightroom or Camera Raw) with same color profiles (so, for example, DNG file with built-in camera matrices: ACR/Lr uses embedded color datain DNG case and LibRaw may be forced to do the same)

-- Alex Tutubalin

White balance

Hi Alex,

Can I have some questions to you:

1] When I want convert RAW image to XYZ color space I multiply rgb_cam * cam_xyz * RAW pixel?

2] Does LibRaw contain parameters of camera temperature? Or is there some way how reconstruct this value from camera?

3] Is possible reconstruct from Libraw parameters RAW pixel values where camera measure white balance coeficients?

Thank you Ladislav

1) rgb_cam is Camera to sRGB.

1) rgb_cam is Camera to sRGB. You may multiply this matrix to srgb2xyz matrix to get camera-to-xyz matrix.
2) LibRaw do not do anything with camera CCT/tint
3) Could you please re-formulate your question, I cannot understand what you want to obtain.

-- Alex Tutubalin

White balance values

Thanks for reply.

reformulate 3] Camera must calculate white balance coefficients from some RGB raw values. It is possible get from LibRaw these RGB values?


The rule is simple: rgb

The rule is simple: rgb values, multiplied by WB coeffs will result into equal values (e.g. gray). So, assume Green to be, for example, 1024, than Red/Blue will 1024-divieded-by-WB coeff.

-- Alex Tutubalin

White point reference

Hi Alex,
1] yes it is clear for me, but must be some reference point for white reconstruct point where camera measure rgb values. It is possible get this reference point from LibRaw? I have function which get CCT from XYZ and I need some reference point from camera to get this white point reference.

and one other question.
2] What is different between pre_mul and cam_mul arrays?

For me working pre_mul as camera temperature setting. I am using matrix

for(int row=0; row < 3; row++)
for(int col=0; col < 3; col++)
cam2RGB[row][col] = rgb_cam[row][col] * pre_mul[col];

than multiply all RGB values for each pixel

int correction_R = cam2RGB[0][0] * pixel_R[col] + cam2RGB[0][1] * pixel_G[col] + cam2RGB[0][2] * pixel_B[col];
int correction_G = cam2RGB[1][0] * pixel_R[col] + cam2RGB[1][1] * pixel_G[col] + cam2RGB[1][2] * pixel_B[col];
int correction_B = cam2RGB[2][0] * pixel_R[col] + cam2RGB[2][1] * pixel_G[col] + cam2RGB[2][2] * pixel_B[col];

cam_mul working too but image is without color cast and image is not same as in other image editors.

Thanks Ladislav

cam_mul is camera (as shot)

1) For some cameras you may get some additional WB data from EXIF/Makernotes fields. LibRaw only parses camera 'as shot' coefficients for most cameras.

cam_mul is camera (as shot) white balance.
pre_mul is daylight white balance (calculated from Adobe camera matrix)

-- Alex Tutubalin

Am I right to think that rgb

Am I right to think that rgb_cam is filled with the values of pre_mul?


rgb_cam is [3][4] matrix,

rgb_cam is [3][4] matrix, while pre_mul are [4] WB multipliers.

-- Alex Tutubalin