2.8. Selecció del Primer Pla

Figura 14.33. L'eina «Selecció del Primer Pla» en la caixa d'eines

L'eina «Selecció del Primer Pla» en la caixa d'eines

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 make changes in background.

2.8.1. Activació de l'eina

Podeu activar l'eina Selecciona el Primer Pla de dues maneres:

  • en fer clic sobre la icona de l'eina en la caixa d'eines,

  • en el menú de la imatge EinesEines de seleccióSelecció del Primer Pla

  • This tool has no shortcut, but you can set one using EditKeyboard Shortcuts, open the Tools group on the left, select Foreground Select and then press the keys you want to use as shortcut.

2.8.2. Direcció per l'ús

Let us start with an object that is easy to distinguish from the background and doesn't need to be refined.

[Avís] Avís

The foreground select tool needs a lot of memory for its processing, depending on the size of the image. It is known to crash or slow down when using larger images.

One way to improve this is to use Matting Global instead of Matting Levin. The slow processing speed can be improved by increasing the number of downsampled Levels, at the cost of using more memory. Both of these options also come with the disadvantage of being less accurate.

  1. The way it works is similar to the Free Select tool. Roughly select the object you want to extract, with a little bit of background around it. To get a more accurate outline, keep the mouse button pressed while moving. To use straight lines for parts of your selection, click and release the button between the start and end points of the straight section.

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

    Before the selection is finished, only the close button x is active, allowing you to cancel and return to the original image (this can also be done by pressing the Esc key).

    To finish the initial selection, it needs to be closed. When the mouse cursor hovers over the dot where you started the selection, it turns yellow. Click this to close the selection. Instead of doing that, you can also double-click to close the selection.

    La selecció està tancada.

  2. To create the mask from your selection, press Enter, or double-click inside the selection:

    The mouse pointer now changes into a Paintbrush icon with a circle. The dark blue area (this color can be changed) shows the background. The lighter area covers the zone you have selected as foreground and a small part of background. Outside the selected area, the dark blue area is called the «Unknown pixels area».

    The options in the small window on top of the image become active:

    • A Preview mask checkbox that toggles displaying a preview of the foreground extraction status. The same can also be done by pressing the Enter key.

    • Un botó de Selecció que s'utilitzarà per a crear l'extracció després de marcar el primer pla.

  3. Now we start the actual foreground extraction process: draw a line through the foreground. The size of the brush can be changed in the Tool Options area. Draw a continuous line over the selected foreground area moving over colors which will be kept for the extraction. The color used to draw the line is not important, but not using the same color as the foreground makes it easier to see. Be careful not to paint background pixels.

    With this one-color object, that is easy to distinguish from the background, a few strokes are enough:

  4. Toggle the preview button, or press Enter to verify the result.

    [Nota] Nota

    You can draw directly on this Preview mask and see the result immediately.

  5. When you are satisfied with the result, click the Select button, or press Enter to finalize the selection and finish the foreground selection operation. You can cancel the operation by pressing Esc.

2.8.3. Opcions

Figura 14.34. Opcions de l'eina de «Selecció del Primer Pla»

Opcions de l'eina de «Selecció del Primer Pla»

Les opcions de l'eina es mostren en una finestra enganxada sota la caixa d'eines quan s'activa una eina. També s'hi pot accedir des de la barra del menú imatge a FinestresFinestres acoblables Opcions d'eines que obre la finestra d'opcions de l'eina seleccionada.

Mode; Suavitza les vores
[Nota] Nota

Mireu Opcions d'eines de selecció Per a obtenir ajuda amb opcions comunes a totes aquestes eines. Ací només s'expliquen les opcions específiques d'aquesta eina.

Mode dibuix

Draw foreground: when selecting with a brush, what you draw will be considered part of the foreground, i.e. included in the selection.

Draw background: when selecting with a brush, what you draw will be considered part of the background, i.e. it will be excluded from the selection.

Draw unknown: When drawing on the background, outside the initial selection, it marks the drawn pixels as belonging to the foreground.

Amplada del traç

The size of the brush to select with.

Mode previsualitza
  • Color (default): the color of the selection preview mask; the current color is shown in the color swatch. You can change the color by clicking on it.

  • Grayscale: allows you to see the resulting mask in black and white. This preview is similar to a layer mask. It can be useful in images where foreground and background color are similar and difficult to distinguish. Available since GIMP 2.10.14.

Motor

This is the method that will be used to select the foreground. The default is Matting Levin, which usually gives the best results, but you can also try Matting global, especially if processing is slow and you are using larger images.

Levels (Matting Levin only)

The number of downsampled levels to use. Higher numbers can improve processing speed at the cost of using more memory. The default is 2 levels.

Active levels (Matting Levin only)

The number of levels to perform solving. Higher numbers can increase the selection a bit at the cost of slowing down processing. Setting this number higher than Levels has no effect. The default is 2 active levels.

Iterations (Matting Global only)

Higher values may improve the result at the cost of being slower. The default is 2 iterations.

2.8.4. Refinant l'extracció del primer pla

In a lot of images, distinguishing what is foreground or background can be difficult. Refining the selection allows you to extract these foregrounds. The procedure steps are the same as above, but, while drawing the foreground, you will often toggle Preview, use Zoom (+ key), switch to Draw background to delete unwanted background areas, and switch between Grayscale and Color preview mode.

Figura 14.35. «Draw background» Example

«Draw background» Example

On the left: drawing foreground by mistake went over the background area: a part of the background will be included in the foreground selection!

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

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


Figura 14.36. «Draw unknown» Example

«Draw unknown» Example

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

On the right: with Draw unknown option checked, draw on the unselected pixels to select them. This shows that they are now selected.