Alpha blending

from Wikipedia, the free encyclopedia

Alpha blending is a technique in image or video processing in which different images are superimposed to form an overall image, whereby the alpha channel is also taken into account in addition to the color information .

The alpha value of an image point ( pixel ) is a measure of the transparency or opacity . An α value of 0 stands for complete transparency, the pixel becomes invisible. An α of 1 stands for complete opacity, the pixel overlays all image points behind it.

calculation

If you have given two colors A and B and want to place A over B, use the following equation to get the new value for the non-transparent end color C:

.

An expression of the shape is also called a convex combination .

It is thus possible to convert an RGBA into an RGB value without simply cutting off the α channel.

Example: A transparent purple (0.5,0,1,0.75) on a white background (1,1,1) then gives (0.625,0.25,1).

In contrast, the Porter-Duff algorithm is suitable for blending two transparent colors . The final color C is calculated

,

and the transparency of the final color is determined by it

This corresponds to the A over B operation in the adjacent picture. This algorithm is used in the PDF and SVG formats.

Example: Fading a transparent blue (0,0,1,0.5) over a transparent red (1,0,0,0.5) results in a transparent purple ( , 0 ,, 0.75).

In some raster graphics formats, α can only take the values ​​0 or 1. In this case, a pixel is either completely invisible or completely opaque. The GIF format is an example of this.

Different blending methods

In addition to this type of calculation, the colors A and B can be combined in other ways. A wide variety of effects are achieved with this. One could e.g. B. form the difference between the color values, fade in A only where the α-value of B is not 0, etc.

Areas of application

Image composition

One of the main uses of alpha blending is image composition: As with a photo montage , an object is to be cut out of an image and inserted into a new image. To do this, the alpha channel of the image must be edited accordingly with the image to be cut out. If the object is cut out using conventional methods, the transparency cannot be taken into account. Instead, a corresponding alpha value is set for each pixel. If the alpha channel is represented graphically by interpreting the values ​​as gray levels between black and white, the so-called alpha matte is obtained. The process of creating this mask is called "pulling the matte" or matting . Until recently, most of the mat had to be created by hand, as there were no powerful algorithms with satisfactory results. However, the SIGGRAPH conferences in 2004 and 2005 presented promising approaches such as Bayesian matting and Poisson matting .

Most image editing programs such as GIMP or Photoshop support the separate editing of the alpha channel via layer masks. So you can edit the transparency of an object directly with the known painting tools.

Computer graphics

Alpha blending is used in computer games and other graphics applications to model the transparency properties of objects. A tinted window pane would simply be saved and displayed as a colored area with a low α. To do this, the first completely opaque object is searched for in the field of view. From this point on, the convex combination presented above is successively formed with the color values ​​of the other objects. With high color , a maximum of 1 bit is available for the alpha channel, with true color it is 8 bits.

See also

literature

  • Thomas Porter, Tom Duff: Compositing digital images. In: SIGGRAPH 1984 Proceedings. Association for Computing Machinery, New York 1984, ISBN 0-89791-138-5 , pp. 253–259 (English, Volume 18, Number 3, July 1984 [PDF; 732 kB ; accessed on December 6, 2016]).