I noticed that we have a few formulas for converting from RGB to Grayscale. Two of these formulas, rgb_to_grayscale and rgb_to_luma are actually the same, although the later offers more float precision.
I then noticed Campbell's comment about some "nonsense" with having two functions (rgb_to_grayscale and rgb_to_bw) to do the same thing but with different coefficients.
It is noted that rgb_to_grayscale is used more for compositing whilst it is rgb_to_bw that is used in the compositor! But they were kinda right, and that should be changed.
I am unable to find where the coefficients for the rgb_to_bw function come from, so if someone knows it would be good to share the knowledge. Otherwise, I propose to also remove this function and replace it with rgb_to_luma.
Some notes:
- rgb_to_luma (and thus rgb_to_grayscale) (Rec 601): the coefficients used properly compute luminance for monitors having phosphors contemporary to the introduction of the NTSC television back in 1953. They are still appropriate for computing video luma. However, they do not accurately compute luminance for contemporary monitors. See Wikipedia article on YCbCr.
- rgb_to_luma_y (Rec 709): these coefficients compute true CIE luminance from linear rgb and account for human perception of luminosity. The same coefficients may also be used for non-linear rgb.
After these notes/observations, it could be good to do the following:
- remove rgb_to_bw and rgb_to_grayscale
- replace their occurrences with rgb_to_luma_y
- only use rgb_to_luma where the rec. 601 is used (i.e. the YCbCr node)
For now, this patch removes the rgb_to_grayscale function and replaces its occurrences with rgb_to_luma.
Some more on-exhaustive readings (if interested):
http://dcgi.felk.cvut.cz/home/cadikm/color_to_gray_evaluation/
https://en.wikipedia.org/wiki/Luma_(video)
https://en.wikipedia.org/wiki/Grayscale
http://www.rapidtables.com/convert/image/rgb-to-grayscale.htm