1
$\begingroup$

I found this function for RGB to Gray scale converter at this kind:

RGB to grayscale

This example converts an image with RGB channels into an image with a single grayscale channel.

The value of each grayscale pixel is calculated as the weighted sum of the corresponding red, green and blue pixels as:

Y = 0.2125 R + 0.7154 G + 0.0721 B

Copy to clipboard

These weights are used by CRT phosphors as they better represent human perception of red, green and blue than equal weights. 1

Also at Matlab site said about :

Algorithms

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

These are the same weights used by the rgb2ntsc function to compute the Y component.

The coefficients used to calculate grayscale values in rgb2gray are identical to those used to calculate luminance (E'y) in Rec.ITU-R BT.601-7 after rounding to 3 decimal places.

Rec.ITU-R BT.601-7 calculates E'y using the following formula:

0.299 * R + 0.587 * G + 0.114 * B

So, i like to know why difference value and how many standard exist in this function type?

Thanks.

$\endgroup$
1

2 Answers 2

2
$\begingroup$

There are different color spaces. Each of them has different coefficients for calculating gamma-corrected luma from gamma-corrected RGB values. You have listed coefficients for calculating luma according to ITU-R BT.709, ITU-R BT.601 and NTSC color spaces. There are many others as well, like BT.2020 used in consumer TVs for Wide Color Gamut.

$\endgroup$
1
$\begingroup$

The reason they are different is because (1) your eye have different sensitivity to different colors, and (b) display devices have very different color output. Therefore the luminescence need to be adjusted accordingly.

Just adding the references and corrected number (0.7152):

#  0.2989 *R + 0.5870 *G + 0.1140 *B    # [1] NTSC
#  0.2126 *R + 0.7152 *G + 0.0722 *B    # [2] luminance signal EY
#  0.2627 *R + 0.6780 *G + 0.0593 *B    # [3] UHDTV
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.