2.8. Extraction de Premier-plan

Figure 14.34. L'outil « Sélection du Premier-plan » dans la Boîte à Outils

L'outil « Sélection du Premier-plan » dans la Boîte à Outils

This tool lets you extract the foreground from the active layer or from a selection. With GIMP-2.10, selection refinement has been improved. After the selection is made, with its marching ants, you can copy-paste or click-and-drag it to another image used as background,and, inverting the selection, you can can make changes in background.

2.8.1. Accès à l'outil

On accède à l'outil Extraction de Premier-plan de deux façons :

  • en cliquant sur l'icône de l'outil dans la Boîte à outils,

  • par le Menu de l'image, en suivant OutilsOutils de sélectionExtraction de Premier-plan.

  • À l'origine, cet outils n'a pas de raccourci clavier, mais vous pouvez en définir un en utilisant FichierPréférencesInterfaceConfigurer les raccourcis clavierOutilsExtraction de Premier-plan

2.8.2. Mode d'emploi

Let us start with an object distinctly different from background, not needing to be refined.

  1. Sélectionnez grossièrement le premier-plan que vous voulez extraire. Quand vous sélectionnez cet outil, le pointeur de la souris s'accompagne alors de l'icône du lasso. Il se comporte en effet comme l'outil de sélection à main levée. Sélectionnez aussi peu que possible d'arrière-plan.

    When the mouse pointer comes over line beginning, a small yellow circle appears: release mouse button to close selection. While selecting, click-and-drag draws a fuzzy line, drag only draws a straight line.

    The selection is closed.

    As soon you click to start drawing, a small window pops up:

    There you have:

    • A Preview checkbox that toggles displaying a preview of the foreground extraction status. Esc key also toggles this preview.

    • A little cross to quit: returns to the original image.

    • A Select button: not active for the moment.

  2. Press Enter to create the mask:

    The mouse pointer goes now with the Paint-brush icon. The dark blue area (this color can be changed) is for background. The light blue area covers the zone you have selected, on which you will paint to extract foreground. Between foreground area and background is a zone you have selected belonging to background named Unknown pixels area.

  3. Tracez un trait continu à l'intérieur du premier-plan : avec ce pinceau, dont la taille peut être changée dans les options, tracez un trait continu à l'intérieur du premier-plan sélectionné de façon à passer sur les couleurs qui seront retenues pour l'extraction. La couleur utilisée pour tracer ce trait n'a pas d'importance, à condition qu'il ne s'agisse pas de la couleur du premier-plan de votre image bien sûr. Veillez à ne peindre aucun pixel d'arrière-plan.

    With this one-color object distinctly different from background, a few strokes are enough:

  4. Toggle preview to verify result.

    [Note] Note

    This Preview mask is a mask: you can draw directly on it and see result immediately.

  5. Try Matting Levin engine that may improve result.

  6. When you are satisfied with result, click on Select button to get the selection of the foreground with its marching ants.

2.8.3. Options

Figure 14.35. Options de l'outil « Extraction de Premier-plan »

Options de l'outil « Extraction de Premier-plan »

Normalement, les options de l'outil sont affichées dans une fenêtre attachée en-dessous de la Boîte à outils. Si elles ne le sont pas, vous pouvez y accéder depuis la barre de menus de l'image par FenêtresFenêtres ancrablesOptions de l'outil.

Mode; Feather edges
[Note] Note

Voyez Fonctions communes pour avoir de l'aide sur les options communes à tous ces outils. Seules les options spécifiques à cet outil sont décrites ici.

Draw mode

Draw foreground: to draw what will be foreground.

Draw background: to draw what will be background.

Draw unknown: to add to your selection pixels that are in background.

Stroke width

The size of the brush.

Preview mask

You can adapt the color of the preview to your image.

Engine

Work with Matting global(default) and improve result with Matting Levin.

Iterations

Default is 1. Repeating algorithm may improve result.

2.8.4. Refining Foreground Extraction

In most images, foreground is not distinctly different from background. Refining selection allows you now to extract these foregrounds. Procedure steps are the same as above, but, during drawing foreground, you will often toggle Preview, use Zoom (+ key), Draw background to delete unwanted background extraction areas. You can also work directly on Preview mask.

Figure 14.36. Example for Draw background

Example for Draw background

On the left: drawing foreground ill-advisedly went over unknown pixels area: a part of background will be included in foreground selection!

In middle: Draw background option is checked: draw on inclusion and unwanted pixels.

On the right: unwanted selected pixels in background are no longer in foreground selection.


You will often have to reduce the unknown pixels zone with Draw background.

Figure 14.37. Example for Draw unknown

Example for Draw unknown

On the left: the selection left a small part of foreground unselected, in unknown pixels area.

On the right: with Draw unknown option checked, draw on unselected pixels. They are now selected in foreground.