PDA

View Full Version : Gamma -- Everybody's favorite greek letter?


High Speed Dubb
13th January 2003, 07:58
In another thread (the one about blivit’s YATS), scmccarthy asked
What do you mean by 'gamma correction'. It is a very technical term and an important term and one where a lot of confusion exists.
...so here is a shot at an answer.

As it turns out, TVs aren’t linear. That is, if you double the strength of the (for example) Red signal, you won’t see a color which seems to have twice as much red.

The relationship between signal strength and observed CRT color turns out to roughly follow a power law. That is,
(1) observed_red = red_signal^k

The k is a constant which varies from picture tube to picture tube, and even depends on hard to handle stuff like the brightness of the room. As a very rough figure, k tends to be around about 1.0/2.4.

Back when the PAL and NTSC specs were designed, the engineers were aware of this nonlinearity. Since running a nonlinear transform on the data inside the TV set wasn’t a realistic possibility, they decided to specify that the signal should automatically compensate for the picture tube. In other words,
(2) R' = R^(1/k)
where R' = signal_red and R = true_red_color

By specification, k for NTSC is 1.0/2.2, and 1.0/2.8 for PAL. 1/k (so 2.2 for NTSC, 2.8 for PAL) is usually known as “gamma.”

This has a bunch of implications.

- LCDs don’t have the same properties as a CRT. So if you want to show NTSC or PAL video on an LCD, you need to transform ("gamma correct") to a linear range. For that matter, CRTs don’t exactly follow the standard, either, so it makes sense to transform for them, too.
- Note that this is a nonlinear transform in RGB space. Because it’s nonlinear, you can’t just run the same kind of function in YUV colorspace.
- Because of equation (2), we aren't really looking at the RGB or YUV colorspace — Really we have Y'U'V' or R'G'B' data. [The apostrophes indicate that the components have been (RGB) transformed.] Usually we skip this distinction in discussions, but it does sometimes matter.
- Because we’re working in Y'U'V', distances and averages between pixels are perceptually very approximate. But if the colors are similar, it’s a passable approximation. (And for that matter, distances and averages in YUV and RGB are approximate, too.)
- Noise tends to be normally distributed in Y'. Because of equation (2), this results in greater perceived noise in darker areas of the picture.

If you do any Google searches on this, be careful of a couple terminology gotchas. The “gamma function” and “gamma distribution” are completely unrelated to video gamma.

blivit
13th January 2003, 09:34
The best reference I have found on these subjects is:

http://www.digitalcolour.org/understanding/coloureq.txt

In the above reference, it mentions that a BBC survey showed that gamma is actually 2.35 for a correctly set-up CRT. So I guess neither NTSC nor PAL will actually display like it was intended to :)

I also noticed a while ago that one of the equations for either NTSC (Y'I'Q') or PAL (Y'U'V') <-> RGB conversions in the above document was wrong. It's the one that has coefficients that don't add up to 1, I forget which. You can get the correct equation from the other form of the equation given on the same line. Someone just made an algebra error.

--EDIT--
Ooops -- I forgot to add the ' after each letter the first time around. It is easy to forget to write them properly :) Also, note that Y'U'V' is _NOT_ the same as Y'CbCr !! Read the text. There is often much confusion in the digital processing community between the two.

-Eric

High Speed Dubb
14th January 2003, 03:04
In the above reference, it mentions that a BBC survey showed that gamma is actually 2.35 for a correctly set-up CRT. So I guess neither NTSC nor PAL will actually display like it was intended to

I think they purposefully used too low a gamma in the NTSC spec, with the expectation that people would be watching their TVs in dark rooms.

And from what I read, the PAL spec of 2.8 isn&rsquo;t really followed.

scmccarthy
14th January 2003, 06:21
I think they purposefully used too low a gamma in the NTSC spec, with the expectation that people would be watching their TVs in dark rooms. That's right, gamma compensates for the viewing environment as well, the standard assumed viewing condition for TV and computer viewing is in a dark room.

Check out Poynton's 'GammaFAQ'.

Stephen

High Speed Dubb
14th January 2003, 09:34
scmccarthy,
So, did that clarify what you were wondering about?

scmccarthy
14th January 2003, 19:00
Yep,

I am single sentence. Contrast *is* a linear transform, Gamma is not.

Stephen