8.55. Colore ad alfa...

8.55.1. Panoramica

Il filtro Colore ad alfa rende trasparenti tutti i pixel del livello attivo che abbiano un colore selezionato. Il filtro proverà a mantenere l'anti-aliasing usando un algoritmo parzialmente intelligente che sostituirà le gradazioni verso il colore selezionato con gradazioni verso la trasparenza. In questo modo, le aree che contengono un elemento del colore selezionato, manterranno l'effetto di dissolvenza con i pixel circondanti.

[Nota] Nota

Questo comando normalmente è disabilitato: è necessario aggiungere un canale alfa per poterlo usare.

8.55.2. Attivazione del filtro

Questo filtro si trova nel menu immagine sotto ColoriColore ad alfa....

8.55.3. Opzioni

Figura 16.247. Opzioni del comando «Colore ad alfa»

Opzioni del comando Colore ad alfa

Preimpostazioni, Anteprima, Dividi vista

Queste opzioni sono comuni ai filtri basati su GEGL. Fare riferimento a Sezione 2, «Caratteristiche comuni».

Colore

Clicking on the color swatch provides a color selection dialog where you can select a color. You can also select a color using the eye dropper on the right.

«Color to alpha» comes with a GEGL option dialog under Toolbox. When the Sample merged option is unchecked, color picker picks only one pixel color. When the option is checked, mouse pointer goes with a square limiting a pixel sample that determines a merged sample «color». You can fix square size directly in text box, or using arrow heads, or Up and Down keyboard keys.

Right clicking on the color swatch will display a menu where you can select Foreground or Background colors, White or Black.

Transparency and Opacity thresholds
  • Transparency: the limit below which colors become transparent.

  • Opacity: the limit above which colors become opaque.

Color to Alpha modifies the transparency (and color) of the pixels based on their distance from the selected background color (the "Color" option) -- the closer they are to the background color, the more transparent they become, with the background color becoming fully transparent.

The transparency and opacity thresholds control how close colors should be to the background color before they become fully transparent, and how far they should be from the background color before they remain fully opaque, respectively. With the default values of 0 and 1, only the background color becomes fully transparent, and only the colors farthest away from the background color remain fully opaque.

For example, while the default values work well for removing a white background from a black object, if the object is gray instead [fig. 1] it will become semi-transparent [fig. 2], since gray is midway between white and black. Lowering the opacity threshold to 0.5 fixes that, by keeping all pixels that are gray or darker (all pixels whose distance from white is 0.5 or more, on a [0,1] scale) fully opaque [fig. 3].

The transparency threshold works similarly: raising it causes more colors in the neighborhood of the background color to become fully transparent. This is mostly useful with noisy images, in which the background is not fully solid. However, unlike in other cases, when the transparency threshold is above 0, recomposing the result against the background color no longer reproduces the exact same image.

At the risk of being a bit technical, this can be visualized by thinking of the RGB cube. The background color is a point within the cube, and the transparency and opacity thresholds are two sub-cubes centered around the background color. Everything inside the transparency-threshold cube becomes fully transparent, everything outside the opacity-threshold cube remains fully opaque, and everything in between gradually transitions from transparent to opaque. In image [fig. 4] you can see the Red-Green face of the RGB cube. (1) is the background color (Red=0.5, Green=0.5, Blue=0.0), (2) is the transparency threshold (set to 0.1), and (3) is the opacity threshold (set to 0.4).

Figura 16.248. Esempi di soglia Colore ad alfa

Esempi di soglia Colore ad alfa

fig. 1

Esempi di soglia Colore ad alfa

fig. 2


Figura 16.249. Esempi di soglia Colore ad alfa

Esempi di soglia Colore ad alfa

fig. 3

Esempi di soglia Colore ad alfa

fig. 4


8.55.4. Usare Colore ad alfa

  1. Add an alpha channel to your image if necessary (Layer > Transparency > Add Alpha Channel).

  2. Aprire Colore ad alfa.

    Figura 16.250. Colore ad alfa aperto con le opzioni predefinite

    Colore ad alfa aperto con le opzioni predefinite

    Immagine originale con un canale alfa

    Colore ad alfa aperto con le opzioni predefinite

    Original image with an alpha channel. Color to alpha with default options : «Color» is white. Opacity threshold = 1.00 is maximum, and so only the colors farthest away from the «Color» remain fully opaque. Transparency threshold = 0 and so the «Color» is fully transparent.


  3. Deselezionare l'opzione anteprima.

  4. Prelevare un colore, qui il cielo.

  5. Ri-abilitare l'opzione anteprima.

    Il «colore» dal cielo. Soglie predefinite.

  6. Regolare le soglie di trasparenza e opacità procedendo per tentativi ed errori.

    Only sky is transparent. Opacity threshold decreased to make farthest colors (monument,trees and road) fully opaque. Transparency threshold increased to make «Color» fully transparent and delete some imperfections in sky.