The Foreground Select Tool Extracting Images Automatically

Before we turn to a work-intensive method where we mask image objects by hand, I will show you the automatic method. The Foreground Select tool that has been included in GIMP since version 2.4 offers a method to easily extract objects in images. Let's have a look at what the tool can do.

First of all, an easy exercise: Extract an orange basketball that is in front of a green background. Open the image basketball.png from the Samplelmages folder on the DVD. Select the Foreground Select tool in the Toolbox. You will work with the tool in several steps.

Figure 3.98

The foreground is roughly selected and a transparent blue mask covers the background.

1. Once you have selected the tool, the cursor will turn into a lasso, just like the Free Select tool. For the first work step, the handling of the Foreground Select tool is similar to using the Free Select tool as a freehand lasso. Just make a rough selection of the object you want to extract. Hold the left mouse button and draw around the object. Try to incorporate as little of the background as possible (though it's impossible to be precise). If you don't close your selection entirely, the tool will close it automatically with a straight line as soon as you let go of the mouse button. Then a transparent blue mask will cover the background.

Figure 3.98

The foreground is roughly selected and a transparent blue mask covers the background.

CHAPTER 3

USING MASKS AND L AY E R S — PA I N T I N G, FILLING, AND COLOR TOOLS

Figure 3.99

The foreground is painted over to cover all shades and colors.

Figure 3.99

The foreground is painted over to cover all shades and colors.

Figure 3.100

The mask around the selected basketball

Figure 3.100

The mask around the selected basketball

Figure 3.101

The finished selection

Figure 3.101

The finished selection

2. The cursor changes shape; it is now a paintbrush. In the second step, you must inform the program which colors the object to extract has. Thus, you paint over the entire surface of the foreground so that all possible colors and shades are covered. Take care to stay inside the selected area when painting. You can paint over the area to select in several steps. As soon as you let go of the mouse button, the program begins to compute and the surfaces that haven't been selected are covered. However, if not all areas to select have been detected by the tool, you can paint the surfaces again. They will be added to your first selection. If you accidentally selected too much, you can switch the tool setting to Mark background below Interactive refinement. Otherwise, you can simply hold the Ctrl key. This way, you can select sections in your image that should be deleted from the selection. The program recalculates the selection and creates a new mask. You can refine the result again if you wish.

3. Finally, after you press the Enter key, the entire process is finished and a real selection is created from the mask.

Perform the steps—selecting, painting over, pressing Enter—in one go. Once you have begun working with the Foreground Select tool, it is not possible to reverse any steps, neither with Undo History nor with Ctrl+Z. The entire process appears as one work step in the Undo History once it is completed. If you mess up somewhere in the process and you would like to start again, simply select another tool in the Toolbox. The Foreground Select tool is discontinued and you can start anew.

Nevertheless, corrections can be made during work as previously described with the tool itself. When working with the paintbrush (step 2), you can select a coarse brush to cover large surfaces. Afterward, the details can be worked out with a smaller brush. The brush size can be selected in the tool settings.

If you marked too much as foreground, you can switch the tool settings to Mark background. In a way, this lets you erase the over-drawn selection.

Before we start to view the results of the tool in an image with low contrast between foreground and background, I would like to give you an overview of the tool settings. We will be looking at only the tool settings that you are not acquainted with:

• Contiguous: This feature is selected by default. It indicates that only cohesive surfaces are selected with the paintbrush. If you deselect this option, other areas in the image that are the same color will be selected when you use the paintbrush. For example, if you selected a flower in a field full of flowers, all similar flowers would be selected automatically.

• Interactive refinement: The choices under Interactive refinement allow you to alternately select colors from the foreground or background, depending on what you want to add to your selection.

• Mark foreground: This option is the default setting. The paintbrush paints with the foreground color when creating a selection. The colors that have been painted over mark the object that should be extracted.

• Mark background: This option can be selected when it is easier, due to the colors, to select the background rather than the foreground. Moreover, you can switch to this option while working by holding down the Ctrl key. With the Mark background option selected, the program paints in the selected background color (in the Toolbox). You can also subtract colors from the selection, for instance, if you have overdrawn the boundaries of the area you want to select. Colors within the images that have been marked as background (with the background color) are not selected.

• Small brush - Large brush: The slider lets you select the size of the paintbrush. A small brush lets you work with fine details.

• Smoothing: This slider lets you determine the sharpness of the edges of the selection border. If you smoothen the selection with the brush, you can remove or cover up small holes.

• Preview color: Lets you select the color of the overlay mask, which covers up the background in the image.

• Color Sensitivity: This feature works with the LAB color model. If your selection has a color with a variety of tones, you can increase the sensitivity of the selection for this color.

Let's have a look at an image object that because of its characteristics is more difficult to extract. Have a look at the image lion.png in the SampleImages folder on the DVD. The lion in the picture has a color that's similar to the background. It is difficult to extract the fringes and the strands of hair in the lion's mane.

You can tag along again in this exercise. The result can be used for exercises later in the book.

• Open the lion.png image in the SampleImages folder on the DVD.

• First, perform an automatic color level adjustment (Colors > Levels > Auto) on the image. The contrast of the background colors will come out stronger.

• Select the Foreground Select tool. Circumnavigate the lion and his mane, applying the tool's lasso with as little distance to the object as possible. If your result isn't to your satisfaction, you can adjust the Color Sensitivity setting. Set the values of L, a, and b up to around 500 to enhance the contrast sensitivity of the tool.

CHAPTER 3

USING MASKS AND LAYERS—PAINTING, FILLING, AND COLOR TOOLS

Figure 3.102

A rough preselection of the lion

Figure 3.102

A rough preselection of the lion

Figure 3.103

Selecting the foreground: the lion overpainted

Figure 3.103

Selecting the foreground: the lion overpainted

The extracted lion. Now you can make corrections with the tool's paintbrush.

Again, the tool switches and turns into a paintbrush. With it you can mark the foreground color of the object you want to extract. First, I chose a medium-sized brush to paint over the lion, and then I painted within the contours and finally tried to cover all the various shades of the lion's fur. For the tail and the tassel, I reduced the size of the brush. Take care not to paint into the background.

If you want to make any changes because there are still surfaces to select or that have been overselected, this is the time to do it. If you have selected too little, you can apply the paintbrush a second time. If you selected too much of the image, you can switch to Mark background under Interactive refinement in the tool settings. You can then erase the sections that you don't want.

When you are satisfied with the result, confirm your selection with the Enter key. The blue mask disappears and a selection is made around the lion.

The result is pretty good, but altogether the contour is a bit too jagged and there are still selection islands visible in the lion. In the next section, I will show you how you can subsequently improve the result and how to make the preselections with "conventional" select tools.

CHAPTER 3

USING MASKS AND L AY E R S — PA I N T I N G, FILLING, AND COLOR TOOLS

TI . r FiEe Edit Seteci

the lion still can be improved.

TI . r FiEe Edit Seteci

the lion still can be improved.

0 0

Post a comment