senguptaumd/background-matting — explained in plain English
Analysis updated 2026-06-26
Cut a person out of a portrait photo with natural hair edges by providing a matching clean background reference shot instead of a green screen.
Remove the background from a video clip and composite the subject onto a virtual scene without studio equipment.
Generate alpha mattes for a portrait dataset to use in training or evaluating other image segmentation models.
| senguptaumd/background-matting | lazovelko/pokemon-terminal | yanshengjia/ml-road | |
|---|---|---|---|
| Stars | 4,774 | 4,773 | 4,775 |
| Language | Python | Python | Python |
| Setup difficulty | hard | easy | easy |
| Complexity | 4/5 | 1/5 | 1/5 |
| Audience | researcher | developer | researcher |
Figures from each repo's GitHub metadata at analysis time.
Requires a GPU and a Python deep learning environment, also requires capturing a separate clean background reference photo for every scene.
This repository contains the code for a research project called Background Matting, published at the IEEE CVPR 2020 computer vision conference by researchers at the University of Washington. The project tackles a classic photography and video problem: how do you cleanly separate a person from their background so you can place them in front of a different scene? Traditional solutions use a green screen, which requires controlled studio lighting and a dedicated colored backdrop. Background Matting takes a different approach. Instead of a green screen, you capture two photos: one with the subject in frame, and one of the same background without the subject. The system compares these two images and uses a neural network to figure out precisely which pixels belong to the person, including difficult areas like hair, which would normally be hard to cut out cleanly. The output is called an alpha matte, which is a map that describes how transparent each pixel is at the boundary between the subject and background. With this matte, you can composite the subject onto any background you choose, with realistic edges that look natural rather than jagged or blurry. The code supports both photos and videos. For photos, you provide a subject image, a matching background image, and a target background. A setup step runs a segmentation model to roughly identify the person, then aligns the background image to the subject image to account for any camera movement between shots. Running the main script then produces the composited output. The repository also notes that a newer version of the project, Background Matting V2, has been released separately with better quality and real-time performance at high resolutions. The original version covered here is the initial research release and is intended for non-commercial use under a Creative Commons license.
Background Matting is a research tool that cleanly cuts a person out of a photo or video using two images, one with and one without the subject, instead of a green screen, then composites them onto any new background.
Mainly Python. The stack also includes Python, PyTorch, OpenCV.
Free for personal and research use only, commercial use is not permitted under the Creative Commons non-commercial license.
Setup difficulty is rated hard, with roughly 1h+ to a first successful run.
Mainly researcher.
This repo across BitVibe Labs
Verify against the repo before relying on details.