How AI Background Removal Works: Segmentation, Matting and Edge Quality
In one sentence: a background remover is a neural network that predicts, for every pixel of the photo, how much it belongs to the subject — and then writes that prediction into an alpha channel that compositing software can read. Everything else is engineering. This article walks through the three pipeline stages, explains why hair and glass are hard, and shows what changes when the network runs on your device instead of on a company's server — which is how Tatovio works.
Stage 1 — Segmentation: deciding what the subject is
The first stage answers the question "which pixels are the subject?". Modern background removers use salient object segmentation networks trained on millions of annotated images. The model encodes the photo into visual features, then decodes a probability map — essentially a heatmap where 1 means "definitely subject" and 0 means "definitely background". Tatovio's default engine, BRIA RMBG-1.4, is exactly this kind of model, executed via Transformers.js v3 on ONNX Runtime Web. Segmentation answers what, but a binary map produces hard edges — which is why a second stage exists.
Stage 2 — Alpha matting: the soft edge layer
Real edges are not binary. A strand of hair is a mix of subject and background; the glass of a perfume bottle is mostly background showing through. Alpha matting assigns each boundary pixel a fractional opacity between 0 and 1 instead of a yes/no verdict. This fractional alpha is what later lets a cutout sit on any new background without a hard cut-line. Tatovio's second engine, IMG.LY ISNet (FP16), specialises in these soft matte edges — it is the engine to pick for portraits with flyaway hair, furry products, or semi-transparent glass and liquids.
Stage 3 — Compositing: putting the subject somewhere new
The cutout is only useful once it is composited: the alpha map multiplies the subject's pixels, and the result is drawn over a new canvas — transparent (a PNG with a real alpha channel), pure white (#FFFFFF for marketplace main images), a colour, a photo, or a painted studio scene. Quality at this stage is geometry, not AI: the subject must be grounded (touching the surface it is supposed to stand on), and any shadow or reflection must follow the actual silhouette. That is why Tatovio computes contact shadows and mirror reflections from the cutout's own shape rather than stamping a generic ellipse under it.
| Stage | What it decides | Where it goes wrong |
|---|---|---|
| Segmentation | Which pixels belong to the subject | Low contrast between subject and background; multiple overlapping objects |
| Alpha matting | How transparent each edge pixel is | Hair strands, fur, glass, motion blur |
| Compositing | Where the subject sits in the new scene | Floating products, wrong shadow direction, mismatched perspective |
Why running the model locally changes everything
Most online background removers upload your photo to a server, run a GPU model there, and send the result back. That design has three costs: a privacy exposure (your photos live on someone else's infrastructure), a per-image pricing model (servers and GPUs are expensive), and latency on every single cutout. Running the same class of networks in the browser — via WebAssembly and ONNX Runtime Web — inverts all three: photos never leave the device, there is no per-image server cost (which is why Tatovio can be genuinely free with no watermark), and after the model is cached, cutouts work offline. The trade-off is honest: the first session downloads the model weights, and very old browsers without WebAssembly support cannot run the local engines at all.
Where AI still struggles (and the manual fix)
- Subject blends into the background. A white shirt on a white wall defeats low-contrast segmentation; reshoot with separation, or restore the missing area with Tatovio's Magic Brush after the cutout.
- Motion blur. A blurred edge has no stable boundary to matte; sharp sources always beat software fixes.
- Tiny repeated details (chains, lace, grille). Expect to touch up a few spots manually — the Magic Brush Erase/Restore strokes plus undo history handle it in seconds.
- Logos printed on a transparent surface. The matte is correct but the design shows through; pair the ISNet engine with the Object Eraser for content-aware removal.
Five terms, plainly defined
- Segmentation — per-pixel classification of an image into regions (here: subject vs background).
- Alpha channel — an extra per-pixel value (0–1) encoding transparency; PNG files store it, JPG does not.
- Alpha matting — computing accurate fractional alpha values along soft edges like hair.
- WebAssembly (WASM) — a fast, sandboxed execution format for browsers; it is how multi-megabyte neural networks run locally on a web page.
- ONNX Runtime Web — a browser engine for executing neural-network models exported to the ONNX format, on CPU or WebGPU.
See the pipeline live: Try the in-browser AI The practical 4-step guide
Keep reading
Remove Backgrounds from Product Photos in 4 Steps
Apply the pipeline: cutout, scene, shadow, marketplace export.
Buying GuideHow to Choose a Free Background Remover
Seven criteria, including where the processing actually happens.
MarketplacesWhite Background Requirements by Marketplace
What Amazon, eBay and Etsy expect from a main listing image.