Why don’t the DNG ColorMatrix and ForwardMatrix satisfy the expected equation?

Asked 8/5/2023

127 views

2 answers

0

I’m testing the DNG spec relationship between a camera profile’s ColorMatrix and ForwardMatrix using a Fuji X-T4 DNG created by Adobe DNG Converter. Based on the article/spec, I expected the forward matrix to match a chromatic-adaptation transform multiplied by the inverse color matrix and white-balance diagonal term, but my calculated result does not match the embedded ForwardMatrix.

I used the matrix values extracted from the DNG metadata and tried a linear Bradford CAT from D65 to D50, with the white-balance diagonal derived from the ColorMatrix response to the reference white. The mismatch is substantial, not just rounding error.

Is this likely due to a mistake in my interpretation, the use of a different CAT or normalization, or are the published equation/article simplifications not sufficient to reproduce Adobe’s embedded ForwardMatrix from real DNG metadata? I’d also like to know whether others have seen the same issue with sample DNG files from other cameras.

Originally by Photography Stack Exchange contributor. Source · Licensed CC BY-SA 4.0

Photography Stack Exchange contributor

3y ago

2 Answers

1

I came across your question because my astro camera sensor is the same as the one used by your camera, and I needed to get the matrices for color conversion.

I read the paper you cited and everything seems to be logically correct. However, I encountered the same problem as yours - equation 75 does not hold. I got an example image for your camera from DPreview - studio shot comparison website: https://www.dpreview.com/reviews/image-comparison where you can select your camera model and download RAW image files as well as jpegs. I also got an example image for the camera that the author of that paper used (Olympus E-M1), and I found the same situation. Regrettably, the author did not attempt to test his equation 75 with the actual exif data from his image.

Then I read the Adobe DNG specification document (v 1.6.0.0) to try to figure out the reason of the discrepancy. The only extra matrices that are involved in the conversion from camera to XYZ_D50 are the ones called AB and CC -- Analog Balance and Camera Calibration matrices. The DNG exif data for the Fuji has AB = identity, and CC = diag(1.0347, 1, 0.9481), which is very close to identity. Disregarding CC (and AB which is ID), the equations given in the DNG spec doc agree with those in Rowlands' paper. I checked also including the CC matrix, but that does not make a significant difference, naturally.

So what is the conclusion? The DNG spec doc says that if the Forward Matrices are given in the exif data, one should use those to make the conversion to XYZ (and then RGB), whereas if they are not given, then one should use the conversion equation based on the Color Matrices. (In another forum someone conjectured that the color matrices are used just for normalization purposes, so we shouldn't expect them to be consistent with the forward matrices.)

An additional clue comes from the exif data in the JPG image downloaded from the same DPreview site. There, you find Red, Green and Blue matrix columns. Putting these together and transposing, you get a matrix that has to be a forward matrix, as it sends the vector (1,1,1) to the XYZ coordinates of D50. This is probably the conversion that was used to create the JPG image, and it is similar (but not exactly the same) to the Forward Matrices in the DNG file (probably interpolated to the exact scene white). According to https://www.strollswithmydog.com/determining-forward-color-matrix/, the matrix \$M_{\mathrm{sRGB}}^{-1} \cdot \mathrm{CAT}_{D50\rightarrow{D65}} \cdot \mathrm{ForwardMatrix}\$ is called "color matrix" in the DxOMark website https://www.dxomark.com/, as it takes white-balanced raw sensor data to sRGB. So some flexibility in the terminology should be accommodated. Fortunately, the above website (strollswithmydog) does make all the detailed calculations showing that his forward matrix agrees with the values given in the DxOMark website, so we can be pretty confident that the Forward Matrices are the ones to be used, if given in the exif data.

Originally by user115932. Source · Licensed CC BY-SA 4.0

user115932

2y ago

0

AI Answer

Generated from our catalog & community — verify before relying on it.

Your result is likely not just a math mistake. Another user tested the same idea on Fuji X-T4 data and also on Olympus E-M1 sample DNG/RAW files and found that the article’s Equation 75 did not reproduce the actual embedded ForwardMatrix values.

So the practical takeaway is: real DNG metadata may not follow that simplified relationship in a way you can verify directly from the stored matrices alone. The mismatch could come from omitted details in the article/spec interpretation, normalization choices, or Adobe’s profiling pipeline using additional constraints not captured by your reconstruction.

A useful way to cross-check is to try other camera files, such as downloadable RAW samples from DPReview’s studio comparison tool, and compare whether the same discrepancy appears. Based on the community report, it does.

So the safest conclusion is that the article’s equation is not sufficient by itself to reproduce Adobe’s embedded ForwardMatrix from actual DNG files.

UniqueBot

AI

3y ago

Your Answer