Skip to content
Bulk orders? WhatsApp us
Toolsshark

Experiments

Removing backgrounds without AI: how far colour distance gets you

An experiment in background removal with no machine learning — just flood fill and colour distance. How it works, where it excels and where it fails.

Published
10 Sept 2026
Reading time
2 min
By
Toolsshark Lab

Machine-learning background removal is impressive, but it needs a large model download or a server round-trip. For a large class of images — product shots on seamless paper, logos on white, screenshots on flat colour — a much simpler approach works well and runs instantly on any device.

How it works

  1. Sample the background colour — by default, from the image's border pixels; or from a point you click.
  2. Starting from every border pixel that matches, flood-fill inwards across neighbouring pixels whose colour is within a distance threshold.
  3. Mark every reached pixel as background and make it transparent.
  4. Soften the edge: pixels near the boundary get partial transparency based on how close their colour is to the background.

Colour distance is measured as Euclidean distance in RGB space. It is not perceptually uniform, but for separating a subject from a near-uniform background it is fast and good enough.

Why flood fill, not a global colour key

A global colour key removes every pixel that matches the background colour — including white highlights inside a white product. Flood fill only removes background that is connected to the edges of the image, so enclosed areas of the same colour survive.

Where it works well

  • Studio product photography on seamless backgrounds
  • Logos and illustrations on flat colour
  • Interface screenshots
  • Scanned signatures and line art on paper

Where it fails

  • Busy or photographic backgrounds
  • Subjects whose edges are the same colour as the background
  • Fine hair and fur against similar tones
  • Strong gradients or vignettes, unless tolerance is raised (which then eats into the subject)

The result is honest about its scope: instant and private for the images it suits, and clear about the ones it does not.

For portraits, hair, busy backgrounds and everything else this method cannot handle, a segmentation model does far better. bgremoved.pro runs one in your browser, so images still never leave your device — it is the Background Remover we now link to from Toolsshark Tools.

Keep reading

All articles