Levels

Image -> Adjust -> Levels...

The Levels dialog displays Histogram, Tone Curves and allows you to change the level values.

Histogram

The Histogram (graph on the left) displays the tonal distribution of the image. It displays values based on their level of brightness, on the x axis from dark (0) to light (255). The y axis represents the total number of pixels in the image with that level of brightness. You can see Histogram for all RGB image parts or for R, G, or B separately. Also you can see only the intensity histogram. (Which merge the RGB to one graph)


The Tone Curve (graph on right) represent the mapping of input tones to output tones. The default curve is an linear upward line. It represents the relationship between the image before and the image after correction. On the x axis are the levels from 0 to 255 of the image before correction, on the y axis are levels after correction. Obviously if the curve is linear from bottom left to top right (as on the image above) there are no changes - the input levels are mapped 1:1 to output levels.

What Histogram shows

Histogram can tell you many things about the image, about the processing already done on the image and also about the device (digital camera, scanner ...etc). First look at the x axis. This represent the dynamic range 0-255 (dark-light). The wider is the histogram , the better is the dynamic range and that means also image with better contrast.

Dull Image 

 
Narrow histogram - small dynamic range means low contrast and flat image

Normal Image 

 
Wide histogram, great dynamic range means also good contrast
Low Key: If the histogram has the peaks concentrated along the left side of the graph we call this low key image. Depending on the image it can also mean underexposed image.
High Key: If the peaks are concentrated on the right side, the image is called high key. This could also mean overexposed or too bright image. Note: most of the digital cameras underexpose, you will have more pictures with low key than high key.
Tone jumps: If the histogram has an empty spaces in intervals, this means a lack of smooth gradation. This usually tells that the image was already processed. (It was stretched to full dynamic range, or there was a color reduction, gamma correction or other adjustments applied.)

Normal Image
 
 
The histogram is mostly uniform, the image covers most of the dynamic range.

 Low key
 
Most of the colors are in dark

 High Key
 
Most of the colors are in the brights.

 Tone Jumps
 
The detailed histogram shows that the image brightness was already stretched, there are Tone Jumps in regular intervals.
There are many other things what histogram can tell you - you will learn the art of it as you work with many images.

Adjusting Levels

There are 2 sets of controls: Input and Output. The Input control has Min, Max and Gamma, where the output Control has only Min and Max. You can either type directly numbers or move the handles on the multiple slider control.


How it works:
You are mapping the brightness of RGB channels (or any channel separate) from input to output. As you move the sliders the Tone Curve graph changes as well. You can change values on the RGB together, or you can chose any channel separate to change its levels. After you change channel R for example you can select channel B and make additional changes.

The Input Min slider adjust the shadow areas - moving it to right the shadows become darker.
The Input Max slider adjust highlights. Sliding it to the left, light areas become lighter.

The Output Min adjust the dark areas. Moving it to the right the dark areas become lighter.
The Output Max adjust the light areas. Sliding it to the left, light areas become darker.

The Input Gamma value changes the linearity of the Tone Curve.

Example of using Levels

   
This is original histogram. It shows that the image is a Low key.

The image is Low Key, that means most of the colors are in dark areas.

Almost half of the range is not used (there are almost no pixels after the half of the histogram)

The sharp peaks at the very right part of histogram shows that a large number of highlights are blown out. We can cut them out as well.
   
We moved the sliders on the Input Min to 15 and Max to 165. The Tone curve shows the mapping Input/Output.
We selected the range of Input where are the most pixels. This stretch the histogram to full range. The image is no longer in Low Key  Selecting different Input Min and Max will stretch the image to the output values 0-255, making the image in full range.
   
Now we change the gamma to 1.8
This changes the Tone curve to non linear.

 Adjusting gamma changes the linearity of Input/Output.

In our case dark colors are mapped into brighter values, making the midtones more brighter.

 We still didn't see much midtones so adjusting gamma (>1.0) will make the midtones appear brighter. It also flatten a bit the high contrast done by stretching.
   
Now we select Blue channel only and move the Gamma to 1.1

We don't like the blue cast the image has, so we put gamma of Blue channel a bit back - make it again almost linear. This push the Blue back to dark tones and shows the more real colors.

Now we press OK.

 
This is the result histogram. The image is no longer in Low key. The pixels cover the whole dynamic range.

With Levels you can fix many of the color and range problems your images have.You can try adjust various levels and see what effect it has on image. Look also at the Tone Curve and try to understand the relation with histogram.

Pick Up Shadows and Highlights

With two buttons on the bottom right of the dialog box you can pick up shadows and highlights from the image. With these tools you can set where on image you want to have black and where white.


Shadows:
Click on the Pick Shadows button (the left one), cursor will change to eye-dropper. Now with this tool you can click on the part of the image where you want to have black. The curves of the R, G and B channel will adjust such way so the color you point at will become black.
Highlights: Click on the Pick Highlights button (the right one), cursor will change to eye-dropper. Now with this tool you can click on the part of the image where you want to have white. The curves of the R, G and B channel will adjust such way so the color you point at will become white. All the other colors and tones will adjust as well.

Note: The Pick up tool will not only let you to pick a color from the image, but from anywhere of the screen (for example from the Color & Texture Palette).