Stepok Image Lab

Home - Help - Background - Matting and Composition

What is Image Re-composition?

'Image re-composition' consists of two steps: separating objects from their original photo ('Image Matting' as its scholarly name or 'Photo Masking' as its general name) and placing them into others (composition). The generalized 'Image Processing' includes two aspects: 'Image Enhancement/Adjustment' which changes the presentation of a image , and 'Image re-composition' which changes the contents of an image.

There are two basic, but significant concepts you need to know about image re-composition: background and foreground (the object). In most cases, the background is a regular image, while the foreground object has no regular shape. When the foreground object is separated from its background image, it is called the matting result.

The foreground object can be hard to understand by a beginner, as it introduces a new concept: the 'mask'. The mask is a channel (usually it’s called the alpha channel) with the same width and height of the foreground image, and defines where the foreground pixels should be transparent, opaque, or between them (semi-transparent). With transparent pixels, the user will see the background color, while with opaque pixels they will see the foreground object’s color. With semi-transparent pixels, a blending color of both foreground and background will be shown. 

In image re-composition software, the foreground objects and their masks are contained in data structures called the ‘Layers’. The background is a special layer with no mask, called the 'Base Layer'. The foreground objects, as sometimes there are several objects, exist in different layers over the base layer. By such a structure, the user can edit different layers separately. The layer in editing is called the 'Current Layer'. After the editing work is done, a merge operation will flatten all the layers into one image. 

The following figure demonstrates the relationship between layers in a 3D space and how these layers will appear in the user interface of the program.

What is Matting?

A photo is the a image of the projection of the real 3D world. A photo with foreground subjects can be treated as a composed image. Selecting and separating the subject(s) from the background is the inverse processing of composition/projection. The 'Image Matting' means the process of accurately estimating the foreground object in images.

There are 3 steps involved:

  • Find the edge of the subject. 
  • Determine its opacity (transparent, semi-transparent or opaque) for each pixel. 
  • For semi-transparent pixels, reverse-calculate its original colour from the blended colour. 

The third step may be the hardest step to understand. Why do we need an inverse calculation? See the following example: 

The pixels in the semi-transparent area should be white, as in their original color. But since it's semi-transparent, the final color is blended with green (the background color). If we generate this without an inverse calculation, and then place it into any other background color except green, you will see the wrong green pixels as the remaining of the original background. A reverse calculation will be based on the opacity and current background color (the area where you are placing it) to generate the real foreground color, which should be white.

And this is also the reason why you need a photo masking program instead of simply selecting an area and copy/paste in photoshop. A simple copy/paste will not reverse calculate the foreground color which may bring terrible re-composition results on edge, as explained above.

Copyright 2002-2023,Stepok Image Lab, All rights reserved