14

I am getting quite confused with the purpose of gamma correction and the relationship between gamma corrected and uncorrected images in terms of graphics and photography as well as color management in general (conversion from linear RGB to gamma-corrected RGB spaces and then displaying it on the screen).

From many sources, mainly http://www.guillermoluijk.com/article/gamma/index.htm and question #23026151 at StackOverflow (Do I need to gamma correct the final color output on a modern computer/monitor?), I've come to the conclusion that:

Gamma correction was originally designed to compensate for CRT monitors' non-linear response to input signal. CRTs were not able to amplify the input signal themselves and thus the output signal from the PC needed to be adjusted giving rise to (as of today) standard gamma 2.2 correction and sRGB color space.

Modern screens, however, do not suffer from the signal loss like CRTs did. They too may show some non-linearities but given that the input signal is most often carried by only 8 bits per channel (256 shades), they should be able to compensate for some non-linearities in their color reproduction themselves as they are probably capable of reproducing more than 256 shades in one channel. This would mean that gamma correction along with sRGB and all gamma-corrected color spaces are just a heritage from the CRT era and its only purpose was to display input signal linearly.

There are also articles claiming that gamma correction is here to compensate for non-linearity of human vision (CambridgeInColour.com - Understanding gamma correction) which should roughly correspond to the gamma curve as we are capable of spotting small differences in darker shades but don't do so well with brighter ones (the brightness of a point must grow exponentially for it to appear brighter). This is not how camera sensors record the scene. Raw data from a sensor are obtained in linear RGB and developed into gamma-corrected RGB color space (shadows raised and lights darkened). Gamma correction was meant to compensate for output signal loss though, so what I believe modern screens do is they simply simulate the behaviour of CRTs to cancel gamma correction out and display the scene just like it was captured by the camera - roughly speaking, mapping camera shades 1:1 to the screen ones. Well, I cannot see any compensation effect regarding human vision here, since the output signal is again linear.

Does it then mean that every shade in whatever RGB color space should have exactly the same RGB values in every other RGB space including linear RGB (e.g. #010A1F in sRGB translates exactly to #010A1F in linear RGB in terms of storage in a bitmap file with 8bpc) and it is only up to the screen and graphics adapter how they arrange the color transfer and whether either side has to perform any additional recomputations in order to convert the image to destination color space? In other words, changing color space in a graphics editor has in fact nothing to do with the RGB values themselves, only takes note of the new color space in image metadata? I believe this is not the case because color management as such would be rendered useless where digital graphics adapter/screen interface is used - the graphics adapter could simply send plain RGB data regardless of the color space used as no analog gain (gamma) would be applied to the values which go on a linear scale from 0 to 255. Also the gamut of different color profiles would be the same if no rounding errors were introduced, or?

My last bit of confusion comes possibly from the misunderstanding of color profile conversion and the table of exposure levels (the first one) in the article http://www.guillermoluijk.com/article/superhdr/index.htm (can be translated using Google Translate). Do I understand it correctly that the linear values are transformed using an exponential function (or inverse gamma), shrinking the tonal range towards shadows and thus darkening the image? Is this what happens if we save linear RGB and present it as a gamma-corrected image to the computer screen?

I apologise for asking such a complex question but it proves very hard to find a really good source of information explaining all the uncertainties that arise. Thank you in advance for any answer that may help correct my misunderstanding.

  • 4
    You might want to try to condense this question. While it is still possible to answer it from the title alone, I think that editing it would be a good way to help you understand the topic yourself. – JenSCDC Aug 24 '14 at 19:59
  • 1
    I'm starting to work on an answer, in no small part because I realized that I had forgotten a lot, and answering someone's question is a good way to relearn it. – JenSCDC Sep 1 '14 at 17:04
  • The main reason is simply backwards-compatibility. You want to be able to use the same computer and the same software with old CRT monitors and modern LCD monitors. Software keeps doing the same thing as what it did in the old days: it creates images in the sRGB colour space. This, of course, includes the usual gamma correction. Then old CRT monitors will use the images as is, while modern displays will basically "undo" the conversion from a linear colour space to sRGB colour space. – Jukka Suomela Sep 1 '14 at 18:44
  • And how it relates to photography: given the right tools, it doesn't. Gamma correction (and more generally conversions between various colour spaces) happens automatically; normal users should not be able to see it at all. It is just a technicality that computer programmers will have to be aware of, but end users do not need to know about it at all. (Unless, of course, you explicitly want to enter something like hexadecimal colour values in sRGB colour space, in which case you most likely know what you are doing.) – Jukka Suomela Sep 1 '14 at 18:51
9

from Charles Poynton "The rehabilitation of gamma":

Misconception: The nonlinearity of a CRT monitor is a defect that needs to be corrected.

Fact: The nonlinearity of a CRT is very nearly the inverse of the lightness sensitivity of human vision. The nonlinearity causes a CRT’s response to be roughly perceptually uniform. Far from being a defect, this feature is highly desirable.

Misconception: The main purpose of gamma correction is to compensate for the nonlinearity of the CRT.

Fact: The main purpose of gamma correction in video, desktop graphics, prepress, JPEG, and MPEG is to code luminance or tristimulus values (proportional to intensity) into a perceptually-uniform domain, so as optimize perceptual performance of a limited number of bits in each RGB (or CMYK) component.

the rest of the article is very enlightening, too :)

  • The scene in Nature is in linear gamma, and should be presented on a screen or on paper same way, with a little raise of gamma to compensate for flare - usually gamma 1.1 or 1.2. – Iliah Borg Oct 17 '14 at 23:56
  • 1
    Dr. Poynton's PhD thesis is now online: poynton.ca/PDFs/Poynton-2018-PhD.pdf . Chapters 3 and 4 deal with the classical curves, chapter 8 introduces the "Barten Lightness" OETF which has the same shape as the Dolby PQ curve (SMPTE-2084). At the high end of the scale it morphs seamlessly from a gamma into a log curve, which is what we actually expected. The whole book is very enlightning ! – Jeroen van Duyn Jun 3 at 18:00
6

Consider this example from Cambridge in Colour:

enter image description here

By applying gamma encoding, we are able to represent the original image more accurately, with the same bit depth (5, in this example).

This is achieved by using the 32 levels in a way that more closely corresponds to the human eye. In other words, it's a form of compression. JPEGs, for example, can actually store around 11 stops of dynamic range despite using only 8 bits per channel.

And like any other form of compression, it doesn't matter if you don't care about file size (and the lower speed with which you can read or write larger files). You could, in theory, use a JPEG-like format that used linear gamma, if you were willing to allocate 11 bits to each channel rather than 8.

So, to summarize, gamma is just a form of compression: it reduces the file size needed to store a certain amount of information as the eye perceives it. Alternatively, it lets you store more subtle gradations in the same bit depth.

6

I am a former broadcast engineer, and I currently work in feature films and television as an editor and VFX supervisor.

Many statements on here are incorrect. Gamma in the signal path is a desired benefit, and a design choice by early video engineers to reduce perceived noise in transmission.

All vacuum tubes, CRTs included, exhibit various non-linearities (see Langmuir-Child law) CRTs can vary from a "gamma" of 1.5 to over 3.5 (when driven by a voltage signal) depending on various design differences. The nonlinearities were less of an issue with monochrome, but became more critical with color so the NTSC specified a signal gamma of 1/2.2. CRT design and supporting circuits adjust actual gamma from the Langmuir-Child law (commonly understood as 1.5, but is typically higher with CRTs due to a number of factors) to a level in line with human perception "gamma" of ~2.5. For NTSC, the television set was assumed to have a gamma target of ~2.4,** while PAL indicated ~2.8

The higher gamma in the old analog broadcast signal standards is specifically to reduce perceived noise, based on human perception being non-linear. In this use case, taking advantage of the non-linearities to hide noise by the "companding" effect of gamma encoding the signal. This is quite academic.

There are a few ways that CRT TV & Monitor design could have been altered to achieve linearity as opposed to a gamma-type curve, but a gamma curve in analog broadcasting reduced apparent noise by 30 dB. Gamma was desirable then AS IT IS NOW.

Gamma is needed even if an LCD monitor could be used in a linear (gamma 1.0) way. The claims here that gamma is no longer needed are complete bunk, and fail to understand the current purpose of applying a pre-emphasis curve.

Gamma is what allows sRGB (or Rec709) to look "good" even though the bit depth is only 8 bits per channel. Here is an example:

This is an image in sRGB, 8 bit, with gamma pre-emphasis (i.e. normal web image). normal

Here is how that image would look without the benefit of gamma (i.e. if it was linear values and linear display, no gamma pre-emphasis). bad

Gamma provides for MORE BITS in the darker areas for smoother gradients and lower noise.

If you wanted to go totally linear, your entire signal path would need at least 12 bits per channel. 8 bpc IS NOT ENOUGH. Encoding with a curve and decoding on display allows the use of a smaller data chunk of one byte per color channel.

In film, we do use linear as a workspace, but when working with linear we are in 32 bit per channel floating point. When we exchange linear image files we use EXR Half, which is 16 bit per channel float. (And if we use 10 bit DPX files, the image data is encoded using a LOG curve).

BUT

The computer monitors we use are still either 8 or 10 bit FOR DISPLAY, so all linear images still need to be gamma-adjusted before being sent to the monitor. Why?

Most "good" monitors are just 8 bit per chan, and many are just "6 bit internal" meaning they take an 8 bit per chan image and display as 6 bit per channel. How can they make an acceptable image?

GAMMA!

10 bit per channel monitors are rare and expensive (like my NEX PA271W). My NEC can take a 10 bit signal, and uses a 14 bit internal LUT for profiling. But 10 bits is still not enough for linear!

Gamma or some form of preemph/deemph curve is required even for 10 bit. 12 bit is the bare minimum for reasonable linear display, and even then is unacceptable for the feature film industry.

We use 12 bit projectors for DCDM (Digital Cinema) and guess what? Not only is DCDM using CIE X´Y´Z´, we ALSO use a projector gamma of 2.6 !!!

DCI was created for theaters and is its own closed eco-system, with no reliance on old technologies like CRT. If there was some "advantage" to using a linear (gamma 1.0) space, it would have been used, but it is not.

Linear is NOT used in digital cinema because the ADVANTAGE is using a gamma curve.

So, please stop saying we only use gamma for legacy reasons, because that is false.

Please read Poynton on the subject, as he clarifies these issues in an easy to understand manner.

Thank you for reading.

Footnote: ** While the NTSC specified a signal gamma of 1/2.2, TVs were expected to have a gamma of 2.4 for a system gamma gain. It is useful to point out that Rec709 (HDTV) and sRGB are identical except for the transfer curve. And interestingly, Rec709 (via BT1886) specifies a "physical display gamma" of 2.4 (i.e. the gamma of the monitor itself) and sRGB monitors are typically set at 2.4 or higher (surveys show most users set them 2.5 and up). But the SIGNAL gamma is different, approx. 1/2.2 for sRGB and approx 1/2.0 for Rec709. in both cases, there is a system gamma gain which is intentional based on the expected viewing environment.

  • I always wondered why doesn't the audio industry use the same approach but instead throws 16+ bits per sample at it... – Zeus May 1 at 4:43
  • Hi @Zeus, there are several reasons (if you ask this as a question I can give a more in depth answer). Basically, even at 16 or 24 bit, audio streams are a far lower bandwidth than video (in general), and computationally easer to handle. Nevertheless, audio DOES use these types of pre-emphasis and de-emphasis in many cases (particularly low bit rate). And in fact hearing is also non-linear (as is all perception) but 8 bit audio is "sort of" like 4 bit per channel video. Remember that 8 bit per chan video uses a total of 24 bits per pixel, so the comparison to 16 bit audio is apples/oranges. – Myndex May 1 at 5:00
  • Thanks @Myndex, unfortunately this would be off-topic here as a question. I'm just curious why such pre-/de-emphasis wasn't used for audio from the beginning, given that it's just as natural for hearing as for sight. By the way, I meant 16 bit per channel, of course (like on CD); linear 8-bit audio (which formally exists) is arguably more horrible than the linear 8-bit video from your example (which doesn't even exist as a standard). I understand the tradeoffs are lower, but the benefits are high: losing half of the resolution every 3 dB feels insane... – Zeus May 1 at 5:55
  • I think there's a stack exchange related site that would welcome audio questions. Regardless: Each bit in 16 bit audio equals 6 dB (voltage), so there's a total dynamic range of 96 dB. 6dB (voltage) is "twice" (or half) as loud in voltage, BUT humans tend to perceive 10 dB as a literal "half as loud" amount. Pre/De emph has been used in audio since the beginning. Records had the RIAA curve, magnetic tape used the NAB curve, etc. etc. What do you mean losing half the resolution every 3 dB ??? – Myndex May 1 at 10:00
  • In linear digital encoding, half of the voltage is half of the digital range (by definition), i.e. loss of 1 bit of resolution. This is a lot for something that is perceived as 'a bit softer' (-6dB, that's the figure I meant, not 3). If we want to capture the required ~35dB at least (for speech or orchestra), that's already a 6 bit loss for the softest sounds (and even then, if properly normalised). I'm aware of the 'analog' emphasis (which was a bit different and frequency-dependent), but never heard of one used for digital, hence my questions... – Zeus May 2 at 2:26
3

There's a lot of confusing articles on gamma correction with many vague references to gamma and human vision. The reason for gamma is historical and a result of the response curve of the old CRT-type monitors (nothing to do with human vision). With modern day flat screens there is no logical reason for gamma encoding and subsequent correction, but it has become industry standard.

The coincidentally similar relationship between the gamma curve and the response curve of human vision does yield some advantage in helping cut down on file size as the bit depth of the image can be reduced without impacting the perceived image quality.

1

The OP is pretty much all correct, except that gamma makes the dark tones brighter, not dimmer. This exists just in the file, not in the eye. The data is always decoded back to original linear BEFORE any eye sees it. Any difference in the eye seeing the original scene, and seeing the reproduced decoded data, is simply an undesired reproduction error.

Gamma is done only to correct the severe losses of CRT monitors. CRT is nonlinear, it shows bright tones, but loses the darker tones. So gamma makes the dark tones overly bright, to then hopefully appear about normal again (linear) after the CRT losses. However, LCD monitors are linear, and so don't need gamma any more, but to preserve compatibility with all the worlds old RGB images, all standards still include the same gamma. It's easy for LCD monitors to merely decode and discard it. And the data still works on CRT.

Gamma is in NO WAY about the human eye.. other than we do wish to see the corrected linear original data. The eye does have a similar inverse response, which is purely coincidental, but the human eye NEVER sees gamma data. It is always first decoded (by either CRT losses, or a LCD chip), and the human eye only sees the linear data again (hopefully). Same as it saw the original scene, no gamma was needed at the original scene either. The eye needs no help. Go outside and look at a tree. There is no gamma there. Do we really imagine our eye cannot see the tree well? :) Do think about that a little more. The brain decodes the eyes response, and the CRT or LCD decodes the data encoding. Those claiming gamma is about the eye simply don't know, they are just repeating wrong stuff they heard. It's not hard to hear it, but it's very wrong. These guys should explain when and how the human eye can ever even see the gamma they imagine is necessary. It cannot, it has no chance.

Gamma is not about 8 bits.. The data is encoded, and then decoded, and to hopefully be identical, so we can see an accurate reproduction of the original linear scene. Gamma was done back in early NTSC TV (1940), before there were any bits, but we did have CRT. :) Gamma is only about CRT losses. Pure and simple. And back in the day of CRT, gamma was extremely necessary.

The RGB data is normalized (to be 0..1 percentage values) before adding gamma, typically with exponent 1/2.2 (approx square root). 18% is (0.18 ^ 1/2.2) = 0.46, or 46% on the histogram, or 117 on the 0..255 scale. (People image 18% should be 50% too. :) 18% is 18%, but we see nearly 50%, only because the histogram data is gamma encoded.) But note that 0 to any exponent is still 0, and 1 to any exponent is still 1, so there is no dynamic range increase. And no clipping due to gamma either, the end points cannot move. And of course, because the data is decoded before anyone sees it. The whole thing (encode, then decode) is just a no-op. No change to the eye, hopefully. But in the files, normalized data (which is a FRACTION) to an exponent becomes a larger number, brighter, except no eye can ever see it in there.

Gamma is ONLY done to correct the response of CRT monitors.

1

I believe our eyes have this response curve, but this response to a sudden change in the amount of light, especially if it got higher but in the same time the brain decodes that response by narrowing our iris to maintain the same (linear perception) we have while in a stable viewing condition until transition to the new viewing condition happens smoothly.

Gamma correction essentially came from the CRT electron gun non-linearity which needed more Encoding (i.e a .45 gamma applied) to send uniform output (linear output) because CRT electron gun characteristics makes the signal as if it were decoded (i.e a 2.2 gamma curve applied). In CRT days they encoded all the digital data to maintain uniformity of viewing and exchanging data on the internet so image files formats mainly encoded with the Gamma Curve of sRGB which is very similar to the .45455 Gamma Curve) and that Canceled the CRT gun Issue.

Now After all the data on the internet were encoded and due to that LCD technology linear behavior (i.e input signal = output values) they found that it's too late to decode all the Digital data again after it became a standard so they have came with a logical solution! and it is to mimic the CRT defect again and they produced LCDs with a chip that decode the signal (i.e apply 2.2 gamma curve) just as a legacy System :) otherwise they should have decoded all the data on the internet.

So Don't Get stuck in this confusion of the eye non-linearity you'll have endless circle of hopeless thinking.

And here's the relation with Gamma And Our Eyes

Linear imagery data produced by camera sensors RAW Files that have by default gamma= 1.00 (camera sensor nature) i.e (no decoding or encodeing = no correction) when Raw files "displayed" on monitor it became dark "only viewed dark" and there 10 & 12 bit per channel are large files but sadly we weren't benefiting this depth at all because our eyes is not sensitive to bright values as much as it is too sensitive to dark values and can distinguish any subtle change in darkness (and i will be explaining below).

Because the image is "viewed dark" due to Monitors nature the brightness levels are wasted on the bright values more than the mids and the dark values (because monitor gamma Viewed the mid-tones pulled down" so we would have benefit much more if dark values had the same chance.

So they found that applying Gamma correction (e.x by encoding raw data to some format like JPEG with .45455 gamma of sRGB) by luck converting it to 8 bit per channel which mean lower file size in addition to proper viewing or display of the brightness values is (which is by having the .45455 gamma burned to the pixels) and having the dark and mid-tones up again) is very consistent with eye's nature.

My explanation is because the Rod cells in eyes we have the ability of night vision and that too sensitive nature of distinguishing dark values >> we ave around 120 million Rod cell Vs only 6 or million for the Cones cells which is sensitive to monochromatic colors and wavelengths

I think it's not the Eye Response Curve that is responsible for that and don't try to link between Eye's Gamma and Monitor Gamma in any other way and Please Correct me if I'm Wrong :). I've Struggled in understanding Gamma Issues so that all I've had got about it.

This on of the best references taking about gamma reasons and solutions

http://www.w3.org/TR/PNG-GammaAppendix.html

0

Here's my first draft of an answer- I'll get into more detail as time allows, but I want to give the OP some sort of answers. Comments are more than welcome.

The stuff about CRTs does not indeed apply anymore. But there is a very good practical reason to continue to use gamma encoded images. Using gamma encoding make edits like curves look "normal" because the eye doesn't respond linearly to light- look up the creation of the LAB space for more on this.

For an example, look at this screenshot:enter image description here

The left image is the original, the middle image a copy in gamma 2.2, and the right image a copy in gamma 1.0. The curve applied to each of the copies can be seen. Given the shape of the curve, does the 2.2 or 1.0 version look like what you'd expect?

0

As a matter of fact gamma is not necessary these days, especially when working in high bit representations of the image. However that means a complete software rewrite in far too many cases - or the transition is far from seamless (say, familiar curves change the shape completely, as Mr. Blankertz just mentioned).

-1

LCD monitors are "linear", and do not need gamma today, but CRT monitors are nonlinear, and still do. And all the worlds archives of existing images do have gamma for CRT, so it's much easier to continue adding gamma than to change all software, and obsolete all existing images.

The human eye absolutely has no use for gamma. The eye sees the original scene fine without gamma. Gamma is ONLY to correct the expected losses of CRT monitors (so we do see a reproduction of the original scene). LED monitors know to just decode gamma and discard it, no big deal (because the human eye expects to see a faithfull reproduction of the original scene data without gamma, the reproduction should look the same). It would be a bad thing to see it as gamma data. Thankfully, the human eye has zero opportunity to ever see any gamma data. The sites telling us the eye needs gamma just don't know nuthin' about gamma.

Our histograms are gamma encoded however, because the data is encoded (for above reason), up until just before it is shown to the human eye. Midpoint of our encoded data is Not 50%, but about 73% in gamma data (camera adjustments like white balance and contrast shift it a bit more). If you underexpose an image exactly one stop, the 255 point shifts to about 3/4 scale, and NOT to 50% scale. An 18% gray card is 18% in liner data, but about 46% in gamma data. People incorrectly assuming that must be 50% somehow may even think of calibrating their light meter to it. :) But the eye never sees gamma data, it is always decoded first, one way or the other. The eye hopefully always sees a faithful reproduction of the original scene.

But FWIW, printers do need most of the gamma change too. Not value 2.2, but not too far from it (due to dot gain, etc). Apple observes world 2.2 standards now, but we all know the early Mac computers used to use gamma 1.8. This was NOT for the monitor, they used the same monitors that Windows used (monitors are interchangeable). But Apple used to sell laser printers back then, and the gamma 1.8 was for their printer. Then the Mac video hardware added a little more to bring it up to the 2.2 that the CRT needed. Today, printers have to tone it down a bit from the 2.2 data they receive, but they still need much of it.

Today, the standard is gamma 2.2, so that all the worlds existing RGB data is still compatible.

  • 1
    LED is backlight type. The main reason for gamma correction is NOT optimizing for CRT even if it ever was. – Euri Pinhollow Nov 12 '17 at 17:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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