Exposure and Contrast 4 - Exposure

- Home and Contact
- Photoshop by Numbers
- Picture Postcard Workflow
- Tutorials and Actions
- Portfolio

Exposure and Contrast adjustments part 4: Exposure

A word of warning

Exposure is the fourth and last of the exposure- and contrast-related adjustments. (The first three were Brightness/Contrast, Levels and Curves). At first sight, its control popup looks pretty simple: three sliders plus three eyedroppers for black, middle gray and white points. The only thing I had to do for this article is describe what each slider does, provide some simple examples and be done. So I thought. But Exposure is not straightforward at all.

First, a word of warning for those who seek simple guidelines to enhance their photos: this article won’t help you much further. What I write here is highly analytical. It’s all about arithmetic and mathematics. If you like that, read on. I provide a few formulas that I was unable to find anywhere else on the internet. Otherwise, you’d better jump to the conclusion or read some of my other stuff.

Math magic for dummies

Yes, there is quite a bit of math magic going on under the hood of this adjustment. So much that I had a hard time grasping the logic behind the controls just by experimenting. First, all three sliders have very drastic effects when moved more than just a small amount. Second, there seems to be very little white or black point protection. A careless move will likely clip highlights, shadows or both. (An exception to this is the Gamma slider – more about this later.) It’s not easy to deduce a simple mathematic formula or algorithm just from entering some straightforward values. What to do? How could I ever explain the adjustment’s mechanics if I wasn’t able to unravel them myself?

Textile factory

Of course, for cases like this Google and the World Wide Web can help. I think I found the clue to my confusion on the following web page:

https://www.dummies.com/software/adobe/photoshop/how-to-adjust-exposure-in-photoshop-cs6/

Photoshop for dummies! The author doesn’t spend many words on the three sliders. The first one mainly adjusts highlights, the second shadows and the third midtones. I think there is more to say than that, but a very interesting remark comes at the top of this page. Let me quote:

“The Exposure adjustment in Photoshop CS6 is primarily meant to correct tonal values of High Dynamic Range images, which are 32 bits. (…) You can apply Exposure adjustments to 16-bit or even 8-bit images, as well. This command works by using a linear color space, also known as gamma 1.0, rather than your image’s color space, to make tonal adjustments.”

That explains something. If the adjustment was designed to correct HDR, 32-bit images, it’s not strange that the logic is not evident for an unsuspecting dummy opening an 8-bit original and just fiddling around with the three sliders. I will discuss the implications of the 32-bit aspect later. First, let me try to make heads or tails out of the three sliders, in 8-bit mode that is. The remark about the 32-bit and linearity helped me to uncover the arithmetic.

Figure 1. An original image

A primer on bit depth, gamma and linearity

Before I continue, let me explain the basics of bit depth and gamma corrections. The rest of this article builds heavily on these concepts.

A digital image in Photoshop can be coded in three possible bit depths: 8, 16 or 32.

- 8-bit coding is the default for JPG, it’s also what your monitor understands. Every 8-bit coded pixel has a maximum value which we consider white, and a minimum value that we consider black.
- In 16-bit, more values are possible, but the luminosity range (from black to white) is the same. Working in 16-bit can prevent banding effects resulting from aggressive editing, but in normal, everyday work, you probably won’t notice the difference between an image coded in 8-bit and in 16-bit.
- 32-bit is fundamentally different. Black and white are just intermediate points on a practically infinite scale. Luminosities way darker than black are nothing special, as are values way lighter than white. 32-bit coding was designed for High Dynamic Range photography. The idea of this extreme luminosity range is that full shadow and highlight detail are preserved, no matter the extremes in the original scene. At some time, the retoucher has to squeeze these values into the 8-bit realm in order to make it visible on screen or in print, a process that is called tone mapping.

Gamma correction is a technique to make images look the way humans perceive the world around us. If we define white as luminosity 1 and black as luminosity 0, one might think that luminosity 0.5 is “half gray” – as if we're dealing with a linear scale. For a camera, this is indeed the case. In the human visual system, it’s not. Half the amount of light is perceived just somewhat darker than the full amount. If we display an image in a linear way, just like the camera captured it, it would look way too dark in our eyes. A gamma correction is the usual way to compensate for this: nothing more than a simple mathematical formula applied to the measured luminance values.

Gamma 1.0 is the uncorrected value, a fully linear relationship. The default gamma value of sRGB is 2.2. Other values certainly exist (one can freely convert an image from one gamma to another, or artificially assign a different gamma in order to make an image look different), but these are out of scope for this article.

Figure 2. Graph showing gamma 1.0 vs. gamma 2.2

One last remark to finish our primer: the default gamma value for 32-bit coding is 1.0. In other words, Photoshop considers HDR work a linear affair. Whether this is a Photoshop choice or a universal standard, I don’t know. For the scope of this article, I assume a 32-bit image to be coded in gamma 1.0.

Slider 1: Exposure

Back to the Exposure adjustment: let’s look at the Exposure slider. When I want to get a feeling of what an unknown adjustment does to an image, it helps to mimic the update in a curve. Apply the adjustment, sample some points and plot them into a Curves adjustment. So this is what I did:

- Open an image and duplicate it
- On the original, add an Exposure adjustment layer and apply Exposure: +1
- Sample enough points and see what the adjustment did to them
- On the duplicate, add a Curves adjustment layer and copy the results to build the curve

Figure 3. Exposure adjustment (left), Curve as described in the text (middle) and resulting image (right)

Voilà. Figure 3 shows Exposure adjustment, the constructed curve and the resulting image. Note the extreme clipping of highlights. The curve is a straight line hitting the top of the graph at about one third from the right. Whatever may be true of 32-bit logic and linear color space does not prevent us from writing a formula for this adjustment. When X is the original pixel value (given on a scale of 0 to 1), Y the result and E the entered value for Exposure, here is their relation:

NB. Why the min(imum)? Because in 8-bit mode, the maximum possible value of Y is 1. Where the inner part of the formula yields a value higher than that, the result must be reset to 1.

Note the 2.2 in the formula: the default gamma value of sRGB (and of my example image). For an Exposure value of 2.2, pixel values are simply doubled. Enter Exposure -2.2 and values are halved.

I think the observation that the Exposure slider mainly works on the highlights and less so on the shadows is correct, at least when working in 8-bit. See the curve of figure 3. The black point is well protected – the white point however is completely overridden.

Offset

Same trick? Why not. See figure 4: Offset + 0.1 (left), an approximation in a curve (middle) and resulting image (right).

Figure 4. Offset adjustment (left), approximation in a Curve (middle) and resulting image (right)

This time, it’s not so obvious what happens. From black to white, all pixels get lighter, but on the left side of the curve more so than on the right side. What sort of curve is this? A parabola? A hyperbola? For this move in particular, I needed the extra information that it was designed for “32-bit linear” in order to reverse-engineer the underlying formula. I will save you the details of that journey, but I am so proud of having found what I searched that I give you the full algorithm.

- Start with a pixel value in 8-bit RGB. This is a number between 0 and 255.
- Divide by 255, so the result is a number between 0 and 1.
- Convert gamma from 2.2 to 1.0. In mathematics, this means, raise to the power of 2.2.
- Add the Offset (in our example, 0.1).
- If the result is lower than 0 (this may happen for a negative Offset), make it 0. If higher than 1, make it 1.
- Convert back to gamma 2.2. In math: raise to the power of 1/2.2.
- Multiply by 255 to get back to the normal 0-255 scale.

Of course, I give you the formula as well. X is original value (between 0 and 1), Y the result, O the offset:

NB. If you don’t understand this formula, no problem. Just read on, you missed nothing important.

How about the statement that this adjustment affects shadows more than highlights? From the curve it’s true, and looking at the resulting image, it’s also true. But in a linear space, the move is equally strong everywhere. The effect occurs just because in gamma 2.2 shadows are more sensitive to adjustments than highlights.

Needless to say, black and white points are completely neglected by the Offset slider.

Gamma

The Gamma slider is the easiest to decipher, provided you haven’t skipped my quick explanation above. There is a simple formula, and I will give it here.

The slider works as though we work in a color space with gamma 1.0. Obviously, that’s not the case (the gamma of the image is still 2.2 as normal for sRGB), but we can pretend, can’t we? When moving the slider to a different value (G), the effect can be described as follows: if we started with gamma 1.0 and then changed the gamma to G, the image would look like this. The corresponding formula is as follows (again, X is the original value between 0 and 1, Y the result and G the gamma):

Here, I show the corresponding curve after having told you the formula. See figure 5 for G = 2.0.

Figure 5. Gamma adjustment (left), approximation in a Curve (middle) and resulting image (right)

As you can see from the graph, this slider indeed affects the midtones more than the extremes. Interestingly, anything fully black (RGB 0) or fully white (RGB 1) remains unchanged. This time, black and white points are respected.

The 32-bit magic

As Exposure was designed for 32-bit coded images, we will now have a look at what the sliders do for those. As you could expect, the formulas for 32-bit are a little different from their 8-bit counterparts – in fact, they are simpler. I provide them here without further explanation. X is the original (range 0-1), Y the adjusted pixel value, E exposure, O offset and G Gamma.

A few things I want to say about the 32-bit mechanics, and how they differ from what happens in 8-bit. I opened figure 1 in Photoshop, duplicated it and converted the copy to 32-bit. Despite this conversion, the two look exactly identical. Of course they do: without further adjustment, the pixels of the 32-bit version remain within the 8-bit range, the high-bit conversion doesn’t suddenly make it an HDR image.

- First, I watched the effect of each slider. More precisely, I applied the same Exposure change, Offset change and Gamma change to both versions of the image and visually compared the two. The outcome: only for a Gamma adjustment the results do not look quite equal (but not far off either), for Exposure and Offset they do.

Be aware that this is a somewhat misleading experiment. My monitor is only capable of 8-bit imaging. The 32-bit image must be internally converted to 8-bit before it can be shown on the screen. The next bullet covers what goes on under the hood of Photoshop. -
Looking at the actual arithmetic, working in 32-bit is definitely different from doing things in 8-bit. In 8-bit, black (0) and white (1 or 255) are hard bumpers. Subtract 0.5 from 0.3 and the result is 0 (black). Nothing can be darker than black or lighter than white. In 32-bit, there is no such limitation. The same subtraction yields -0.2 (something darker than black). The difference becomes apparent in consecutive adjustments, especially for the Offset slider. To illustrate this, I applied two Exposure adjustments. In one: Offset -0.2. In the other, Offset +0.2. Working in 8-bit, shadow detail is lost in the first adjustment, which the second cannot recover. In 32-bit, thanks to the extreme dynamic range, no detail is lost at all. The two adjustments cancel each other out.

The eyedroppers

It’s time to have a look at the eyedroppers – there is definitely something odd in their behavior. To show what happens, I started again from our example image (figure 1).

Figure 6. Left: original image with 3 eyedroppers. Right: corrected in Curves with midtone eyedropper only

Figure 6 is the same as figure 1, but with three eyedroppers (marked with red circle). Bottom left, the black, just left of the middle the white and bottom right the midtone. The image right is a Curves correction with the midtone eyedropper only. Note a small color move (taking away a slight green cast) but no perceptible luminosity shift.

Figure 7. Midtone eyedropper in Exposure applied in 8-bit (left) and in 32-bit (right)

The RGB read-outs of the third sample (red marked bottom right point in figure 6 left) are 128, 133, 125. If I click the midtone eyedropper on that very point, a slight color correction is supposed to happen, but no luminosity shift to speak of. In Curves, this is exactly what happens (figure 6 right). In Exposure, quite the contrary occurs: no color shift but a strong darkening. And moreover, in 8-bit the result is very different than in 32-bit.

That no color correction occurs is according to design. The Exposure eyedroppers are supposed to only fix luminosity and leave color alone. But we can't reasonably speak of a 'luminosity fix' in figure 7. The results are so absurd that they make me think we’re dealing with one (or more) Photoshop bugs.

The problem is indeed caused by the midtone (middle) eyedropper; the white and black eyedroppers have pretty normal behavior, whether in 8-bit or in 32-bit. Here is a simple experiment to conduct to isolate the issue.

- Create a new Photoshop document, 8-bit, and fill with 50% gray. This corresponds to RGB values of 128 each, or 0.502 on the 0-1 scale.
- Duplicate the file and convert the duplicate to 32-bit. The RGB values in the duplicate are now 0.216 each. That makes sense, because the gamma was converted from 2.2 to 1.0. Raise 0.5 to the power of 2.2 and you get 0.216. The gray looks identical in both versions.
- Now on both, add an Exposure adjustment layer and click the midtone eyedropper somewhere on the image.

- In the 8-bit version, RGB now change to 88 each, or 0.345 on a 0-1 scale.

- In the 32-bit version: RGB become 0.180, which corresponds to 0.46 in gamma 2.2.

See figure 8 for original and both corrections.

Figure 8. Original (left), corrected for midtone in 8-bit (middle) and in 32-bit (right).

None of these values make sense to me. Apparently, Photoshop thinks that:

- "Middle gray" as established by the eyedropper is something else than “50% gray” as set by the Color panel.
- Middle gray in 8-bit is considerably darker than middle gray in 32-bit.

Don’t ask me for the logic behind this: both conclusions seem incomprehensible to me. This is not magic, it’s just plain wrong.

An advice for you and another one for Adobe

Here is my advice. Don’t use the Exposure adjustment if you work in 8- or 16-bit. Its mechanics are unintuitive, unsophisticated and unprotective. It’s in one word: clumsy, guaranteed to give erratic results. It can ruin your image if you’re not careful. And it cannot do anything that Curves can’t do better.

If however you happen to work with 32-bit images, then go ahead, study the formulas, make sure to understand what each control does and do whatever you like with them. Avoid the midtone eyedropper though (see previous paragraph). By the way, Exposure is definitely not suitable for tone mapping. Use the HDR Toning adjustment for that. Or better, use dedicated HDR software.

Another advice, not for the retoucher but for Adobe. Why is this adjustment called Exposure? For anyone seeking to fix an exposure problem, this sounds like the obvious choice, right? Well, not so, see all the above observations. If the adjustment is designed for 32-bit HDR images, then please make that clear in the name. Call it “HDR Exposure” or whatever. A minimal effort for you, a meaningful improvement for the users of your product.

Gerald Bakker, 13 February 2021

Related articles

Photoshop by the Numbers

Copyright © 2015-2021 Gerald Bakker. All Rights Reserved.