Blog

How Smart Erase Works Without AI: Background Models and Harmonic Fill

Written by InSnap · Published · smart erase, inpainting, screenshot editing, algorithm, on-device

How Smart Erase Works Without AI: Background Models and Harmonic Fill

Smart Erase uses no AI model: it measures the background around your box, finds what does not belong and fills the gap mathematically. How it works, and where it fails.

Smart Erase in InSnap does not use a neural network or a downloaded model. It is a plain image algorithm that runs on your computer: it measures the background around the box you draw, decides which pixels inside the box are not background, and fills them by solving an equation. This article walks through those steps, how it behaves on photos, and where it gives up.

Why not an AI model?

Three practical reasons shaped the design. A segmentation model adds a large download. Its licence and platform support have to work on both Mac and Windows. And the result should look the same on every machine. Screenshots are mostly text and interface elements, and a model trained to find "subjects" in photos is not built for that.

So the tool answers a narrower question: what colour should the background be at this spot, and which pixels disagree with it?

Step 1: Measure the background around the box

The algorithm looks at a ring just outside the box. Along each side it takes the median colour per row or column, which gives four smooth profiles. Two details matter here:

  • It starts a margin away from the edge. Pixels touching the box border are often part of the object you want gone, so sampling them would paint that colour across the gap.
  • It uses the median, not the average. In a real screenshot test, text falling inside the sampling band pushed the mean deviation to 9.35 while the median stayed at 0. A mean-based threshold would have been too forgiving and missed faint text.

Step 2: Decide what is foreground

For each pixel inside the box, the algorithm computes the background colour it would expect there by blending the four profiles by distance, then compares the real pixel with that expectation. A pixel that differs by more than about twice the background noise, with a floor of 12 grey levels, counts as foreground. That floor is low on purpose: light-grey caption text on white often differs by only about 20 levels, and a looser threshold leaves it behind.

If more than about 35% of the box is foreground, or nothing is found, the whole box is repainted. Otherwise only the foreground pixels are filled, which keeps the untouched background pixel-for-pixel.

Step 3: Grow, then clean the border

When the box cuts through an object, part of it sits outside. The mask grows outward through pixels that still do not look like background, up to a limit.

Before solving, any pixel outside the mask that does not look like background (a neighbouring title or border) is replaced by the predicted background colour in a working copy. That matters for the next step.

Step 4: Fill by solving a smooth surface

The gap is filled with a harmonic solution: the smoothest set of colours that matches the border on all sides, like a soap film stretched over a frame. It is solved on a coarse grid first and refined step by step.

This also explains the border cleanup. A harmonic fill is a membrane: if the border is five grey levels darker because of a neighbouring object, the whole filled area ends up five levels darker. Cleaning the border first prevents a grey patch.

Smart Erase removing an item and rebuilding the background

Textured backgrounds use a different path

A smooth membrane looks wrong on a photo, so when the ring around the box has noticeable colour variation the tool switches approach:

  1. It separates the subject from the background on a downscaled grid, using colour models of the ring and the box centre and a minimum-cut step, in the spirit of GrabCut.
  2. It fills the hole with patches copied from the background around it, working from coarse to fine detail, using only patches that lie entirely outside the hole.

Segmentation depends on colour. If the subject and background are close in colour, it can miss part of the subject, which is why the tool has a whole-box mode that repaints everything inside the box.

What it never touches

Pixels outside your box are not changed. The algorithm may use a wider area while solving, but when the result is written back it is clipped to the box, and tests check this pixel by pixel. The algorithm is also deterministic, so the exported image matches what you saw on screen.

Speed and limits

On our development Mac a typical 440 × 340 box takes roughly 20 ms in an optimised build. Very large boxes take longer.

SituationWhat to expect
Flat colour, gradient, interface backgroundClean result
Text or icon over soft shadowUsually clean
Photo or fabric textureA believable patch, not an exact copy
Subject close in colour to backgroundUse whole-box mode
Object extending far beyond the boxThe part beyond a limit stays; draw a bigger box

If you only need to hide something rather than rebuild the background, Mosaic and Blur are separate tools that do not need Pro.

Mosaic and Blur for hiding instead of erasing

What needs Pro

Smart Erase is a Pro tool, part of a one-time purchase of $9 for up to three devices. The first Pro feature you open offers a 7-day trial that needs no account.

FAQ

Is Smart Erase powered by AI?

No. It is a classical image algorithm: background measurement, a foreground test and a smooth-surface fill, plus patch copying on textured backgrounds. No model is downloaded and nothing is generated.

Does Smart Erase upload my screenshot?

No. It runs on your computer. A screenshot only leaves your machine if you choose to share it.

Why does a faint edge remain after erasing?

The foreground test has a threshold. If the leftover is very close to the background colour, or the object extends beyond the grown area, a trace can stay. Draw the box slightly larger or use whole-box mode.

Can I undo a Smart Erase?

Yes. It behaves like the other annotation tools: undo restores the original pixels.

Your next screenshot is one hotkey away.

macOS 14.4+ (Apple Silicon & Intel) · Windows 10+ (64-bit)