Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does greyscale work the way it does?

Tags:

My original question

I read that to convert a RGB pixel into greyscale RGB, one should use

r_new = g_new = b_new = r_old * 0.3 + g_old * 0.59 + b_old * 0.11

I also read, and understand, that g has a higher weighting because the human eye is more sensitive to green. Implementing that, I saw the results were the same as I would get from setting an image to 'greyscale' in an image editor like the Gimp.

Before I read this, I imagined that to convert a pixel to greyscale, one would convert it to HSL or HSV, then set the saturation to zero (hence, removing all colour). However, when I did this, I got a quite different image output, even though it also lacked colour.

How does s = 0 exactly differ from the 'correct' way I read, and why is it 'incorrect'?

Ongoing findings based on answers and other research

It appears that which luminance coefficients to use is the subject of some debate. Various combinations and to-greyscale algorithms have different results. The following are some presets used in areas like TV standards:

  • the coefficients defined by ITU-R BT.601 (NTSC?) are 0.299r + 0.587g + 0.114b
  • the coefficients defined by ITU-R BT.709 (newer) are 0.2126r + 0.7152g + 0.0722b
  • the coefficients of equal thirds, (1/3)(rgb), is equivalent to s = 0

This scientific article details various greyscale techniques and their results for various images, plus subjective survey of 119 people.

However, when converting an image to greyscale, to achieve the 'best' artistic effect, one will almost certainly not be using these predefined coefficients, but tweaking the contribution from each channel to produce the best output for the particular image.

like image 708
Delan Azabani Avatar asked Mar 15 '11 12:03

Delan Azabani


2 Answers

Although these transformation coefficients exist, nothing binds you to using them. As long as the total intensity of each pixel is unchanged, the contributions from each channel can be anything, ranging from 0 to 100%.

Photographers converting images to grayscale use channel mixers to adjust levels of each channel (RGB or CMYK). In your image, there are many reds and greens, so it might be desirable (depending on your intent) to have those channels more highly represented in the gray level intensity than the blue.

This is what distinguishes "scientific" transformation of the image from an "artistic" combination of the bands.

An additional consideration is the dynamic range of values in each band, and attempting to preserve them in the grayscale image. Boosting shadows and/or highlights might require increasing the contribution of the blue band, for example.

like image 56
Benjamin Avatar answered Sep 28 '22 10:09

Benjamin


An interesting article on the topic here.... "because human eyes don't detect brightness linearly with color".

http://www.scantips.com/lumin.html

like image 38
JNadal Avatar answered Sep 28 '22 11:09

JNadal