7.1 Tutorial: Extracting Information from a Picture

So, how do you separate noise from the meaningful elements in a picture? One way is to gather information about the image, via histograms, to see if there’s distortion in any of the channels. The image we’ll use in this tutorial isn’t particularly interesting, but it is representative of the problems you may encounter when dealing with badly taken photographs. As you can see in Figure 7-1, the picture’s quality is very poor. The photograph was taken through a closed window, in poor lighting, and with the camera’s automatic settings.

The initial photograph

Figure 7-1. The initial photograph

Dynamics Extension

Begin by gathering information on the image dynamics, such as the ratio between the smallest and largest values in various channels. The combined histograms shown in Figure 7-2 are a way to visualize the image dynamics. Open them via Image: Colors > Info > Histogram, and change the CHANNEL to RGB. The three channels—Red, Green, and Blue—are shown in the same graph in their corresponding colors. The colors in the areas where the histograms superimpose are additive. A position on the horizontal axis represents a specific value between 0 and 255. The height of the histogram (the vertical axis) represents the number of pixels with that value.

The histogram for the initial photograph

Figure 7-2. The histogram for the initial photograph

The meaningful part of the histogram

Figure 7-3. The meaningful part of the histogram

After equalizing

Figure 7-4. After equalizing

Move the small triangles under the horizontal grayscale bar to frame the meaningful interval of values. Figure 7-3 shows that almost no pixels have a value less than 65 or greater than 173. In fact, 99.1 percent of the pixels are in the framed interval, which explains why the image is dull and hazy.

The histogram after equalization

Figure 7-5. The histogram after equalization

After stretching the contrast

Figure 7-6. After stretching the contrast

Extending the dynamic range is fairly easy with the tools available in GIMP. The simplest one is Image: Colors > Auto > Equalize, which automatically stretches the dynamic range in each channel to span the entire available range. Figure 7-4 shows the result, and Figure 7-5 shows the corresponding histogram. Because the image has only slightly more than a hundred different values, and the range has 255 values, extending the existing values over the full range leaves a lot of values unrepresented, which explains the strange “comb” shape.

In the resulting image (Figure 7-4), you see the squirrel is more visible, but the color distortions in the image have been exaggerated.

The same menu contains other automatic tools. For example, Figure 7-6 shows the image and its histograms after we used Image: Colors > Auto > Stretch Contrast. You could also try Image: Colors > Auto > Normalize, which gives a similar result.

After using Auto in the Levels tool

Figure 7-7. After using Auto in the Levels tool

Extracting the RGB channels

Figure 7-8. Extracting the RGB channels

Pressing the AUTO button in the Levels tool yields the image shown in Figure 7-7. You can get a similar result by using Image: Colors > Curves to manipulate the curves in each color channel and suppress high and low values, which are not present in this photograph.

Histogram Modification

The histograms you saw in the preceding section are not very useful because they are crammed into one window, and their significance is not obvious in the image. A better way to visualize the three channels is to use Image: Colors > Components > Decompose. In the dialog shown in Figure 7-8, choose RGB to decompose the image into its three RGB channels. A new image with three grayscale layers, one for each channel, is created. In the Histogram window, choose the Value channel, which is done automatically because the image has no color or transparency.

The red channel

Figure 7-9. The red channel

The green channel

Figure 7-10. The green channel

The blue channel

Figure 7-11. The blue channel

Figure 7-9 to Figure 7-11 show the three channels, along with their respective histogram. Clearly the Blue channel contributes much less to the image than the other two channels. Let’s see what happens if you stretch its histogram and leave the others unchanged.

Stretching the dynamics of the Blue layer

Figure 7-12. Stretching the dynamics of the Blue layer

After recomposing the image

Figure 7-13. After recomposing the image

Select the Blue layer in the Layers dialog and apply Image: Colors > Auto > Equalize. The result, if you hide the other two layers, appears in Figure 7-12. Next, apply Image: Colors > Components > Recompose. The result, shown in Figure 7-13, is worse than the original. This image demonstrates that proper preprocessing requires an understanding of image dynamics that goes beyond being able to use the automatic tools.

Noise Reduction

Noise is a set of small fluctuations around the average value intensity in some region of an image. As you’ll see later in this chapter, noise reduction is useful in many circumstances. But in the present case, the image is mostly noise, and no noise reduction process can really improve it. The only tool that’s even slightly useful is Image: Filters > Enhance > Unsharp Mask, which brings up the dialog shown in Figure 7-14.

The Unsharp Mask dialog

Figure 7-14. The Unsharp Mask dialog

After using Unsharp Mask

Figure 7-15. After using Unsharp Mask

If you increase the RADIUS to more than 40, you improve the image a bit, as shown in Figure 7-15. The squirrel is more visible and has more relief, but identifying most of the plants in the background would still be very difficult.

Edge Detection

Generally, edge detection enhances the visibility of objects in a photograph. But when we applied the various filters in the Image: Filters > Edge Detect menu to our initial squirrel photograph, we didn’t see any improvement. You can achieve a better result by successively applying several different tools.

For example, first select the Levels tool, and click AUTO. Next, apply the Unsharp Mask filter. Finally, choose the Image: Filters > Edge-Detect > Edge filter. Using the settings shown in Figure 7-16, you get the result shown in Figure 7-17. Admittedly, this version is not really an improvement if your goal is to create a realistic image of the squirrel in its habitat. You could try applying the last filter on a copy of the layer and then adjusting the blending mode to get a more natural result.

The Edge filter dialog

Figure 7-16. The Edge filter dialog

After using the Roberts edge detection filter

Figure 7-17. After using the Roberts edge detection filter

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset