Background removal without a green screen is an underdetermined problem. Here's what the maths is doing.
Every pixel in a photograph of a person against a wall is a blend of two things. The compositing equation is the whole problem in one line: C = αF + (1 - α)B C is the pixel you can see. F is the foreground colour, B is the background colour, and α is how much of that pixel belongs to the foreground. Solid shirt, α is 1. Empty wall, α is 0. A single strand of hair crossing that pixel, α is 0.3 and…
Every pixel in a photograph of a person against a wall is a blend of the person's color and the wall's color. The compositing equation tells us how much of each color is present in each pixel. With a green screen, the background color is known, which allows us to solve for the person's color at each pixel. The problem becomes underdetermined without a green screen, requiring additional constraints to find a solution.
Green screening, or chroma keying, eliminates the need for additional constraints by providing the background color. However, this method has limitations, such as spill from the green screen onto the subject, which requires additional processing to correct. Alternative methods involve segmentation, where a model directly outputs a mask for the person, or alpha matting, where the image is split into foreground, background, and unknown regions.
The quality of the final result depends on various factors, such as the distance between the subject and the wall, the contrast between the subject's hair and the background, and the presence of light sources. Proper shooting techniques can significantly improve the outcome when swapping backgrounds in photos.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.