OT: Gamma and linear light

Posted by Jeff Harrell 
OT: Gamma and linear light
March 21, 2010 05:19PM
The subject of gamma versus linear light has come up a few times recently, so I thought I'd just put this here so if anybody wants to refer to it, they can.

We're all familiar with gamma, in the sense that it's a number, and changing it makes an image look overall brighter or darker, sort of, kinda. That's the empirical explanation. But just a tiny bit of a deeper technical understanding is helpful when you have to figure out why things aren't working the way you think they should.

We'll start by talking briefly about how electronic sensors see light. An electronic sensor generally has a linear response to light. In other words, if you shine twice as much light into it, you'll get out a value that's twice as big. If we plot out a linear response curve, it looks like a straight line ? hence the term "linear."



But televisions do not have a linear response. If you send a certain signal to a television, then double it, it will not emit twice as much light as before. Plot a CRT's response in terms of emitted light to input voltage on a graph, and you get something like this:



It's not a straight line, so it's nonlinear.

Now, obviously if you go out and record something with your camera, then want to play it back, you want the overall relationships between the tonal values in the on-screen image to match what your camera was pointed at in the field, yeah? In other words, you want the contrast to match what you saw on location. So we have to apply a correction to the signal we send to the monitor. That correction is just the reciprocal of the monitor's response curve. It looks like this:



This is what we call the gamma curve. If you take your image and transform it through the gamma curve, then send that signal to a CRT television, what you'll get back will at least closely approximate your original image.

This operation ? applying the reciprocal curve to the sensor's output ? is actually handled for you by the camera itself, so you don't need to worry about it. But it's important to remember that it's occurring behind the scenes.

I know it sounds complicated, but it's unavoidable. See, a cathode-ray tube's nonlinear response to input voltage is a consequence of the laws of physics. There's nothing anybody can do to change it, ever. It's like gravity. You can't alter it, so you just have to learn to live with it.

(I'm talking about CRTs here, with the acute awareness that CRTs are nearly extinct. The fact is that LCDs behave downright bizarrely in terms of their input-to-illumination curves, so every LCD screen has circuitry inside it that forces it to more or less approximate the response of a CRT. Since CRTs are what LCDs are replacing, it made sense to reproduce their quirks.)

Now, this is important, so I'm going to say it loudly.

Everything you see on your screen is a lie.

I'm serious. Everything you see on your computer screen, or your broadcast monitor, is a bald-faced, shameless lie. Throw up any timeline you might happen to have laying around. See that image in the canvas? Lie. Take any still into Photoshop. What you see there is a lie too. Every pixel ever drawn on your computer screen is a flat-out, no-kidding, I'm-being-totally-serious-now lie.

By which I mean it's been gamma-corrected.

Look, I said this bit is important. I have no qualms about manipulating your emotions to get you to pay attention.

Remember how I said sensor data is linear? With that straight-line response curve? That's how digital images are actually stored in your computer. Remember, stuff that's recorded with a video camera has had the gamma correction already applied for you, in-camera. But stuff that never touched a video camera hasn't been corrected. I'm calling out video specifically there, because cameras like the Red One and the Panavision Genesis and the Sony F35 handle gamma completely differently. For purposes of our conversation, we're gonna consider those not to be video cameras. Anything that doesn't originate inside a video camera is stored as linear light, and corrected in software. If all you do is view it ? like in Photoshop or whatever ? then it automatically gets converted behind the scenes to look right-ish on your monitor. If you do anything else with it, though, you need to have some passing awareness of what's being done to it, gamma-wise.

Say you're working with a graphics guy who sends you fully rendered 16-bit TIFF image sequences to drop into your timeline. You're not superimposing them, you're not doing anything fancy, you're just dropping them in place. How can you be sure that what ends up on television will match what your graphics guy thought it should look like?

Well, obviously the correct answer is that your graphics guy should have a broadcast monitor next to him, fed by a Kona board or whatever from his graphics system, so he's working in a controlled Rec. 709 environment. But we all know that doesn't always happen in the real world.

In the real world, the universal answer is communication. Ask your graphics guy directly, "Hey, what gamma space are you working in?" If he has no idea what you're talking about, fire him immediately and hire somebody who's at least once in his life been in the same room with a television.

If he says "2.2," accept that and move on. Same with "1.8" or any other numerical answer. If he says "Rec. 709," send him a fruit basket, 'cause you're dealing with somebody who gets it.

When you load any RGB material into Final Cut ? like your graphics guy's TIFF sequences, for instance ? you're given the option (through the "item properties" dialog) to specify what Final Cut calls a "gamma level." Let's take a moment to figure out exactly what that means. The number you're supposed to put in there is the gamma that approximates the response curve of the monitor the work was being displayed on when it was finaled. That's really the simplest way to say it. You're not supposed to put the value you think it should be. Basically the "gamma level" control is for plugging in the gamma value that was in effect when the shot was signed off on. If your graphics guy says he was working in 1.8 space, set that to 1.8. If he says 2.2, set it to 2.2. If he says "Rec. 709," after you send him the fruit basket, set it to 2.2, and hope the artist's monitor at least vaguely resembles a television in some way, 'cause if it does, then you're all on the same page and everything is happiness and puppies and unicorns riding surfboards.

By default, Final Cut Pro assumes the graphics guy's monitor was set up to have a gamma value of 1.8; in my experience, this is correct far more often than not. But again, you should always ask. You can change the default assumption if you want; this is covered in the manual.

So let's sum up.

? Gamma is unavoidable. It's determined by the laws of physics, so we can't just ignore it.

? Gamma is your friend. Without it, television would look like ass on stale toast.

? Anything that comes off a video camera will have the proper television gamma "baked into it." Anything that doesn't come from a video camera should be examined carefully in a known-good Rec. 709 environment ? such as on your broadcast monitor ? to make sure the client is happy with it.

? When in doubt, ask. This stuff seems baffling when you're just starting out, then seems complicated when you learn what all lies under the hood, then turns out to be really very simple once you dig down to the fundamentals. If you have questions about linear versus gamma (or what the hell, versus log), or sRGB versus Rec. 709, just ask. It's really not something to be scared of.

Re: OT: Gamma and linear light
March 21, 2010 05:22PM
This needs to go into the wiki.

I do have one question on gamma and CRTs. The gamma curve was a feature on CRTs, because it is an accurate reversal of human's reaction to light. But if we are shooting and compensating for the gamma curve on CRTs, how would that be a feature then?



www.strypesinpost.com
Re: OT: Gamma and linear light
March 21, 2010 05:26PM
There's also the "compression" element to gamma that actually makes 8bit video "work" without excessive posterization by suppling more code values to the shadows than the highlights in a perceptually relevant manner.

Graeme
Re: OT: Gamma and linear light
March 21, 2010 05:38PM
Quote

The gamma curve was a feature on CRTs, because it is an accurate reversal of human's reaction to light.

It's not a feature of the CRT. It's an inherent property of cathode-ray-tube technology. There's a range of possible input voltages, right? From zero (no light emitted) to just below too much (it's not quite exploding, but almost). If you ramp up the voltage applied to the tube linearly, the brightness of the light emitted by the screen goes up nonlinearly. It starts off gaining really slowly ? big changes in voltage create small changes in luminance ? but then takes off, so small changes in voltage result in big changes in luminance. That's just how, like, electrons work. And stuff.

When you point a video camera at something, your intent is for a television ? either immediately, or later when fed from videotape ? should reproduce the same overall contrast of the scene you're shooting. If you didn't do any gamma correction at all ? in other words, fed the television linear values ? then you'd get a picture that doesn't look at all right.

Here's an example. I happened to have some frames of scanned film laying around. They're 16-bit TIFFs, and encoded linearly. This is actually true of all TIFFs; the TIFF file format doesn't have any way of storing a gamma curve, really. There's a LUT, but ? bleh. Anyway, these are linear.

This is what an uncorrected frame from one of these sequences looks like:



Clicky the tiny to download a full-size, uncompressed screen shot.

Now here's the same frame after it's been passed through a Rec. 709 viewer LUT:



See the difference? The Rec. 709-corrected one looks right. Well, at least it matches the colorist's intent. The uncorrected linear one is way dark. If you use your imagination a bit, you can see how this relates to those gamma curves I posted up yonder. The linear image comes out through your monitor looking dark because your monitor is responding to input as the second gamma curve I posted. This one:



The bottom two-thirds of the input range comes out too dark, while the top third comes out too light. (EDIT: Eh, that was really carelessly said. In fact, the top third of the input curve comes out too contrasty. But whatever, it's not right, okay?) To correct this, Nuke applies a LUT that approximates this curve:



When the resulting values are sent to the monitor, they come out looking right, because the monitor itself is transforming them according to its built-in response curve.

In this example, Nuke itself is doing, in software, what the camera would have done if this frame had been shot with a video camera. The camera itself would have applied a reciprocal transformation that would have made the data technically wrong ? i.e., gamma encoded ? so it looks right when displayed on a monitor with a nonlinear response.

Make sense?

(Hi, Graeme! Got any cameras lying around that need a good home? I'll feed it fresh CF cards and play with it every day, I promise!)

Re: OT: Gamma and linear light
March 21, 2010 06:11PM
Quote

Gamma is your friend. Without it, television would look like ass on stale toast.

THAT needs to go into the WIKI? Really? I think if this pertinent information goes into the WIKI, it should be rewritten a little more clear. Some people might not understand Jeff's humor and this stuff is important IMHO.


...except for Mike...who prints our Jeff's posts as-is and sleeps with them.

When life gives you dilemmas...make dilemmanade.

Re: OT: Gamma and linear light
March 21, 2010 06:41PM
That was from Charles Poynton. I don't understand how it would be a feature if we ended up having to correct it (which we do for video). Or perhaps it means that the CRT displays with more sensitive to light changes in a certain spectrum of the curve? I'm grasping at straws.


Quote
http://www.poynton.com/notes/color/GammaFQA.html
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.



www.strypesinpost.com
Re: OT: Gamma and linear light
March 21, 2010 07:36PM
>The fact is that LCDs behave downright bizarrely in terms of their input-to-illumination curves

There's also the ICC profiling.

As computer screens do not respond to a gamma curve like a CRT/TV. ICC profiling was developed. Of course, all this is simulation, and for some reason, I've never been able satisfactorily calibrate certain non ACD monitors.

How it now works on a computer screen, is the computer monitor is calibrated and assigned a profile. Eg. On calibrating your Apple cinema display via the Apple calibration tool, your monitor will then be assigned a display profile (which is basically an LUT). Although FCP ignores the profile when it displays the image on the canvas, Adobe works with it.

A color management/linear workflow goes like this:

While working:
rec 709 source -> gamma compensation to linear -> linear workspace -> display profile

On Export:
Rec 709 source -> gamma compensation to linear -> linear workspace -> bake in 709 gamma -> output


This is quite similar to a film workflow, where you would bake in the LUT at the end, rather than work with a baked in LUT, as that would affect certain compositing modes.

Because the monitor no longer acts or behaves like a CRT, and all you have is a computer screen this workflow would be the next best option. But that said, it's only simulation.



www.strypesinpost.com
Re: OT: Gamma and linear light
March 21, 2010 07:55PM
Quote
Jeff Harrell
Anything that comes off a video camera will have the proper television gamma "baked into it." Anything that doesn't come from a video camera should be examined carefully in a known-good Rec. 709 environment ? such as on your broadcast monitor ? to make sure the client is happy with it.

I shot a sequence at night that was pitch black except for laser lights and a couple of beam lights. It was the first time I had put the Sony Z1U to such a test.

I was able to see everything on the camera LED monitor so I figured this is video, if I see it on the monitor it's there. Then I came home and captured the sequence on my G5 FCP 5.04 and looked at it on my old Sylvania CRT screens and everything was black. I panicked ...

Until I discovered the gamma filter. Wow, I said, and went ahead and played around with the gamma until I could see everything brightly. Well, by now you must know what happened, I had so much noise on the image that it looked really bad (like I had shot the whole movie on expired Ektachrome ER film LOL > my first student film, which I still have!)

Then I made a DVD to see the whole movie on my TV set and judge it as a whole... And it looked more terrible than what I saw on the CRT monitor. So guess what I did next? I logged on to LAFCPUG and I was laughed at. That's what I thought LAFCPUG stood for the first time I logged on here. LOL I've come a long way, baby!

So after I was told, "You can't judge your movie on that monitor!" etc, and Koz told me what kind of monitor I had to have, etc, I went back to my computer and "removed attributes" and threw the 3-Way CC filter on the sequence and I was able to correct the sequence a lot better. I learned to estimate the amount of correction I could add after I made several DVDs and looked at them at several different types of TV sets. Now I'm an expert on color correcting on my old Sylvania monitors (of course, once they go, I have to go back to school again:-)

So back to the gamma correction: I found out that there were those scenes that could better be corrected by the gamma filter!

And this is what I wish you would talk about a bit more, Jeff. When should one correct with the gamma filter and when not to? And to what extent one should use the gamma correction before it ends up on the proverbial piece of toast? LOL
Re: OT: Gamma and linear light
March 21, 2010 08:05PM
Color correction is a whole different topic, and beyond the scope of what I intended to talk about here.

Re: OT: Gamma and linear light
March 21, 2010 08:10PM
Jeff isn't talking about adding a "gamma" filter to footage as part of color correction. Rather, Jeff was explaining the gamma correction that occurs as part of calibration in the video system. This is usually an invisible process that is handled by the camera, software and the TV monitor.

It started with CRTs. CRTs naturally display images with a gamma curve. And although the sensors in the camera capture light in a linear fashion, that image has to be corrected before it hits the TV, or it will look dark. So to properly display that image on a TV, video cameras are designed to correct the gamma (actually it inverts the gamma curve of the CRT) on capture so the image will look perceptually linear when viewed.

Also, he's talking about importing stills/image sequences/RGB formats into FCP. As these formats may originate from computers, they may have a different gamma curve (or sometimes linear). FCP will then assume that the image is created with a certain gamma curve and compensate for it so that it looks "normal" on a TV. But because different PCs and Macs have different gamma settings, the image may end up looking brighter or darker. So to make those images look "normal", you define the gamma source on import.

This is all calibration.

The gamma correction filter has more to do with color correction than calibration (of course, you can use it to calibrate too).



www.strypesinpost.com
Re: OT: Gamma and linear light
March 21, 2010 08:27PM
Thank, strypes. It's funny that you replied on behalf of Jeff. No, no, I really appreciate it :-)

But gamma correction is gamma correction. Calibration of a monitor is for the purpose of screening a scene, isn't it? One doesn't calibrate the monitor to just enjoy looking at the color chart.

I would be willing to post a few frames to illustrate what I'm asking. Perhaps that might illicit a reply? Or perhaps not?

Let me know. Thanks.
Re: OT: Gamma and linear light
March 21, 2010 08:44PM
>Calibration of a monitor is for the purpose of screening a scene, isn't it?

If I get what you're saying, it's yes and no. Calibration standards exist so we can view everyone's works on the same TV without having to constantly adjust the settings for each film. If you're talking about a scene that you shot way too dark, as it has nothing to do with standard video calibration, that is another subject for another day.


In a nutshell:

object -> camera sensor (linear) -> gamma correction 0.45 (inverse of 2.2) -> recording tape ->editing machines -> TV display (gamma correction as part of design at gamma 2.2) -> linear perception of object (viewer)


In picture, from the Gamma FAQ:



That was 2002 and I believed he referred to CRT monitors on computers. Computer screens are generally more erratic and even more so on an LCD, hence the color profiling as part of monitor calibration in a Mac.



www.strypesinpost.com
Re: OT: Gamma and linear light
March 22, 2010 01:07AM
Thank you. I appreciate your going to all the trouble to clarify the calibration of Macs and PCs.

Quote
strypes
>Calibration of a monitor is for the purpose of screening a scene, isn't it?
<br>
If I get what you're saying, it's yes and no.

What's the yes part? In other words, what's the use of calibrating a monitor if you're not going to watch anything on it?

There is a Chinese proverb that goes like this: the purpose of knowledge is to apply it, not to express your ignorance.

The question is: when is using a gamma filter on a dark scene the best way to correct the exposure and when is the using the 3-Way Color Corrector the better way to color correct a scene?

You don't have to answer this question, strypes, because this was not a thread you started to talk about gamma; it was Jeff who decided we needed to know about gamma and linear light. I'll wait for another day as you suggested, that's fine. The new health care bill is going to extend our life span by at least twenty years. And as Jeff said, gamma is forever!

Though, it's wonderful knowing the theory behind how to calibrate CRT monitors now that they are becoming obsolete, because I can then describe it to someone else online when nobody else is there to do it justice.

Actually, if I remember correctly film has a much wider gamma!

By the way, the scenes that I shot came out beautiful. My Sony Z1U is a beautiful camera. I shot in pitch darkness, with only laser lights sometimes and fires -- everything came out beautiful. I was able to manipulate the 3-Way CC filter settings. That's a great filter!
Re: OT: Gamma and linear light
March 22, 2010 06:13AM
>Actually, if I remember correctly film has a much wider gamma!

Film has a wider latitude and is capable of storing more color information than most video formats. Gamma refers to the curvature of the light response.

>The question is: when is using a gamma filter on a dark scene the best way to correct the
>exposure and when is the using the 3-Way Color Corrector the better way to color correct a
>scene?

The 3 way color wheels in a grading machine controls lift, gamma and gain, or shadows, midtones, highlights, whichever you prefer to call it, as well as the color tonality of each of those regions. The point of these filters is to manipulate the shot and to grade for a "look". The gamma filter is a simplified filter that consists of only gamma adjustment.


>There is a Chinese proverb that goes like this: the purpose of knowledge is to apply it, not to
>express your ignorance.

Knowledge, yes. Jeff was explaining about gamma and calibration, and you're asking about color correction. They are two separate topics, if you have not realized. Let's not hijack the thread. Color correction is a very extensive topic, and enough books have been written on it to sink a battleship.



www.strypesinpost.com
Re: OT: Gamma and linear light
March 22, 2010 08:38AM
Thanks, strypes, you explained it. So there is gamma correction in the 3-Way CC filter also. This puts my mind at ease; I don't have to worry about using the gamma filter anymore.

It's like a lot of these actress pictures on the Internet show the girls pushing a wall. I kept thinking, "what's with the wall?" not realizing that the action is on the other end. LOL
Sorry, only registered users may post in this forum.

Click here to login

 


Google
  Web lafcpug.org

Web Hosting by HermosawaveHermosawave Internet


Recycle computers and electronics