Belmont 16 ft sailing club, photographic club

LEVELS

This brief tutorial explains the basic concepts behind Levels adjustments in image editing programs such as Photoshop.

This tutorial was prepared by Roy Killen and is copyright. It is part of the supplementary training materials for members of the Belmont 16 Ft Photographic Club and is not intended as a complete, stand-alone instruction package.

Comments and suggestions on this tutorial are welcome - they should be emailed to Roy Killen.

 

NOTE: There are two ways of applying adjustments (such as bightness/contrast adjustments) in Photoshop. One way is via the Image>Adjustments selection from the menu - this is referred to as a "static" adjustment because it makes permanent changes to the pixels in the image. Static adjustments cannot be reversed or modified. The other approach is to make "dynamic" adjustments by creating adjustment layers. Dynamic adjustments can be reversed, or altered or disabled at any time (unless you flatten the layers). This tutorial describes static Levels adjustments to demonstrate the principles that can be applied in any image editing program (even those that do not allow for the use of layers). The use of adjustment layers is described in another tutorial.

 

SOME TERMINOLOGY

Before we start investigating how to make Levels adjustment it is useful to define a few terms:

Luminance: The intensity of light. (If no light is being emitted by a pixel it wil be black,if maximum light is being emitted by a pixel it wil be white).

Brightness: The apparent luminance of pixels in an image. The perceived brightness of a particular pixel will be influenced by the luminance of the pixels surrounding it. This is demonstrated in the following image - the two circles have the same luminnce (intensity of light) but the one surrounded by black appears to be brighter than th eone surrounded by white.

 

Contrast: The difference in brightness between the lightest and darkest parts of an image.

The following images show the effect of (a) keeping the contrast the same but varying the brightness, and (b) keeping the brightness the same but varying the contrast.

 

Low brightness

 

High brightness

 

Low contrast

 

High contrast

 

What is "Levels Adjustment"?

In every digital image there are both dark and light pixels. Levels adjustments are one way of altering the luminance values (apparent brightness) of the pixels.

 

If you open an image in Photoshop and then use the menu to select Image>Adjustment>Levels (as shown on the right) a levels dialogue box will be displayed and this enables you to make tonal adjustments on the image.

 

levels-adjustment

The Levels dialogue box

1. The main feature of the Levels dialogue is a graph or HISTOGRAM. It is explained below.

2. Just below the histogram, at the left-hand end, there is a small triangle and below this is a small box with a "0" in it. This triangle is called the INPUT SHADOWS SLIDER.

3. At the right-hand end there is a small triangle above a box that has "255" in it. This triangle is called the INPUT HIGHLIGHTS SLIDER.

4. Below the centre of the histogram there is a small arrow above a box with "1.00" in it. This triangle is called the GAMMA SLIDER. (Gamma in this context simply means the relative brightness of the shadows and highlights in the image.)

For now, don't worry about anything else in this dialogue box. - we will come back to these things later.

The histogram that is displayed in this example for the following image:

 

What does the histogram represent?

The histogram represents the luminance (brightness) levels of the pixels in the image. It tells you how many pixels there are at each of the possible levels of luminance in the image. The "peaks" in the histogram indicate that there are lots of pixels at those luminance levels, the flat areas indicate that there are very few pixels at those luminance levels. Let's look at this in more detail.

1. The horizontal axis of the histogram is divided into 256 discrete steps or "levels" of luminance. (You can't actually see these divisions but they are there.)

"O" on this scale represents total BLACK.

"255" on this scale represents total WHITE.

"128" on this scale represents MID-GREY.

2. The vertical axis represents relative magnitudes of each of the 256 different levels of luminance. The higher the histogram at any particular luminance level the more pixels there are in the image with this level of brightness. For example, in the image above the highest "peak" on the histogram occurs at approximately 220 on the scale and this peak corresponds to the white stripes on the guard house and the white shirt. The second peak from the right is at approximately 150 on the scale and this corresponds to the grey stripes on the guardhouse. The second peak from the left is at about 80 on the scale and this corresponds to the blue uniform (it is the luminance that is important in determining where this peak occurs, not the colour). The broad left-hand peak is centred on about 30 on the scale and this corresponds to the grey background behind the guard's cap.

You will notice that there is very litle information in this histogram below about 10 on the scale. This is because there are very few pixels in this image that are near total black. There is also very little information in the histogram above aboout 230 because there are very few pixels in this image that are near total white.

 

 

 

Let's see what happens if we click on one of the triangles below the histogram in the levels dialogue box and drag it horizontally.

NOTE: The adjustments that follow are NOT meant to improve the image in this example - they are just illustrating how and why levels adjustments can change the appearance of an image.

 

First I will adjust the INPUT SHADOWS SLIDER - by clicking on it and dragging it to the right.

 

In the above example I dragged the left-hand arrow towards the right until the number below it changed from "0" to "25". (There is nothing magic about the "25", I am just illustrating a change. The same applies in the next three adjustment examples.)

This had the effect of slightly darkening the image. We will see why a bit later.

Next I returned the input shadows slider to its original position and then dragged the INPUT HIGHLIGHTS SLIDER to the left.

 

In this example I dragged the right-hand arrow towards the left until the number below it changed from "255" to "220".

This had the effect of slightly lightening the image. We will see why a bit later.

I then returned the input highlight slider to its original position and altered the position of the central ("Gamma") slider.

In this example I dragged the centre arrow towards the left until the number below it changed from "1.0" to "1.3".

This had the effect of slightly lightening the image. It looks different from the "lightened" image created by moving the input highlights slider (see image above) because it has less contrast. We will see why a bit later.

Next I dragged the centre arrow towards the right until the number below it changed from "1.0" to "0.70".

This had the effect of slightly darkening the image. It looks different from the previous "darkened" image (created by moving the input shadows slider) because it has more contrast. We will see why a bit later.

Now let's see WHY THESE CHANGES ARE HAPPENING TO THE IMAGE when we move the sliders.

The input shadows (left-hand) slider

The position of this slider determines what level of luminance in the original image will be forced to be the new "black" (0 luminance) in the adjusted image. So when we move the input shadows slider we say that we are changing the "black point".

For example, if this slider is moved to the right so that it is at "25" then any pixels in the original image whose luminance level is 25 or less will be forced to have a luminance level of "0" in the adjusted image.

That's why, earlier in this tutorial, moving this slider to the "25" position caused the image to darken slightly. The shadow areas behind the guard became darker (as you might expect because that area contained the darkest parts of the image).

Other areas of the image (such as the guard's face) also darkened slightly. This is becasue when we force the bottom part of the histogram (everything below 25 in this case) to be zero the remaining pixel levels are redistributed across the "new" full 0-255 range.

The histogram in the levels dialogue box does not change because this is always the "input" or starting histogram but you can see the effect if you display the histogram palette in photoshop. This is what happens:

 

Notice that the left-hand end of the histogram has been forced up against the left-hand boundary of the histogram (creating a "spike" at level "0").

The rest of the histogram has been "stretched" with the left-hand part of it (representing the darker tones) being distorted more than the right-hand end.

The gaps that now appear in the histogram indicate that there are now some discrete luminance levels for which there are no pixels in the image. This is because there were originally 256 luminance levels but that has been reduced to 231. The "missing" 25 levels have been spread evenly across the tonal range.

Note: If you make very drastic changes with the levels adjustment sliders you will creat large "gaps" in the histogram and this can cause uneven "banding" between tonal ranges (rather than smooth changes). This effect is called posterisation and it can be very noticeable when you print an image that has large areas with little detail (such as the sky).

 

The input highlights (right-hand) slider

The position of this slider determines what level of luminance in the original image will be forced to be the new "white" (255 level) in the adjusted image. This change is called a "white point adjustment".

For example, if this slider is moved to the left so that it is at "220" (just to the right of the right hand peak in this example image) then any pixels whose luminance level is 220 or more will be forced to have a luminance level of "255". That's why, earlier in this tutorial, moving this slider to the "220" position caused the image to lighten slightly.The histogram changes as follows:

 

 

The histogram of the adjusted image shows that the right-hand end of the histogram has been forced up against the right-hand boundary (creating a "spike" at "255").

The areas of the image that were already bright (the white stripes on the guard house and the guard's shirt) have been made brighter as you would expect. Again the remaining pixels have been "stretched to cover the full range from 0 to 255 in the adjusted image so there is some overall brightening of the image.

Again, gaps appear in the histogram to indicate that there are now some discrete luminance levels for which there are no pixels. There were originally 256 luminance levels but that has been reduced 221. The "missing" 35 levels have been spread evenly across the tonal range.

 

The gamma (mid-tone) slider

The central slider below the histogram can be moved either to the left or the right. Whatever luminance value it is moved to is forced to become a luminance value of 128 (the mid tone).

Moving the mid-tone slider does not alter the two end points of the histogram. Whatever value was previously the darkest luminance remains the darklest luminance. Whatever value was previously the lightest luminance remains the lightest luminance.

 

 

Moving the slider to the LEFT lightens the image and reduces its contrast. You can see on the histogram that this occurs because some luminance levels from the left-hand half of the histogram are being removed and some of the luminance levels at the right-hand end of the histogram are being boosted (because there are now fewer pixels with brightness levels between 0 and 128 and more pixels with brightness levels between 128 and 255). The pixels at the level corresponding to the position of the gamma slider (that were originally darker than 128) have been forced to become the new 128 level.

Moving the slider to the RIGHT darkens the image and increases its contrast. You can see on the histogram that this occurs because some luminance levels from the left-hand half of the histogram are being boosted (there are now more pixels with luminance levels between 0 and 128) and some of the luminance levels at the right-hand end of the histogram have been removed. The pixels at the level corresponding to the position of the gamma slider (that were originally lighter than 128) have been forced to become the new 128 level.

 

ADJUSTING LEVELS TO IMPROVE TOTAL RANGE

The difference between the luminance of the darkest pixel and the luminance of the lightest Pixel is called the TONAL RANGE of the image. An image in which the darkest pixel is pure black and the lightest pixel is pure white is said to have a FULL TONAL RANGE.

Images that have a limited tonal range often look dull and lack contrast, as shown below - the image on the right has a full tonal range, the one on the left does not. Generally, an image looks better when it has a full tonal range - from black to white. That is, when there is luminance information from 0 to 255 on the histogram. (Sometimes you might deliberatley want to create an image with limited tonal range - but that's a story for another tutorial.)

 

 

The tonal range of an image can be altered with the Levels adjustment.

We saw in the histograms above that for the sample image (the guard) there is very little (if any) luminance information towards each end of the histogram - because nothing in the original image was totally black and nothing was totally white.

If we drag the shadows and highlights input sliders "inwards" until they are just at either end of the histogram (where the tonal information in the image starts) we can redefine the tonal distribution for the image. We can force the darkest part of the image to be black and we can force the lightest part of the image to be white. For our sample image (the guard) this might give the following adjustments:

 

 

These adjustments would do the following:
1. Force all pixels in the image whose input luminance levels were 13 or less to become black (0 level).
2. Force all pixels in the image whose input luminance levels were 236 or higher to become white (255 level).

This would give us the result we wanted (maximising the tonal range of the image) provided the levels of 13 and 236 were "accurate". There is a better way of achieving this than simply "guessing" as you move the input sliders. It is called "turning on the THRESHOLD display". Here is what to do:

As you drag the input shadows slider hold down the SHIFT key and the ALT key. This gives you the THRESHOLD display.

Initially, the image will probably go totally white. As you move the input shadows slider to the right you will start to see small parts of the image. They will be in different colours that indicate the channels (red, green, blue or combinations of them) that are clipping. These coloured areas indicate the pixels that are being forced to level 0. The further you move the slider to the right the more pixels are forced to level 0. The following screen shot illustrates the type of THRESHOLD display that you will see.

 

This particular threshold display is the result of moving the input shadows slider to "26" on the guard image histogram.

In this screenshot, all the pixels that are clipping (being forced to 0) are shown as black. (This is a minor problem with the way I am capturing the screen shots.) When you do this adjustment you should see colours. For example, if the clipping is only in the blue channel you will see blue areas on your screen; if clipping is occurring in both the blue and green channels you will see cyan areas on your screen; and so on.

If you take this adjustment too far, you will lose detail in the shadows. For this sample image, the first signs of clipping occurred when the input shadows slider was moved to "6" rather than "13' which had been my guess from just looking at the histogram.

If you hold down the Shift and ALT keys as you move the input highlights slider to the left you will initially see a black screen and then coloured areas will appear to indicate the pixels for which each of the colour channels is being forced to a brightness less of 255. The type of threshold display you will see is shown below.

 

 

This particular threshold display is the result of moving the input highlights slider to "236".

In this screenshot, all the pixels that are clipping (being forced to 255) are shown as white. When you do this adjustment you should see colours. For example, if the clipping is only in the blue channel you will see blue areas on your screen; if clipping is occurring in both the blue and green channels you will see cyan areas on your screen; and so on.

If you take this adjustment too far, you will lose detail in the highlights. For this sample image, the first signs of clipping occurred when the input highlights slider was moved to "240" which was very close to my guess (of 236) from just looking at the histogram.

 

Adjusting the input gamma slider

We saw above that you can use the threshold display to show the precise points at which you will get shadows or highlight clipping when you move the input shadows slider or the input highlights slider. There is no such way of determining where best to set the mid-point slider (the input gamma slider). You have to make this adjustment to suit your individual preference. Moving the slider to the left will give you a lighter image with less contrast. Moving it to the right will give you a darker image with more contrast.

Moving the mid-point slider does not alter the settings of fhe two end-point sliders - so it makes no difference to the overall tonal range of the image.

The example below shows how an image can be transformed by doing nothiing more than adjusting the shadows/highlights/gamma sliders guided by the threshold displays as explained above. The original image is on the left.

 

 

MENU OR ADJUSTMENT LAYER

All of the adjustments described above can be achieved by selecting IMAGE>ADJUSTMENTS>LEVELS from the Photoshop menu. However, this is NOT a good idea because the changes you make in this way are not reversible - once you close the levels dialogue box the changes are made to the image and they cannot be modified later. You can "undo" the changes in the usual ways (including via the history palette) but you cannot reopen the levels dialogue box and make further adjusments from where you left off when you closed the levels dialogue box. This can be quite inconvenient.

A far better approach is to create a levels adjustment layer - this will allow you to re-open the levels dialogue box and fine tune your levels adjustments if you find this necessary later in your work on the image. Adjustment layers are described in another tutorial.

 

Is "Levels" the only way?

In versions of Photoshop before CS3 it was often useful to make "levels" adjustments to set the overall tonal range of the image and then make "curves" adjustments to achieve the desired contrast and colour. One of the reasons for doing this (levels and then curves) was that the curves dialogue did not display a histogram. This changed in Photoshop CS3 - the curves dialogue now has a histogram. This means that if you are using Photoshop CS3 (or later) you can achieve all the adjustments that are possible with levels (and then a lot more) by going directly to the curves adjustment. Curves adjustments are desribed in another tutorial.

Return to top of page OR View other tutorials

All images on this site and all documents and tutorials linked to this site are copyright.

This page last updated 15th May 2009 (RK)