Gamma & the Zone System

Some of the first posts on this blog of mine had to do with the Zone System and its application to digital imaging. In that regard, I also explored the origin of “18% gray” as being a middle gray density. I also reviewed the notion of gamma, especially in regard to the application of the concept of film gamma as it might be applied to the performance of a DSLR sensor. In this post, I have an update that relates to the notion of gamma as it applies to RGB color spaces, the L*a*b* color space, and gray gamma spaces for black and white image processing.

Just like the human ear has a non-linear response to sound intensity, the human eye has a non-linear response to light intensity. Here is an interesting question: Suppose you were to place a gradient of 10 boxes filled with shades of gray running from pure white to pure black on a piece of paper. What would the difference in those densities of gray have to be such that most observers would agree that the step sizes were equal? This question is bundled up with the notion of Ansel Adam’s Zone System which proposes to use almost exactly this model of tonal gradation from paper white to ink black in a print. More particularly, Adam’s Zone System establishes the central middle gray in this range to be at a reflectance of 18%.

This choice of reflectance is not immediately obvious. In other words, why should a gray with a reflectance of 18% be perceived as a mid-point between white and black? In experiments on visual perception, it’s been shown that a perception of equal step sizes is achieved when the reflectance increases in a certain proportion from step to step; that is, in a way that is not linear. Said another way, people perceive linear, equal reflectance increases when, in fact, those increases are not linear.

In fact, the appropriate sequence with which to build apparently even steps of neutral reflectance is by taking the ratio of the step numbers, say n/(n-1) raising this to a given power, and multiplying the previous reflectance by the result. It turns out that for human visual perception, the appropriate power to use is between 2.3 and 2.5. This number is often called gamma; and various values of gamma have been employed, and may be employed, in the management of tonal contrast.

Another, and simpler, approach is just to raise the step number to the power of gamma and normalize the maximum value to 100%.

The following table shows what results for reflectance when using gammas of 2.47, 2.2, and 1.8. Note that for this gamma value, the middle gray step corresponds to a reflectance of exactly 18% for gamma=2.47. For different values of gamma, the middle gray reflectance takes on different values.

Reflectance versus Gamma
Gamma/Step 0 1 2 3 4 5 6 7 8 9 10
2.47 0% .34% 1.9% 5.1% 10% 18% 28% 41% 58% 77% 100%
2.2 0% .63% 2.9% 7.1% 13% 22% 33% 46% 61% 79% 100%
1.8 0% 1.6% 5.5% 11% 19% 29% 40% 53% 67% 83% 100%

Color spaces like sRGB and AdobeRGB use gamma values of 2.2, for which middle gray becomes 21.7%. For ProPhotoRGB, which uses gamma 1.8, then middle gray becomes 28.7%. Generally, middle gray becomes a lower reflectance as gamma increases.

The choice of gamma is an important consideration for black and white photography. As may be guessed after inspecting the table, Ansel Adam’s Zone System is wrapped up with a gamma of 2.47 or so, and this is a higher value than is used for any commonly employed color space with the exception of L*a*b*, which effectively employs this gamma value. It is fairly common in doing B&W processing in Photoshop to convert to a gray gamma color space at some point, with “gray gamma 1.8” and “gray gamma 2.2” being common. A typical recommendation is that, if you are doing your color post processing in sRGB or AdobeRGB, you should convert to gray gamma 2.2 to ensure neutral B&W. On the other hand, if you’ve been working in ProPhotoRGB, the natural conversion choice is gray gamma 1.8. While there is no built-in “gray gamma 2.47” space, it is possible to create one as a custom profile.

It is interesting to return to this notion of equal neutral steps in various working spaces within Photoshop. In the following screen shots, I have created a blank document in the working space, filled the background with 50% gray (whatever that is), and built a sequence of neutral steps with L* values as shown: 0%, 10%, …, 100%. I’ve annotated the images with the results from sampling the RGB values for actual color from Photoshop’s Info panel.

Tonal steps in Gray Gamma 2.47 Space

Tonal steps in Gray Gamma 2.47 Space

At least on my monitor, using the built-in DigitalColorMeter app on my Mac, the L* values test very close to what Photoshop reports both for the Photoshop original, for the screen shot in PNG format, and in the way that Safari shows the image above as delivered from the server. I can’t make any claims about how this will look on other monitors out on the tubes of the Internet (TOIT).

Now, if I assign this image into gray gamma 2.2, I get the following screen shot. At a minimum, it should be apparent that the middle gray (including the background) has shifted to a lighter tone. I have annotated the image to show the resulting changes in L* and RGB values taken from the Photoshop Info panel.

Tonal steps for Gray Gamma 2.2

Tonal steps for Gray Gamma 2.2

If, instead, I assign to gray gamma 1.8, I get this next result; and again, I’ve updated the annotations to show the modified L* and RGB values.

Tonal steps in Gray Gamma 1.8 Space

Tonal steps in Gray Gamma 1.8 Space

For these last two screen shots, it should again be apparent that the middle gray tone has become lighter, as the gamma of the space has been decreased. More particularly, the entire sequence of tonal values becomes brighter as gamma is decreased. While I won’t show the screen shot here, please accept my word (or repeat this experiment yourself), that the screen shot looks identical when this is done in the L*a*b* color space in Photoshop.

This process of assigning the equal tonal steps into other gray gamma spaces results in unequal changes in luminosity (or density).

The results appear quite different if this process is repeated in RGB color spaces. Here is what we get if this is set up in an RGB color space with gamma of 2.47:

Tonal steps in RGB Gamma 2.47 Space

Tonal steps in RGB Gamma 2.47 Space

Interestingly enough, this is the first time we’ve seen RGB values of 128 correspond to L*=50 and a background fill of 50% gray. If, instead, we set this up in sRGB, with a gamma of 2.2, we get the following:

Tonal steps in sRGB  Space

Tonal steps in sRGB Space

My guess is, that if you’re looking at this on a reasonably new Mac with Safari or Firefox, this last image may be the first one in which you could use your DigitalColorMeter app and read RGB values of near 128 for the middle gray value. Since I’ve been using PNG files for these embedded images, this sRGB color space example is likely to hit middle gray accurately on most screens, whether they’re color managed browsers like Safari or Firefox, on not, like most instances of Internet Explorer at the time I’m writing this.

OK. So, I’ve dumped a fair amount of data embedded in the images I’ve attached here thus far. What does it all mean?

Well, here’s a summary:

  1. Middle gray has an 18% density in L*a*b* and with gamma at 2.47.
  2. A custom RGB space with gamma 2.47 matches the L* settings of the L*a*b* color space. No other commonly used space does this.
  3. Assigning equal luminosity steps from either L*a*b* or a gamma 2.47 space to any other space produces unequal luminosity steps.
  4. Converting or creating equal luminosity steps in a space with a gamma other than 2.47 produces a middle gray that does not have RGB values of 128. This only works out in an RGB space with gamma 2.47.

What’s so great about any of this? Well, if you begin with the assumption that the equal luminosity steps of L* in the L*a*b* color space are correct; that is, they would be a linear tonal scale as perceived by most human viewers, then one might care to discover what gray and RGB spaces most closely approximated this behavior. Another relatively simple observation is that gamma encoding should match gamma decoding. This is what is happening with our oddball assignments. We see inconsistent values either in luminosity or RGB when we assign images between spaces with different gamma values.

A related aspect of these gamma games would be the gamma setting of the monitor that you or I might use to view the images. An extremely common gamma value for monitors is 2.2, as is used in sRGB, and as is assumed in most untagged RGB files employed on the Internet. If and only if the gamma for your monitor matches the gamma of your working color space will the gamma encoding and gamma decoding of your post processing environment give you a linear display of any image’s tone curve. This is an extremely important point.

Let’s speak to this a bit more. Assume you’ve calibrated your monitor, like most recommendations, for gamma 2.2 and 6500K. Then assume your working space is AdobeRGB. Now, your monitor’s tone curve matches your working space’s tone curve. Your mid-gray is internally around 22%, and your RAW converter may tend to assign its mid-grays to that somewhat lighter point than you might intend. Of course, if you color correct properly, this should be no big deal.

Let’s take another case, assume you calibrate your monitor as before, but you like to work in that big gamut color space, ProPhotoRGB, which has a gamma of 1.8. Now, the gamma encoding of your images and the gamma decoding of your monitor do not match up. You might also have some RAW conversion issues, but again, proper color correction handles those shifts easily. The main problem is that you may not be seeing a linear presentation of the tone curve of your working files.

Let me say that again: match the gamma curve of your monitor calibration to the gamma curve of your working space.

Now, one could also calibrate one’s monitor to L-star. This can be done with, for example, DataColor’s Spyder3Elite. Then, you could create a custom profile with gamma 2.47 and work within that space. In this way, you also get a tone curve that more closely approximates human perception. However, this approach tends to bend the natural gamma curve of the monitor in most cases.

In fact, here is what may be an even better policy. Calibrate your monitor for native gamma and native white. It turns out for my monitor, native gamma is 2.3. Then go ahead and select ProPhoto as a starting point, and create a custom RGB space with ProPhoto primaries, your monitor’s native white point, and your monitor’s native gamma. For a working gray space, for B&W, go ahead and create a gray space with your monitor’s native gamma as well.

Here’s a screen shot of such a setup:

Setting up a custom gamma RGB space

Setting up a custom gamma RGB space

If you create such a custom space, you don’t save it by hitting the obvious “Save…” button. Instead, you open up the RGB space listing and selecting the Save RGB option near the top:

Saving a custom RGB color space

Saving a custom RGB color space

So, what’s the benny for this? Well, at least in my case, on my system calibrated in this fashion and with this working profile, this is the set of values I get for working in my native RGB color space:

Tonal values in a native gamma (2.3) color space

Tonal values in a native gamma (2.3) color space

The value of this is just that the screen RGB values on my monitor are identical to what Photoshop has to within a point or two right across this entire span as I can verify with the DigitalColorMeter app. Now, of course, I have to convert back to sRGB or whatever in order to push any final image to the web. But, I have a system in which the gamma curve of my monitor and the gamma curve of my working space match, and the calibration curves within the look-up tables have to make minimal adjustments to the native behavior of my screen.

Which is cool, I think.

It might be worth tossing up a graph of both the gamma 2.5 curve and the L* curve at this point, just for comparison. Although the L* curve is not strictly a “gamma” curve, it is so close to gamma 2.5 as to not make much of a difference. The gamma 2.47 value I was using earlier gets the middle gray, arguably, a touch closer to 18% nominally. This is a bit of a numerical quibble only.

Gamma 2.5 and L-star

Gamma 2.5 and L-star

Note that the middle gray value on the x-axis at 0.5 corresponds to a y-value of about 18% in both cases. Lower values of gamma more closely approximate a simple straight line between 0 and 1; hence, as gamma is decreased from the 2.5 shown here, the y-value increases towards the value of 0.5 that it would have with a gamma of exactly 1.

This is apparently the curve implicit in the Zone System… which might make it worthy of interest in its own right.

4 Comments

  1. Wow, fantastic writeup! I’m certainly going to explore this in more depth. Glad to hear someone else preaching native white point & gamma settings for displays but I’ve never heard the rationale behind it. Thanks for the time and research invested in this.

  2. Thank you for the visual chart of Reflectance versus Gamma, this helps me a lot!!

  3. Sungeetha

    thank you, it was very informative.

    i am little confused. does Gamma always needs to be corrected in post processing cant it be done incamera?

    does shooting in RAW will capture the Gamma as our eyes preceive….

    reading your article, so if we want to achieve Gamma of 2.2 the middle gray expsoure component has to be manipulated in the camera for a better exposure am i right?

    kindly correct my understanding.

  4. Sungeetha, I guess I’d start my reply to you by noting that the way the sensor in a DSLR works is extremely different than the way in which our eyes work. Whether you shoot in RAW or not, the behavior of the sensor is identical; you might think about it this way: the sensor is shooting in RAW even if that’s not the way you set your camera. The difference between shooting RAW or, say, JPG, is just that the conversion from RAW to JPG is done in the camera by its electronics in the latter case. If you shoot RAW, then you get to decide what conversions to apply in your workflow; and you can experiment with different approaches. That last ability, experimentation, is gone, if you freeze the image into a single conversion in camera.

    Now, back to the difference between sensor and human eye: In the sensor, at any given exposure setting, there is some intensity of light that will fill up the pixel buckets to a 100% level. This is pure white. Exactly 1/2 of this intensity, which is exactly 1/2 the count of photons, will fill up the pixel buckets to a 50% level. In other words, the sensor’s pixels are almost perfectly linear; their response to light is in direct proportion to its intensity. This linearity is true at least over a wide range of light intensities. Of course, there are limits. You can’t put in more than 100% of a pixel’s capacity and you can’t get less than 0%. And if you wait around for a long exposure, some of the pixel’s contents will “leak” out; but we can ignore those issues for now.

    In contrast, human visual perception is inherently non-linear. You can think about this in terms of small steps or changes in intensity or in terms of the overall response to big changes. If a person is looking at a scene to which their eyes have properly adapted (like getting exposure right in a camera) then the neural response to a part of the scene that is providing 50% of the intensity of the brightest part of the scene (assuming that’s 100% for now) is not 50% it is instead 18%! The details of how that works is given in the article, and you can also look them up in Wikipedia and elsewhere on the Internet. The last graph in my article demonstrates this response as well.

    Our response to sound is similar in this respect to our response to light; that is, non-linear. In the case of sound, this is the origin of the deciBel (dB) scale. On the average, a 1 dB change in sound intensity is just perceptible. A 3 dB change doubles the sound intensity. Using the same language for sound as for light, we’d say the dB scale has a gamma of 2. No one says that, but it’s the same idea.

    Why would our vision and hearing have adapted to have this non-linear character? Probably because the intensity of light and sound falls off as the square of the distance from the source. If you move towards a source of light or sound and halve the distance between it and you, then the intensity is now 4 times as great. So, a non-linear response prevents us from becoming blinded by a light or deafened by a sound as we approach its source. At least, that seems to be a reasonable explanation.

    Digital cameras though are not the result of biological adaptation. They are just artifacts of human design, and they behave in accordance with certain rules of quantum mechanics in how likely it is for a photon to produce an electron in a semiconductor. I suppose if a camera designer decided to try to copy the non-linear response of the human eye in a camera, they could do so; but no one has tried this to my knowledge. Who knows? This may be happening somewhere.

    So, shooting in RAW does not capture gamma as our eyes perceive it; however, it does give you the option to treat the data from your camera’s sensor in this way in your workflow. My article here, and others, teach how to do this if you wish.

    The question of how to set exposure properly for a DSLR goes beyond just getting middle gray right. Generally speaking, the worst scenario for a DSLR is blowing out the highlights; that is, getting the brightest parts of the scene to overload the corresponding pixels in the sensor. It is quite possible to set the exposure in a DSLR so that an object in the scene with a perfect 18% reflectance is exposed at an 18% level on the sensor; but the brightest element in the scene, say a cloud in the sky, can easily turn out to be bright enough to over-expose its pixels. This is because there are only about 2 and 2/3rd stops of exposure between 18% and 100% (18% -> 36% -> 72% -> 144%, in stops of light). To avoid this issue, cameras from Canon and Nikon add some small amount of compensation and attempt to expose a true 18% reflectance element (say, a gray card) at something less by 1/3 to 1/2 stop; but this is really a minimal amount of compensation.

    So, people say, “expose to the right” meaning set up your camera so that the highlights are not blown out. Under almost any circumstance, this will get the exposure for middle gray just dead wrong; it will be too dark. No resetting of gamma in post processing can correct for this. You have to do something much more dramatic to get middle gray back.

    This was not so huge a problem in Ansel Adams’ day since people used film then. Film was also non-linear and one could very frequently set the exposure properly for middle gray and still not blow out the highlights. If the range of light in a scene was such that the highlights would become overexposed, then one could underexpose the scene and compensate for that in development. Adams’ writings are explicit in telling how to manage situations like this in handling the negative and the print.

    With digital post processing, one can achieve effects like Adams taught for negative and print and much more by applying certain compensations to the “curve” in post processing. Let’s say you’ve captured a scene in which the brightest elements were 4 stops over middle gray. Say the scene was outdoors and some bright clouds were basically specular highlights relative to parts of the scene you were trying to capture. So, you exposed for these highlights and now true middle gray is about 1 and 1/3 stops too dark. So, drag up that part of the curve in post processing to lighten the mid-tones by exactly the correct amount. This will yield, if done properly, exactly that kind of non-linear behavior that film had in Adams’ day.

    The good news is that a modern professional or semi-pro DSLR has much more range than the combination of film and print that Adams had by as much as 4 stops or more. So, if you do this right, you can capture much more information properly than someone like Ansel Adams could. You do have to keep track of just how much of an offset in exposure you had to set in to the camera in order to get your shot; that is, how far off you’ve pushed true middle gray in exposing for highlights. But you can write that down, you can remember it, you can do it with an EV setting, and some cameras let you make notes like this now.

    This is by way of answering your last question about manipulation in camera. To summarize, if you expose to get the highlights right, especially in a daytime landscape scene, you’ll almost always get middle gray too dark. Almost the only time you can get middle gray right without blowing highlights is in studio shots where you are in complete control of lighting, and even this won’t be true if the subject is metallic or otherwise has specular highlights, say, a car or motorcycle or glass object. Even if you use bracketed exposures and put them together with HDR methods, this will not guarantee getting middle gray right.

    The point is that the range of light between a true middle gray object (18% reflectance) and the brightest element in a scene is defined by the scene itself. In a studio, it might be 2 and 2/3rds stops (because you made it that way) but in general, this will almost never be true. So, a camera cannot get the range of light in the same proportion as our eyes in this general way. You have to compensate for the camera’s limitations in order to achieve anything like the same impact as the scene would have had upon a human viewer.

    In part, this was the idea behind the Zone System, to get an image that had the same visual impact as the original scene, or better. Sometimes this involves a compression of the original range of light, sometimes the range of light is exactly right for the final print, and sometimes the range of light must be expanded. In the Zone System, whatever one might have to do to get the range of light in the scene to match the range of light in the final print (or now digital image on the web, let’s say), one wants to get one point from the original scene to match one point in the final print; namely, middle gray. That is the touch-stone.

    I know that this is a reply about as long as a post. I hope that it isn’t too confusing a response to your simple questions, but your questions turn out not to be that simple. Perhaps I’ll try to add another post to deal with some of these ideas directly.

Leave a Reply