
Originally Posted by
bpetty
Looking at
QColor's qGray documentation
http://doc.qt.io/qt-4.8/qcolor.html#qGray on how it converts RGB to Grayscale, it uses this formula:
(r * 11 + g * 16 + b * 5)/32
There are a few peculiarities here.
1. I can find no reference to this formula outside of this class in Qt. It is used nowhere, in any article on the subject that I can find.
It looks like an approximation of the RGB->Luma conversion in ITU BT.601.
Y = 0.299 R + 0.587 G + 0.114 B
Y = 0.299 R + 0.587 G + 0.114 B
To copy to clipboard, switch view to plain text mode
Common approximations are:
Y = 0.33 R + 0.5 G + 0.16 B ( computed like Y = (R+R+G+G+G+B)/6 )
Y = 0.375 R + 0.5 G + 0.125 B ( computed like Y = (R+R+R+G+G+G+G+B) >> 3 )
Y = 0.33 R + 0.5 G + 0.16 B ( computed like Y = (R+R+G+G+G+B)/6 )
Y = 0.375 R + 0.5 G + 0.125 B ( computed like Y = (R+R+R+G+G+G+G+B) >> 3 )
To copy to clipboard, switch view to plain text mode
The equation in QColor is:
Y = 11/32 R + 16/32 G + 5/32 B = 0.343750 R + 0.5 G + 0.156250 B
Y = 11/32 R + 16/32 G + 5/32 B = 0.343750 R + 0.5 G + 0.156250 B
To copy to clipboard, switch view to plain text mode
which is in between the two.
Bookmarks