Image Compositing Operators

Introduction

In computer graphics, image compositing is a technique of combining two raster images to create a new resulting image. There are two different group of operations (modes): alpha compositing and color blending.

Alpha compositing (see Porter and Duff) is an operation which defines how two images are combined using only alpha components of the images.

Color blending is an operation which mixes the colors of two images by producing a new color.

In both modes, the first and the second colors presents the colors of the source and the destination images.

This article provides the full list of compositing modes available in MapSurfer.NET. This list consists of 46 operations in total, 11 operations in the alpha compositing and 35 in the color blending group respectively. In MapSurfer.NET compositing operations can be applied to two types of the objects, namely to layers and styles.

In order to demonstrate the effect of each mode, we first give a short description of each operator and visually present a resulting image obtained by applying this operator to the pair of the following images (source and destination).

Example Images

    

    

Alpha Blending

Source

The source is copied to the destination.

    

SourceOver

The source is drawn on top of the destination.

    

SourceIn

The part of the source that overlaps the destination replaces the destination.

    

SourceOut

The source is drawn on top of the destination only in regions where the destination is transparent.

    

SourceATop

The source is drawn on top of the destination in regions where it intersects the destination.

    

Destination

The destination is left unchanged, i.e. the source is not taken into account.

    

DestinationOver

The destination is drawn on top of the source.

    

DestinationIn

The destination is drawn only in regions where it overlaps the source.

    

DestinationOut

The destination is drawn only in regions where the destination does not overlap the source.

    

DestinationATop

The destination is composited over the source in regions where it overlaps the source. Source is placed elsewhere.

    

Xor

The Xor operator, also known as 'exclusive or', combines the non-overlapping regions of the source and the destination.

    

Color Blending

Clear

Both the color values and the alpha of the destination are cleared.

    

Plus

The source is added to the destination and replaces the destination. This operator is useful for animating a dissolve between two images.

    

Minus

Adds the values of the source and base colors and subtracts 255 from the result. Because this merge mode treats the color channels as subtractive, the result color is never lighter than the base color.

    

Multiply

The source color is multiplied by the destination color and replaces the destination.

    

Screen

Multiplies the complements of the destination and source color values, then complements the result. The result color is always at least as light as either of the two constituent colors. Screening any color with white produces white; screening with black leaves the original color unchanged. The effect is similar to projecting multiple photographic slides simultaneously onto a single screen.

    

Overlay

Multiplies or screens the colors, dependent on the destination color. Source colors overlay the destination whilst preserving its highlights and shadows. The destination color is not replaced, but is mixed with the source color to reflect the lightness or darkness of the destination.

    

Darken

Returns the darker of the source and the destination colors. The destination is replaced with the source when the source is darker, otherwise it is left unchanged.

    

Lighten

Returns the lighter of the source and the destination colors. The destination is replaced with the source when the source is lighter, otherwise it is left unchanged.

    

ColorDodge

Brightens the destination color to reflect the source color. Painting with black produces no change.

    

ColorBurn

Darkens the destination color to reflect the source color. Painting with white produces no change.

    

HardLight

Multiplies or screens the colors, dependent on the source color value. If the source color is lighter than 0.5, the destination is lightened as if it were screened. If the source color is darker than 0.5, the destination is darkened, as if it were multiplied. The degree of lightening or darkening is proportional to the difference between the source color and 0.5. If it is equal to 0.5 the destination is unchanged. Painting with pure black or white produces black or white.

    

SoftLight

Darkens or lightens the colors, dependent on the source color value. If the source color is lighter than 0.5, the destination is lightened. If the source color is darker than 0.5, the destination is darkened, as if it were burned in. The degree of darkening or lightening is proportional to the difference between the source color and 0.5. If it is equal to 0.5, the destination is unchanged. Painting with pure black or white produces a distinctly darker or lighter area, but does not result in pure black or white.

    

Difference

Subtracts the darker of the two constituent colors from the lighter. Painting with white inverts the destination color. Painting with black produces no change.

    

Exclusion

Produces an effect similar to that of Difference, but appears as lower contrast. Painting with white inverts the destination color. Painting with black produces no change.

    

Invert

This mode blends an inverted version of the destination with the original destination color under control of source alpha.

    

InvertRGB

    

GrainExtract

Extracts the “film grain” from a layer to produce a new layer that is pure grain, but it can also be useful for giving images an embossed appearance. It subtracts the pixel value of the source from that of the destination and adds 128.

    

GrainMerge

This mode is the opposite of “Grain extract”. It adds the pixel values of the source and destination together and subtracts 128.

    

Hue

Creates a resulting color with the luminance and saturation of the destination color and the hue of the source color.

    

Saturation

Creates a resulting color with the luminance and hue of the destination color and the saturation of the source color. Painting with this mode in an area with no (0) saturation (grey) causes no change.

    

Color

This mode uses the hue and saturation of the source and the value of the destination to form the resulting image.

    

Value

This mode uses the value of the source color and the saturation and hue of the destination color to form the resulting image. You can use this mode to reveal details in dark and light areas of an image without changing the saturation.

    

LinearDodge

This mode is a combination of the color dodge and screen modes. Sometimes refered to as Add mode (not the same as additive mode).

    

LinearBurn

This mode is a combination of the color burn and multiply modes.

    

VividLight

This mode is a combination of the color burn and color dodge modes; color burn is used to darken the destination color if the src color is darker than mid-grey, color dodge is used to lighten the destination color if the source color is lighter than mid-grey.

    

LinearLight

This mode is a combination of the linear burn and linear dodge modes; linear burn is used to darken the destination color if the source color is darker than mid-grey, linear dodge is used to lighten the destination color if the source color is lighter than mid-grey.

    

PinLight

Replaces the colors, depending on the blend color. If the blend color (light source) is lighter than 50% gray, pixels darker than the blend color are replaced, and pixels lighter than the blend color do not change. If the blend color is darker than 50% gray, pixels lighter than the blend color are replaced, and pixels darker than the blend color do not change. This is useful for adding special effects to an image.

    

HardMix

This mode posterizes the destination color and blends with the source color using Vivid Light mode, such that the output consists of only the 6 primary colors (RGBCMY), white, and black.

    

Glow

This mode is a variation of reflect mode (the source and destination colors are swapped).

    

Reflect

This mode is used for adding shiny objects or areas of light.

    

Freeze

Another variation of reflect mode; the destination and source colors are inverted, the resulting color is inverted again.

    

Heat

Another variation of reflect mode. It is like freeze mode, but the destination and source colors are swapped.

    

Phoenix

This mode substracts lighter pixel from the darker pixel, and adds 255, giving a bright result.

    

Stamp

This is helpful when applying relief or bump textures to images. Gray blend colors do not change the background, brighter or darker colors make the background brighter or darker.