5.2 Selections, Overlaying, and Blending Modes

This chapter focuses on the construction of composite images using elements from several different photographs. The three main tools for this process are selections, overlaying, and blending modes.

As the preceding tutorial demonstrates, making selections is one of the most important, and trickiest, tasks involved in photo manipulation. So we’ll spend some time clarifying the functionality of the selection tools available in GIMP.

When you build a selection with the Rectangle Select tool, you get an area bounded by a simple geometric form. The simplicity makes it easy to tell whether pixels are within the selection. If you choose to feather the edges of the selection, however, the boundary is less clear: Some pixels are clearly out of the selection and some are deep within it, but what about those pixels on the feathered border?

The situation is even more complicated when you use the Fuzzy Select tool or the Select by Color tool. The selections that these tools build are usually not defined by clear and simple outlines. This shortcoming is obvious when you turn on Quick Mask, which displays the unselected pixels in red (by default). If the selection is feathered, you see that some pixels are completely red (unselected); others aren’t red at all (selected); and some pixels are, well, reddish. Figure 5-9 shows a feathered selection made with the Select by Color tool, whereas Figure 5-10 shows the same selection with the Quick Mask tool active. Both images are shown with a zoom factor of 800%.

As you may have guessed, those reddish pixels are partially selected. A selection and a mask are actually the same thing. They are both grayscale images that specify to what degree each pixel is selected. If the pixel value of the mask is 0 (i.e., black), the corresponding pixel in the image is not selected at all. If this value is 255 (i.e., white), the corresponding pixel is fully selected. A partially selected pixel has a value somewhere between 0 and 255.

Along the feathered edge of a selection, pixels are partially selected. All actions made to the selection affect these partially selected pixels to a lesser degree: Painting is semitransparent; burning is partial; cutting leaves some of the pixels in place; and so on. Partial selections are what make selections so useful in photo manipulation. They allow you to build composite pictures that don’t look like clumsy collages.

Because a selection and a mask are the same thing, and a mask is a grayscale image, you can manipulate it with the same tools that you would use on an image. You can paint on it with the painting tools demonstrated in Chapter 3. You can select and edit specific areas. And you can save it and use it later with Image: Select > Save to Channel. The mask appears as an additional channel in the Channels dialog, as shown in Figure 5-11. In this figure, the channel is selected (its line is emphasized), so if you paint on the image now, you’ll be painting on the mask. To paint on the image itself, switch to the Layers tab, select the layer you want to modify, and begin painting.

You can also use this property to change the mask in the same way we use the Quick Mask tool. To do this, open the Channels dialog and click the box to the left of the mask so the eye is visible. The mask now appears over the image (in gray by default). You can change the mask’s display color by selecting Channels: right-click > Edit Channel Attributes to open the dialog shown in Figure 5-12. You can change the channel’s name and its opacity, as well as the color of the mask. Click the large button on the right to open the Color chooser, where you can pick any color you want. But keep in mind that using a color that contrasts with the image is generally best.

When a selection (a mask) is saved in a channel, you can use it again later by simply clicking the red square button at the bottom of the Channels dialog. If you hover the pointer over the button, you’ll see that the standard key combinations allow you to activate different selection modes. You can save an unlimited number of selections as masks in the Channels dialog.

A mask used to determine the transparency of pixels in a layer is known as a layer mask. A layer mask is a part of a specific layer, and its pixels specify the transparency of the corresponding pixels in that layer. If a mask pixel is white, the corresponding layer pixel is opaque and thus visible in the image if not hidden by another pixel located in an upper layer. If a mask pixel is black, the corresponding layer pixel is transparent and thus invisible. Intermediate values for the mask pixels produce intermediate transparency levels for the layer pixels. Note, however, that the layer itself is unchanged.

You can add a layer mask by applying Add Layer Mask from the Image: Layer > Mask menu. Once added, you can access its options via the same menu. You can also add or manipulate a layer mask by right-clicking in the Layers dialog. When you add a mask to a layer, you can choose among several options: a completely white or completely black mask, the current selection, a specified channel, and others. Once you’ve built the mask, you can change it by painting on it, for example, with Quick Mask. You can change some of its properties, such as how it displays on the image. Finally, you can apply it to the layer, making its effect final.

We already demonstrated some of these options in previous chapters, and we come back to them later in this chapter.

Simply overlaying opaque images isn’t very interesting. Modifying the opacity of the top layer sometimes yields a satisfying result, but doing so doesn’t give us much control over it. Once you build a selection, however, you can create your own unique and imaginative images.

For example, take the photographs shown in Figure 5-13 and Figure 5-14. Open the first one, and add the second one as a layer (). Then, with the Fuzzy Select and Select by Color tools, select the sky in the top layer, which requires about a dozen clicks in several areas of the sky. Recall that pressing allows you to add to the selection, whereas pressing allows you to subtract from the selection. The completed selection is shown as a Quick Mask in Figure 5-15.

Our goal is to make the sky transparent so the building from the other photograph is visible behind the tropical vegetation. If we simply cut the selection, however, the sky is replaced by opaque white because the layer doesn’t contain any transparency (indicated by the boldface layer name) and so any cut pixels are replaced by the background color. To add transparency, add an Alpha channel to the top layer: Layers: right-click > Add Alpha Channel. Now if you cut the selection, you get Figure 5-16.

You can also use a selection to copy something from one photograph and paste it into another one. You did this earlier on a smaller scale when you created the composite portrait at the beginning of the chapter. Moving larger objects from one photograph to another presents its own challenges, as you’ll soon see.

As you saw previously, newly pasted objects are added to an image as a floating selection. They appear in the Layers dialog (which you should always keep visible in your workspace) and act somewhat like a layer located on the top of the stack. But as long as a floating selection exists, you can’t change anything else in the image. The other layers are inactivated, just as the unselected regions of an image are inactive as long as a selection exists.

With a floating selection, you can do the following:

Let’s say you want to combine elements from the photographs shown in Figure 5-17 and Figure 5-18. You’ve decided to place an overdressed man in front of a sunny villa on the French Riviera. Select the man on the right, as shown in Figure 5-18. Make the selection with the Free Select tool and complete it by painting with Quick Mask. Don’t very careful when selecting his legs, however, because they won’t be visible.

Copy the selection from Figure 5-18 and paste it onto the image in Figure 5-17. The man appears in the center of the image, as shown in Figure 5-19, as a floating selection (see Figure 5-20).

Create a new layer for this floating selection and move the man to the bottom-right corner of the sunny scene. He’s darker than his surroundings, so select the Levels tool and add some light and contrast. Also apply Image: Layer > Transform > Flip Horizontally to flip him around. You can see the result in Figure 5-21.

GIMP has 21 blending modes, which you can select from the Layers dialog. The MODE option contains a drop-down menu with a list of blending modes that will act on the active layer. Each blending mode uses a different mathematical model to compute a new pixel value from the active layer and the layer below. Although we won’t go into any detail regarding the mathematics of blending modes, we will introduce some of the modes most useful for overlaying images.

Begin with the photographs from Figure 5-22. Put them into the same image with the first one as the upper layer. The blending modes are arranged in a logical order, as explained in Chapter 12. In the following list, we briefly introduce these modes, in a different order, so we can run through them more quickly.