A channel mask is a special grayscale layer only 8 bits deep and is used to store and edit selections. This section describes the Channels dialog, how to save selections to channel masks, how to convert channel masks to selections, and the other GIMP functions used for organizing masks and operating on them.
As an image can have any number of layers, it can also have any number
of channel masks. Thus, analogous to the Layers dialog, the Channels
dialog is the the tool for organizing and working with channels. The
Channels dialog is obtained by typing C-l in the image window
and clicking on the Channels tab in the resulting Layers &
Channels window. Figure 4.1
The most important feature of the Channels dialog is the Channels Palette. This region of the dialog consists of horizontal strips where the top three entries are always the Red, Green, and Blue channels of the image, already described in Section 2.2.1. The rest of the strips are channel masks. Figure 4.1 shows a single channel mask. The channel mask strip displays a thumbnail image of the mask's contents, and the area to the left of the thumbnail contains an Eye icon. Analogous to layer strips in the Layers dialog, the visibility of the Eye icon for channel strips can be toggled on and off, making the channel mask either visible or invisible in the image window.
To the right of the thumbnail is the Channel Title Area. In Figure 4.1 the channel is named A Channel Mask. The title can be changed by double-clicking in the Channel Title Area. This brings up a dialog where the new title can be entered.
The channel strip in Figure 4.1 is highlighted in blue, indicating that it is the active channel. A channel mask is made active by clicking on its thumbnail or Title Area. Only a single channel mask can be active at a time, and, when a channel mask is active, none of the image layers can be active. Because GIMP tools applied to the image window are applied to the active layer or the active channel, this can sometimes be a source of confusion. After working on a channel mask, to work on a layer it is necessary to explicitly switch to the Layers dialog and to make the layer active.
The remaining elements of the Channels dialog are the Channels menu and the button bar. These are described in more detail shortly.
One of the primary uses you will make of channel masks is to save selections. Why should you save a selection to a channel? There are many reasons. The first is that saving the selection protects your work, which is particularly important if you are making an involved and difficult selection. Second, it allows you to make your selections in parts. This helps divide and simplify the work. Third, it allows you to reuse a selection for several purposes. This is useful for all sorts of rendering operations, such as making drop shadows, highlights, and special textures (for example, see Section 8.5). Fourth, it allows you to refine your selections in ways that would otherwise be impossible. Finally, many special effects can be had using filter plug-ins on masks. As you can see, saving a selection to a channel mask really has a very broad range of benefits.
After making a selection with any of the tools described in
Chapter 3, we can save the selection to a channel
mask using the Save To Channel function, found in the Image:Select menu.
Figure 4.2(a)
After using Save to Channel, the active focus changes from the Layers dialog to the newly created channel in the Channels dialog. Nevertheless, the selection in the image window remains active. This has several important consequences. First, since the new channel is active, all ensuing filtering or painting operations are applied only to this channel. Furthermore, since the original selection is still active, the only parts of the new channel that can be affected are those inside the selection area. For example, trying to paint outside the selection will have absolutely no effect.
Thus, if the objective is to work on the newly created channel, the selection must be canceled by typing C-S-a in the image window, and the channel must be made visible by toggling on its Eye icon in the Channels dialog. If the objective is to save the selection as a channel and to move onto other image operations, the selection must be canceled, and the appropriate layer in the Layers dialog must be made active.
A channel mask's visibility can be toggled on or off by clicking on
its Eye icon. Looking again at
Figure 4.2(b), the Eye icon is not visible.
Toggling it on, as shown in Figure 4.3(b), and
toggling off the image layer's visibility produces the result shown in
Figure 4.3(a).
If the Eye icon of the image layer is toggled back on, as shown in
Figure 4.4(b), the resulting view in the
image window is Figure 4.4(a).
Being able to see the image through the filmy parts of the channel mask, as illustrated in Figure 4.4(a), makes it possible to edit the mask according to the features of the image behind it. In this way, the channel mask is like a piece of digital tracing paper placed over the image.
Double-clicking in the channel mask title area brings up the Channel Options dialog, shown in
Figure 4.5(b).
The Fill Opacity slider sets the degree to which the image layer is visible through the filmy parts of the mask. The slider's units are in percent so if the opacity is set to 100, the only parts of the image that are visible are those that correspond to the white part of the mask, and the parts of the image corresponding to the black parts of the mask cannot be seen. Alternatively, if the opacity is set to 0, the image layer is completely visible, and the mask cannot be seen. An intermediate opacity setting allows the masked-out regions of the image to be seen through the black part of the mask. Adjusting the Fill Opacity slider allows an optimum working level to be set for the mask.
If some of the image pixels seen behind the semi-opacity of the mask are dark, it will be difficult to see the details of these pixels. This may impede your ability to make useful edits to the mask, regardless of the Fill Opacity slider's setting. This is why the color of the mask can be changed. Changing the mask's color is done by clicking in the color patch of the Channel Options dialog. This brings up the Color Selection dialog, from which any color can be chosen. A good choice, of course, is one that contrasts well with the image layer pixels. Closing the Color Selection dialog changes the color in the Channel Options color rectangle. Closing the Channel Options dialog makes this color appear at the chosen opacity level in the image window. This is shown in Figure 4.5(a), where a 50%-transparent red has been chosen for the mask color.
The Channels dialog, like the Layers dialog, has a hidden menu that
can be displayed by right-clicking in the title area
of the Channels Palette. This menu is shown in
Figure 4.6(b).
The remaining functions in the Channels menu, Add to Selection, Subtract From Selection, and Intersect With Selection are described in the following section.
Section 3.2 describes how selections can be combined; selections can be added, subtracted, and intersected. These operations are useful because they allow the results from different selection tools to be combined and because they also allow the work to be performed incrementally. This can be particularly important when selecting from a large image or when making a complicated selection.
Channel masks can also be combined. This is done by converting the
masks to selections and then saving the combined result back to a
mask. Figure 4.7
After making the channel labeled Rock the active channel, it is
converted to a selection by clicking on the Channel to Selection
button (represented by the dashed circle icon) in the button bar. The
active channel can be seen in Figure 4.8(b).
A similar operation is performed with the channel mask labeled Fish.
The mask is made active and then converted to a selection. Normally
the conversion of a mask to a selection replaces any selection already
active in the image window. However, the selection represented by the
mask can also be added to the active selection. This is accomplished
by choosing the Add to Selection function from the Channels menu, shown in
Figure 4.6(b). The Add to Selection
function can also be invoked by Shift-clicking the Channel to
Selection button in the button bar. The result of adding the
selection is shown in Figure 4.9(a),
Two other combining modes are also available in the Channels menu. These are the Subtract From Selection and the Intersect With Selection functions. These can both be used from the Channel to Selection button in the button bar. Control-clicking the button produces a subtraction and Control-Shift-clicking produces an intersection.
The final step to obtain a channel mask of the combined selection is
performed by using Save to Channel from the Image:Select
menu. The procedure is illustrated in Figure 4.10.
Partially selected pixels are especially important at selection edges because they allow the selection to blend more smoothly with other image layers. The subject of partially selected pixels has already been discussed to some extent in Section 3.1.2, which presented the concepts antialiasing and feathering.
A powerful feature of masks is that they provide an easy way to create and to work with partially selected pixels. As has already been discussed, a white pixel in a channel mask represents a fully selected pixel in the image window, a black pixel fully unselected, and a gray pixel partially selected. Thus, channel masks allow for partially selected pixels, and, moreover, provide a framework on which any of the GIMP's filters and functions can be applied. This makes channel masks a particularly flexible and versatile medium for working with partial selections. Some examples of using GIMP filters on masks are illustrated in Section 4.3.5.