A flat background comes off; a photographed one is a different problem
Two quite different jobs hide under the words "remove the background". One is arithmetic and the other needs a model. This tool does the first.
How the background is found
The outer ring of pixels is sampled. On a logo or an icon that ring is almost entirely background. Similar colours are grouped, the largest group is taken as the background colour, and the share of the ring it occupies becomes a confidence.
Only what is connected
| Approach | What goes | What else goes |
|---|---|---|
| Only the connected region (this tool) | Background reachable from the edge | Nothing |
| Every matching pixel | Every background-coloured pixel anywhere | The whites of eyes, the holes in letters, a white shirt |
The second is simpler, which is why many tools do it, and it is how characters end up with holes where their eyes were. This one starts at the edge and follows connected pixels, so the same colour inside the picture is left alone.
What the tolerance does
Backgrounds are rarely one exact colour. Anything that has been through a JPEG has a "white" that wobbles slightly. Tolerance decides how much wobble still counts as the same colour. Too low leaves a fringe of background; too high starts claiming the bright parts of the picture.
Where this approach stops working
| Background | Works |
|---|---|
| Flat colour (logos, icons, scans) | Yes |
| Nearly flat (JPEG noise) | Yes, with more tolerance |
| A gradient | No |
| A photograph (cutting out a person or product) | No |
Cutting a person out of a photograph is not a colour problem. It needs a model that knows where the person ends, which is a separate technology that has to be downloaded into the browser. This tool does not do that, and does not pretend to.
Why the result is always a PNG
What was removed has to become transparent, which requires a format that can hold transparency. JPEG has no alpha channel at all, so it is not a candidate. What each format can carry is set out in choosing an image format.
Back to PrismMesh