fix(raw): eliminate double white balance application by un-scaling pre_mul on rgb_cam

This commit is contained in:
2026-10-05 21:59:51 +07:00
parent 2e17308b46
commit bf7b99467a
2 changed files with 11 additions and 9 deletions
+10 -8
View File
@@ -440,14 +440,6 @@ function invert3x3(m: number[][]): number[][] | null {
}
function getCamToSrgbMatrix(cd: any): number[][] {
if (cd?.rgb_cam && Array.isArray(cd.rgb_cam) && cd.rgb_cam.length >= 3) {
return [
[cd.rgb_cam[0][0] || 0, cd.rgb_cam[0][1] || 0, cd.rgb_cam[0][2] || 0],
[cd.rgb_cam[1][0] || 0, cd.rgb_cam[1][1] || 0, cd.rgb_cam[1][2] || 0],
[cd.rgb_cam[2][0] || 0, cd.rgb_cam[2][1] || 0, cd.rgb_cam[2][2] || 0],
];
}
if (cd?.cam_xyz && Array.isArray(cd.cam_xyz) && cd.cam_xyz.length >= 3) {
const cx = cd.cam_xyz;
const scale = (Math.abs(cx[0][0]) > 100) ? 10000.0 : 1.0;
@@ -470,6 +462,16 @@ function getCamToSrgbMatrix(cd: any): number[][] {
return [[m00, m01, m02], [m10, m11, m12], [m20, m21, m22]];
}
if (cd?.rgb_cam && Array.isArray(cd.rgb_cam) && cd.rgb_cam.length >= 3) {
const pm = (cd?.pre_mul && cd.pre_mul.length >= 3) ? cd.pre_mul : [1, 1, 1, 1];
const pmR = pm[0] || 1, pmG = pm[1] || 1, pmB = pm[2] || 1;
return [
[(cd.rgb_cam[0][0] || 0) / pmR, (cd.rgb_cam[0][1] || 0) / pmG, (cd.rgb_cam[0][2] || 0) / pmB],
[(cd.rgb_cam[1][0] || 0) / pmR, (cd.rgb_cam[1][1] || 0) / pmG, (cd.rgb_cam[1][2] || 0) / pmB],
[(cd.rgb_cam[2][0] || 0) / pmR, (cd.rgb_cam[2][1] || 0) / pmG, (cd.rgb_cam[2][2] || 0) / pmB],
];
}
return [[1, 0, 0], [0, 1, 0], [0, 0, 1]];
}
+1 -1
View File
@@ -1 +1 @@
a9c60b5464f6fae4d4a9084eaaa0f4674217c4f345f4f448d0d90307462cb6ad recipescam-images.tar.gz
57dffc7b58b389595d4ea7fb9cc20b3922c0725c77e9f67f7f54186cd8da2e4e recipescam-images.tar.gz