Canon cameras can show a histogram of the images (either in live view or in the preview). There are two modes: an RGB histogram and a "brightness" histogram.
While the RGB histograms can easily be recreated and show a very similar shape than on the camera, the brightness histogram is hard to replicate. Every equation to calculate "brightness" actually gives different results. The overall shape is the similar but not exactly the same.
So far, I tried the following equations (RGB values are in [0, 1]
):
- Normed RGB Norm, as
sqrt(R^2 + G^2 + B^2) / sqrt(3)
- "naive" brightness, as
(R + G + B) / 3
- ITU BT.709 Luminance, as
0.2126*R + 0.7152*G + 0.0722*B
- ITU BT.601 Luminance, as
0.299*R + 0.587*G + 0.114*B
What other type of "brightness" measure are there and what does the Canon cameras actually show?
Here is an example:
This is the histogram as seen on a Canon RP:
Now, here is a recreated version from the embedded JPEG of that RAW image using RGB Norm for the "brightness":
It can be seen, that the RGB Histograms look the same, but the brightness is not.
Edit: I have some suspicions what Canon might be doing. The histogram looks a bit spiky, while all my calculations produce a rather smooth histogram. This is likely the case when either using a different number of bins than 256 or when using floor or ceil functions or integer arithmetic. I think that Canon might compute the brightness solely on the uint8 RGB data without float operations. There is a integer approximation given here: https://stackoverflow.com/a/596241/446140
Using this equation, I get this histogram for (2R + 3G + B) / 6
:
and this one for (3R + 4G + B) / 8
:
This already looks much more similar to the Canon one, than the float based rel. luminance. However, there are still distinct differences.
(3R + 4G + B) / 8
is actually the closest I could get... However the ITU BT.709 would look like(2R+7G+B)/10
and is thus not that different. \$\endgroup\$