PIXELBANKv8.2.1
Menu

Alpha Matte Compositing

MediumMatting

Implement alpha compositing for foreground/background blending, a key technique in image matting. This process involves combining a foreground image with a background image using a matte, which is a grayscale image defining the opacity of the foreground.

The matte, represented by α\alpha, is used to control the blending of the foreground and background colors. The compositing equation is based on the principle of linear blending, where the resulting color is a weighted sum of the foreground and background colors.

  1. Define the foreground, background, and matte images.
  2. Apply the compositing equation to each pixel.
C=αF+(1α)BC = \alpha F + (1 - \alpha) B

This technique is widely used in digital image editing.

Example:

Input:
foreground = person image
background = beach scene
alpha = person matte (1 inside, 0 outside)
Output:
Person composited onto beach
Reasoning:

For each pixel:

  • Where alpha=1: use foreground
  • Where alpha=0: use background
  • Where 0<alpha<1: blend smoothly

Constraints:

  • foreground: Foreground image (H, W, 3)
  • background: Background image (H, W, 3)
  • alpha: Alpha matte (H, W) in [0, 1]
  • Return: Composited image
Editor

Test Results

0/0
Run code to see test results.