Hi.

I know, this question was asked more than once, but I still have not been able to find a solution.

I want to translate the white balance coefficients into Temperature and Tint, as for example, this is done in FastRawViewer.

For this, I used dng_temperature from the DNG SDK (about the error with the typing I know).

I receive rgb_cam from cam_xyz with cam_xyz_coeff for my camera. The rgb_cam now stores the matrix from the camera to sRGB.

To get XYZ, I multiply rgb_cam by xyz_rgb. And multiply the resulting matrix by the RGB value. I hope I understood the dcraw code correctly.

Now the question arises, what exactly to use as RGB. I suggested that I need to divide the pre_mul by a white balance factor. As a result, I get values that are approximately similar to Temp / Tint, but there is no accuracy that is found in FastRawViewer.

I need help, I seem to be mistaken somewhere.

If it's easier to look at the code, here's the my test:

double out_cam[3][4]; double pre_mul[4] = {0,0,0,0}; double cam_xyz[4][3] = { {0.6722,-0.0635,-0.0963},{-0.4287,1.2460,0.2028},{-0.0908,0.2162,0.5668} }; // 5D Mark III double black = 0; double maximum = 0x3c80; double rgb_cam[3][4] = {0}; int i, j, k; int colors = 3; cam_xyz_coeff (rgb_cam, cam_xyz, pre_mul); double dblRGGB[4] = //{1986.0, 1024.0, 1024.0, 1628.0 }; // RGGB 5200 //{1438.0, 1024.0, 1024.0, 2399.0 }; // RGGB 3200 {2275.0, 1024.0, 1024.0, 1393.0 }; // RGGB 7000 double dblWB[3] = {0, 0, 0}; double dblRGB[3] = {0, 0, 0}; double dblXYZ[3] = {0, 0, 0}; GetWBcoef(dblRGGB, dblWB); for (i=0; i < 3; i++) dblWB[i] = pre_mul[i] / dblWB[i]; double dblWBmax = MAX(dblWB[0],MAX(dblWB[1],dblWB[2])); for (i=0; i < 3; i++) dblRGB[i] = dblWB[i] / dblWBmax; for (i=0; i < 3; i++) for (j=0; j < colors; j++) for (out_cam[i][j] = double(k=0); k < 3; k++) out_cam[i][j] += xyz_rgb[i][k] * rgb_cam[k][j]; dblXYZ[0] = dblXYZ[1] = dblXYZ[2] = 0; for (i=0; i < colors; i++) { dblXYZ[0] += out_cam[0][i] * dblRGB[i]; dblXYZ[1] += out_cam[1][i] * dblRGB[i]; dblXYZ[2] += out_cam[2][i] * dblRGB[i]; } dng_temperature t; dng_vector_3 coord(dblXYZ[0],dblXYZ[1],dblXYZ[2]); dng_xy_coord xy = XYZtoXY (coord); t.Set_xy_coord(xy); double Temp = t.Temperature(); double Tint = t.Tint();

## 1/2 Solved

To get the same Temp/Tint as in ACR you you need to do:

1. CameraNeutral[3] = {G1/R,1,G1/B}; // R, G1, B are WB mul

2. use NeutralToXY from dng_sdk_1_4\dng_sdk\source\dng_color_spec.cpp

3. use Set_xy_coord from dng_sdk_1_4\dng_sdk\source\dng_temperature.cpp to get Temp/Tint

I rewrote the code and got the same result as in ACR. But there is a trouble. I have to get CameraCalibration matrixf for RAW. Another matrix I goto from Adobe dcp files (from DNG Converter).