Archive: Colour to Black and White


2nd July 2002 15:39 UTC

Colour to Black and White
Looking at the previously thread about the colours got me thinking.

I would like to know what is the forumla to convert any colour to what it would look like on a black and white tv.

e.g. Red (r=1,b=0,g=0) might be (I do not know) (r=0.8, b = 0.8, g=0.8)

Does anyone know what these would be and a forumla to work these out?

I want to craete a code drive b&w filter that I can change on to the music etc.

Sorry if the syntax is a little wrong but can anyone here help.


8th July 2002 15:46 UTC

I'm no expert, but I BELIEVE that all you hafta do is take away the hue and saturation data, and just have luminance. The formulas to convert, however, I'm not sure.

For an easy way, divide all the components (rgb) by 3 and add them together to get a grayscale type thing... Try it out, it might work.

~Keaton


8th July 2002 18:36 UTC

Well, I've been working on a sinusoidal interpolation of hues, but I can't get it exactly correct.
(init) shift=acos(-1)/3;
--------------------
(frame)
red=abs(sin(t));
green=abs(sin(t+shift));
blue=abs(sin(t+shift*2));

where t is whatever you're basing it off of (the colors will fluctuate relative to t). Your computer interpolates hues linearly, but I'm too stupid to do that. But like I said, it's not exactly correct yet...

Saturation and luminoscity shouldn't be to hard. I'm just guessing here, but saturation should be:
red=(red-0.5)*sat+0.5;
green=(green-0.5)*sat+0.5;
blue=(blue-0.5)*sat+0.5;

and luminoscity should be:
red=red*2*lum;
green=green*2*lum;
blue=blue*2*lum;

I'll go check it out in a bit


9th July 2002 11:49 UTC

If you want to convert a RGB value into a Brightness value, you have several possible approaches:

- Use the average of the 3 colour channels (bad approach)
- Use the average of the minimal and maximal component (desaturation)
- Use the maximal component (HSV decomposition)
- Use a weighted average of the 3 colour channels ('natural' grayscale).

Typically the last approach is best because it results in a value that is the same as the perceived brightness. The human eye is more sensitive to green than to red and blue. The following weights are use for RGB to YUV, which is the colourspace used in PAL televisions:

Y = 0.2989*Red+0.5866*Green+0.1145*Blue

On the following page you can see a natural grayscale (top-right), a desaturation (bottom-left) and an HSV decomposition (bottom-right):

http://gimp-savvy.com/BOOK/index.html?node54.html