What is Matting?

Image matting is the task of separating the foreground from the background in ordinary photos or images, without any special setup like shooting on a green screen.

Most so-called "background removal services" are built on matting.

The goal is to cut out even fine details like hair as naturally as possible. Instead of a simple binary (black-and-white) mask, it produces a mask that also carries semi-transparency, called an alpha matte.


BiRefNet

BiRefNet is a family of foreground extraction models: high-accuracy models specialized for background removal and matte generation.

It's lightweight and performs well, so for matting you can't go wrong with BiRefNet.

birefnet_general.json

There are several variants, but start with general. It handles a wide range of subjects, including people, objects, and animals.


SDMatte

SDMatte is a matting model that draws on what Stable Diffusion knows.

sdmatte.json

It can cut out the foreground just like BiRefNet, but what sets it apart is that it can handle see-through things like glass bottles, liquids, and thin fabric, at least to some extent.

Like any diffusion-based model, it's computationally expensive, but give it a try when you need to cut out transparent or semi-transparent objects, or extremely fine things like the tips of hair.