MATLAB Answers

0

Why does rgb2gray use these weights for the weighted sum?

Asked by Thomas Huepf on 18 Aug 2015
Latest activity Edited by kokila Mani on 30 Nov 2017
From the documentation I find: "rgb2gray converts RGB values to grayscale values by forming a weighted sum of the R, G, and B components:
0.2989 * R + 0.5870 * G + 0.1140 * B"
Depending on which format you have it is sometimes more correct to use 0.2126 * R + 0.7156 * G + 0.0722 * B. Maybe the weights which rgb2gray.m uses apply more often (in a standard case where the user is not so specific about how precisely the conversion is done)? I am this 'lazy' kind of user but I would have choosen the alternative weights. But I guess matlab knows better than I - so I would like to know why they prefere their choise.

  0 Comments

Sign in to comment.

1 Answer

Answer by blaat
on 18 Aug 2015
Edited by blaat
on 18 Aug 2015

These values come from the BT.601 standard for use in colour video encoding, where they are used to compute luminance from an RGB-signal. It was probably optimised for accurate perceived brightness.

  3 Comments

Thanks for the standard. The standard uses these weights on "gamma pre-corrected primary analogue signals". So, rgb2gray.m is very specific. Probably, many users don't consider this (and matlab experts know that they don't). I still don't know why these weights were considered to be the better choice. Why was this standard preferred?
If I had to guess, I'd say that there wasn't necessarily too much reasoning behind it. The code of rgb2gray() seems to indicate it was originally written in 1992. Back then, the BT.709 standard using the "better" coefficients was only just introduced and not in widespread use - nobody used HDTV yet. The coefficients from BT.601 were therefore a logical choice, since they were the then-standard.
Changing the behaviour of rgb2gray() afterwards was probably considered do to more harm than good, since it would affect a lot of code that processes images.
The image shows the sensitivity of our eye cones vs wavelength of primary colour(Red,green,blue).According to which green has high sensitivity then comes red,and blue. so if you see the weights "(0.2989 * R + 0.5870 * G + 0.1140 * B") we have high value for green weight(0.5870),then red(0.2989),then blue(0.1140).
Note:This is not an explanation for exact weight figure.

Sign in to comment.