Sunday, February 17, 2013

Digitized picture correction with digiKam – Part 2

In About picture correction and work optimization post we have decided to use digiKam and in DigiKam installation and configuration (in 4 parts) we have installed and configured digiKam, so we are ready to do some real work. Please keep in mind this is not a manual (you can find that here). It is simply a selection of commands that work great for me with detailed explanation and some theoretical background.

Again I managed to write too much for a single post so I had to split it into several parts:
  • In Part 1 I talk about digiKam Image Editor and picture orientation and sizing commands.
  • In this part I present some color and histograms theory.
  • In Part 3 I go into details of color and brightness correction with "Levels Adjust" command.
  • In Part 4 I describe how to achieve good pictures quality without using unreasonable amounts of time.

About color presentation and histograms


What happens when we use different color correcting commands? The answer is the program we use is executing different mathematical operations on RGB color values of each pixel in the image. Most readers probably already know all this, but for those that don’t here is a short explanation. RGB is an acronym for 3 basic colors (red, green and blue) which can compose any other color. In JPG picture each pixel has a value from 0 to 255 for each color, 0 meaning the color is not present at all and 255 meaning the strongest possible color presentation in the pixel. That gives approximately 16 million (exactly 256*256*256) possible colors for each pixel. Here are some basic color examples and their RGB values:


And what is the histogram? It is the graphical presentation of frequency of each value for a color (or of luminosity, but more about it later) in a picture. Sounds complicated, but it is not. Remember a normal picture has millions of pixels, most of them are different, but if we look at only one color and draw a graph where horizontal axis has values from 0 to 255 and vertical axis is the count of pixels that have exactly that value for a color we get a histogram. The histogram of a theoretical picture containing all possible 16 million colors each used by exactly one pixel would be a horizontal line. Here is an example color gradient picture and its red color histogram.



It is not a horizontal line, because it is not a perfect color gradient, but I hope you get the idea. Of course real life pictures do not have histograms that are horizontal lines, but curves going up and down over color spectrum. But in most normal pictures each color should use the whole spectrum and it should be balanced evenly. If it is not, that indicates a possible error, which could be corrected. Let me repeat it because it is important, an uneven histogram may suggest an error, but you know what is in the picture (the program has no idea) and you should decide if it really needs correction. If you have a picture of night sky with moon and stars its histogram will be very unbalanced (very high on the far left and almost zero everywhere else), but that is not an error, it is expected for such a motive. Here is an example of a normal picture and its red color histogram.



Red color spectrum is not fully used (on the left and even more on the right edge it is zero) which suggests colors could be improved (and picture author agrees, because he knows it was taken in Legoland).

Now let us investigate the luminosity, which represents the L of the alternative HSL color model. We can also think about it as brightness of each pixel if the picture were converted to grayscale (this is not exactly true, but close enough and helps keep this explanation short and simple). An unbalanced luminosity histogram almost always suggests the picture is underexposed (meaning too dark) if shifted to the left or overexposed (meaning too bright) if shifted to the right. Here are exaggerated histogram examples of under and overexposed versions of already known Legoland picture.



Above I have mentioned the importance of correct vertical lines. Another possible picture defect which is also easily noticed is the white balance. When we know that something (like paper or snow) is usually white we immediately notice if it is bluish or reddish. Unfortunately that is exactly what happens when film fades with years, but luckily it can be corrected.

Color adjusting is the most complicated and time consuming part of digital picture correction. It is also what I do (or at least try to do) on each picture. DigiKam has several commands that can be used for brightness and color correction and I have tried them all. But most of the time I use only the command “Levels Adjust” (shortcut Ctrl-L) which allows for all picture correction adjustments I need.

No comments:

Post a Comment