Gimp Subtract One Layer From Another

by -47 views


up

previous

contents

index


Side by side:

4.iv Conversions of Selections,

Up:

four. Masks

Previous:

4.2 Layer Masks


Subsections

  • 4.3.i Painting Tools
  • 4.3.2 Selection Tools
  • 4.3.3 Gradients
  • 4.3.4 Transparency equally a Tool for Editing Masks
  • 4.3.5 Blurring of Masks and Other Effects


        

4.3 Basic Tools for Working with Channel and Layer Masks

This department discusses techniques for editing channel and layer masks. Although, layer masks are used to edit a layer’s alpha channel, and channel masks are used to store and edit selections, these two mask types behave similarly. Thus, the techniques for editing and filtering them tin be treated in a somewhat unified manner.

      

4.3.1 Painting Tools

1 of the most directly means to modify masks is with the GIMP’s painting tools. The
Paintbrush
Pencil
Airbrush
Eraser
Ink Pen
Dodge and Fire
Smudge,  and
Bucket Fill  tools can all be used. The versatility of these tools allows masks to be created that could not be duplicated using the selection tools alone. This is i of the reasons why masks are complementary to the selection tools.

Figure iv.17

Figure four.17:
Using Painting Tools on a Channel Mask
Figure 4.17

illustrates the use of the
Paintbrush
tool to edit a channel mask. As can exist seen from Figure 4.17(a), the
Paintbrush
tool has been selected from the Toolbox, and white is the
Agile Foreground Color. Furthermore, as shown in Figure iv.17(b), a medium hard brush has been selected from the
Brush Selection  dialog. Effigy four.17(c) illustrates the Channels dialog, which shows that an active channel mask labeled Butterfly has been created. The mask’southward color is gear up to yellowish, its opacity is 50%, and its Eye icon is toggled on, which means the the channel mask tin can be seen in the image window. The effect of the mask in the image window is shown in Figure iv.17(d).

The partial transparency of the mask makes information technology piece of cake to paint in the paradigm window while post-obit the butterfly’s outline. As already noted, the mask acts like digital tracing paper. Some white strokes can be seen in the channel mask thumbnail shown in Effigy iv.17(c). These were created by painting with the
Paintbrush
tool in the paradigm window. Because the channel mask is active, the
Paintbrush
modifies the mask, not the paradigm layer. However, the issue in the image window is to reveal parts of the epitome layer, as can exist seen in Figure four.17(d). Regions that have been painted white can be repainted black, which restores the mask. Note that although the mask appears xanthous in the prototype window, it actually remains a grayscale image. For this reason white, black, and grays are the merely colors that should exist used when painting in channel masks.

      

4.3.2 Pick Tools

Pick tools tin can too exist used to modify masks. Cutting a selection while a mask is agile fills the selected region of the mask with the current
Active Groundwork Color. Like the painting tools, selections tin be used to add or subtract parts of the mask.

Figure four.18

Figure iv.xviii:
Using Selection Tools on a Aqueduct Mask: Addition
Figure 4.18

shows how a selection in the image window can be used to add white pixels to the mask and, consequently, add to the set of selected pixels represented past the mask. Figure 4.eighteen(a) shows that a selection has been made in the image window, and Effigy 4.18(b) indicates that it was made using the
Bezier Path
tool. Figure four.18(b) besides shows that the
Active Background Color
is white. Cutting the selection while the aqueduct mask is active produces the result shown in Figure 4.18(c). The selected part of the mask has been removed from the epitome window. Furthermore, the respective role of the mask has been inverse to white, as can be seen from the mask thumbnail shown in Figure 4.eighteen(d).

Alternatively, Figure iv.19

Figure iv.19:
Using Selection Tools on a Channel Mask: Subtraction
Figure 4.19

shows how a selection tin can exist used to add blackness pixels to the mask, thus subtracting from the set of selected pixels represented by the mask. Figure 4.19(a) shows the selection in the image window and, as indicated by Figure iv.19(b), the selection was made using the
Rectangle Select
tool. Figure 4.19(b) also shows that the
Active Background Color
is set to black. The result of cutting the pick using
C-x
is shown in Effigy four.19(c). All the pixels in the interior of the rectangle selection accept been filled with black, which results in the removal of these pixels from the set of selected pixels represented past the mask.

      

iv.three.3 Gradients

When used in layer and aqueduct masks, gradients are very useful blending tools. Effigy 4.twenty

Figure 4.20:
Two Images
Figure 4.20

is used to illustrate how two images tin be blended together using a gradient in a layer mask. To begin, a new transparent layer is created in the lunar module image (Figure 4.20(a)), and the space shuttle image (Figure four.twenty(b)) is copied and pasted into it. The paste actually creates a floating selection that is subsequently positioned and anchored to the transparent layer. The result of the paste is illustrated in Figure 4.21(a),

Effigy 4.21:
Pasting and Positioning the Shuttle Over the Lunar Module
Figure 4.21

and the prototype’southward Layers dialog is shown in Effigy 4.21(b). Information technology can exist seen from the Layers dialog that the space shuttle is in the upper layer and that, in preparation for the next stride, a layer mask has been created for information technology.

The blending of the 2 layers is performed by amalgam a gradient  in the layer mask. The following steps are used to accomplish this:

1.
The layer mask is fabricated active by clicking on its thumbnail in the Layers dialog.
2.
The
Slope
tool is chosen from the Toolbox, and the
Active Foreground Colour
and the
Active Background Color
are set to black and white, respectively.
iii.
The
Tool Options
dialog  is opened by double-clicking on the
Gradient
icon in the Toolbox, and the Blend choice is set to FG to BG (RGB).
4.
The gradient is practical by clicking and dragging in the prototype window starting at the leftmost edge of the space shuttle layer, and releasing slightly to the left of the left shuttle rocket.

The resulting gradient can be seen in the layer mask’s thumbnail, shown in Figure iv.22(b).

Figure 4.22:
Two Images Composite Using a Gradient in a Layer Mask
Figure 4.22

Several points are worth noting here. First, the gradient is created in the layer mask past clicking and dragging in the
image
window. The gradient is applied to the
layer mask
considering it was fabricated agile in the kickoff step of the preceding process. 2d, every bit seen in Figure 4.22(a), the slope in the layer mask blends the upper layer with the lower one by creating a gradual transition from blackness to white in the mask. The black pixels of the mask brand the upper layer completely transparent. The tendency from the nighttime grey to lite gray pixels in the mask gradually blends the upper layer into the lower until the mask is totally white, at which point the upper layer is totally opaque. The width of the blend is controlled by the width of the gradient.

The alloy fabricated in Figure 4.22 produces a direct, horizontally varying gradient, but what if a more complicated blending interface is desired? This can exist solved using the Mode  menu found in the
Brush Selection  dialog. Figure 4.23(a)

Figure 4.23:
The

Brush Selection

Dialog and the Mode Menu
Figure 4.23

shows the
Brush Selection
dialog, and Effigy four.23(b) shows the mode carte du jour’s choices.

The Fashion card controls how the paint of the slope combines with what is already active in the image window (whether that exist an prototype layer, a channel mask, or a layer mask). The
Normal
style is the default, and this mode just replaces annihilation that was in the layer with the paint from the gradient. The other modes combine the paint from the slope in various ways, which are described in depth in Chapter 5. For the moment, withal, let’due south turn our attention to the
Multiply
and
Screen
modes. These modes will let united states of america to create gradients with tailor-made interfaces. To illustrate this, Figure 4.24(a)

Figure 4.24:
Using Blending Modes to Combine Gradients
Figure 4.24

shows a horizontally varying slope created by clicking and dragging with the mouse in the image window, beginning at the tail of the scarlet arrow and releasing at its tip. (Note that the red arrow is just for illustrative purposes and is not office of the image or the gradient.)

Choosing the
Multiply  style from the
Castor Pick
dialog’due south Mode menu and applying a second gradient to the get-go is shown in Figure 4.24(b). The direction of the applied gradient is indicated past the red arrow. If the normal combining fashion had been used, the second gradient would have replaced the first. However, setting the blending mode to
Multiply
has produced a completely different consequence. The two gradients have been multiplied together. What does it mean to multiply 2 gradients? Assigning a value of 0 to black, a value of 1 to white, and proportional values for grays provides us with a definition. This numerical correspondence is used to create a gradient that is the product of the first two. More precise definitions for the blending modes are given in Affiliate 5.

Figure 4.24(c) shows the result of using the
Screen  style, applied as shown by the scarlet arrow in the effigy. This mode works in a manner like to
Multiply
mode. It performs a multiplication, except that information technology is white that is assigned the value of 0 and black the value of one. As can be seen in Figure 4.24, the
Multiply
and
Screen
blending modes tin can be used to create custom gradient interfaces. The
Multiply
mode can be used to make a blackness pivot effectually the point of application, and the
Screen
style to make a white pivot.

Figure 4.22 shows an example of using a slope in a layer mask to alloy two layers. In the upper role of this figure, the alloy seems too abrupt, because the black space of the lunar module image contrasts strongly with the grayness-blue sky of the space shuttle launch. This tin be softened past making the gradient interface curve around the infinite shuttle epitome, letting more than of the lunar module’south black show through from below. Using the
Multiply
and
Screen
blending modes to do this produces the effect shown in Figure iv.25(a).

Figure four.25:
Custom Blending in the Upper Portion of the Image by Combining Boosted Gradients Using the

Multiply

and

Screen

Modes
Figure 4.25

The corresponding curved slope interface tin be seen in the layer mask thumbnail shown in Figure 4.25(b).

Effects like to what were accomplished with
Multiply
and
Screen
can exist had using two other blending modes:
Darken But
and
Lighten But.  The results are a piddling different from those obtained with
Multiply
and
Screen
considering these two modes provide more angular, predictable results at the corners of intersection. The result is more similar a mitred picture frame than a fluid, smooth transition. Figures iv.26(a), (b), and (c)

Figure 4.26:
Compare

Darken Only

and

Lighten Only

with

Multiply

and

Screen

in Effigy 4.24
Figure 4.26

illustrates the application of the
Darken Merely
and
Lighten Only
modes. Compare them with the application of the
Multiply
and
Screen
modes, shown in Figure iv.24.

Blending modes are discussed in more item in Section 5.6. A sophisticated use of gradients and blending modes in layer masks is illustrated in Department 7.iii.

     

4.iii.four Transparency as a Tool for Editing Masks

To effectively edit masks, the prototype layer must exist partially visible behind the mask so that information technology tin be used as a guide for editing. The semi-transparency of channel masks was discussed in Section 4.three.1, but how is information technology washed for layer masks?  It is done past using the Opacity slider in the Layers dialog. The following example demonstrates its use.

Effigy four.27

Figure 4.27:
Prototype with 2 Layers and a Layer Mask
Figure 4.27

illustrates an image consisting of two layers. The Layers dialog shown in Figure 4.27(b) shows that the lower layer is a photograph of a woods and the upper layer an prototype of a fish, on an otherwise transparent layer. The upper layer besides has a layer mask, which is to be used to edit the fish image.

The goal is to make parts of the fish transparent to create the illusion that the fish is partially behind some of the trees in the woods. This can be done with the layer mask past painting with black on the desired areas of the mask (see Section 4.3.i) or by cut away parts of the mask with a selection (see Section four.3.2). Still, to effectively edit the layer mask using either approach, you must be able to encounter the outline of the trees through the fish. This is achieved by making the Fish layer active and, then, lowering the value of the Opacity slider.

Figure 4.28(a)

Figure 4.28:
Decreasing the Opacity of the Top Layer and the Pick Obtained Using the

Bezier Path

Tool
Figure 4.28

illustrates the effect of lowering the Fish layer’s opacity. Because the copse tin be perceived through the fish, it is easy at present to edit the layer mask to achieve the desired issue. The upshot of using the
Bezier Path
tool to brand a selection is shown in Figure four.28(b) (annotation that the opacity of the Fish layer has been reset to 100%).

Making certain that the
Active Groundwork Color
in the Toolbox is set to blackness and that the layer mask is active in the Layers dialog, the option is cut by typing
C-x
in the image window. The event on the image is shown in Figure four.29(a),

Figure 4.29:
The Outcome of Editing the Layer Mask
Figure 4.29

and the thumbnail of the resulting mask can be seen in Figure four.29(b).

      

4.3.5 Blurring of Masks and Other Furnishings

Section 3.i.2 discussed an edge-softening technique called antialiasing  and an edge-blending technique called feathering. Effects similar to antialiasing and feathering tin be had by applying blur filters to masks.

White pixels in a mask correspond to selected pixels in an prototype layer, and black pixels in the mask correspond to unselected image pixels. If at that place are no gray pixels betwixt the black and white zones, this gives the selection edges represented past the mask the harsh edge already seen in the word on antialiasing. Blurring a mask softens the sharp edges in the mask past creating a graded zone of gray between the regions of blackness and white pixels. The width of the grayness zone is controlled past the blur radius. The gray zones represent to partially selected pixels in the image layer, and this is what creates the antialiasing/feathering effect for masks.

Figure iv.xxx

Figure iv.30:
An Paradigm and a Mask
Figure 4.30

is used to illustrate the use of blur filters on masks. Figure 4.thirty(a) shows an epitome of a wood duck, and Figure 4.30(b) shows a channel mask representing a selection of it. Figure 4.30(c) shows the associated Channels dialog.

A closer examination of the woods duck mask is shown in Effigy four.31(a).

Effigy 4.31:
Aliased Mask Edge Softened Using Blur Filter
Figure 4.31

As can be seen, the mask has an unpleasant, hard, and aliased edge. This can exist softened by blurring the mask. Figure four.31(c) shows the result of applying the
Gaussian Mistiness (IIR)  filter to the mask. The filter dialog is displayed in Figure 4.31(b), which shows the pick of mistiness radius. In full general, a small-scale radius produces an antialiasing outcome, and a large blur radius creates a feathering effect. A blur radius of 1 was used for this example.

Other interesting and artistic edge effects can be obtained by processing masks with one or more of the GIMP’s big drove of filters, found in the
Image:Filters
menu. Figures 4.32, 4.33, and 4.34 illustrate some examples.

Figures 4.32(a)

Effigy 4.32:
Applying the

Waves

Filter to the Wood Duck Mask
Figure 4.32

illustrates the
Waves   filter dialog, found in the
Image:Filters/Distorts
menu. The resulting issue on the forest duck mask is shown in Figures 4.32(b), and the result of applying this mask as a selection to cutting away the image’southward groundwork is shown in Figures 4.32(c). Figure 4.33(a)

Figure 4.33:
Applying the

Drinking glass Tile

Filter to the Wood Duck Mask
Figure 4.33

shows the
Glass Tile   filter dialog, found in the
Paradigm:Filters/Glass Effects
menu. Figures iv.33(b) and (c) prove the effect of this filter on the mask and the image. Effigy four.34(a)

Effigy 4.34:
Applying the

Spread

Filter to the Wood Duck Mask
Figure 4.34

shows the
Spread   filter dialog, found in the
Prototype:Filters/Noise
menu. Figures four.34(b) and (c) show the result of this filter on the mask and the epitome.

Many other interesting filter possibilities can be found. Have fun! Experiment!



up

previous

contents

index


Side by side:

4.4 Conversions of Selections,

Upward:

4. Masks

Previous:

4.ii Layer Masks


©2000 Gimp-Savvy.com

Source: http://tinf2.vub.ac.be/~dvermeir/manual/gimp/Grokking-the-GIMP-v1.0/node45.html