Skip to content
GPU-assistedUpload required

Blur Behind a Subject Without the Halo

There is a specific artifact that gives away almost every fake background blur, and once you know it you cannot stop seeing it. A faint glow around the subject, the color of the subject, spreading a few pixels into the blurred area. It happens because the blur was calculated using pixels that belonged to the subject, and it is entirely avoidable if the mask is grown by at least the radius of the blur. This one is.

Use this without the search next time. Prathom Workbench puts Prathom's tools in your toolbar.

Add to Chrome — free

Drop an image here, or click to browse

Up to 25 MB. Uploaded temporarily, deleted after processing.

GPU-assisted — results vary slightly between runs.

What it does

  • Mask grown wider than the blur radius
  • No color bleed from subject into background
  • Subject stays exactly as photographed
  • No generative model in the chain

How to use Blur Background

  1. 1

    Know what real defocus looks like

    Optical blur increases with distance from the focal plane. A uniform blur across a deep room is the second give-away after the halo.

  2. 2

    Run the blur

    The subject is matted, the mask is grown well past the blur radius, the frame is blurred, and the sharp subject is composited back over it.

  3. 3

    Look at the silhouette, not the background

    The background will look soft either way. The question is whether there is a colored glow tracing the outline of the subject.

How it works

Your image is resampled to about two megapixels. A segmentation model produces a matte of the subject, and that matte is then grown outwards by more pixels than the blur radius that follows. The whole frame is blurred, and your original sharp image is composited back over it through the grown mask.

There is no generative model. The subject in the output is the subject you uploaded and the background is your background with a blur applied to it, so nothing in the picture has been invented.

The order matters and the growth amount matters, and between them they remove the artifact this page is named after.

The halo, and why it exists

A blur replaces each pixel with a weighted average of its neighbors. That is the whole operation, and it has no idea what a subject is.

So consider a pixel one step outside the subject's outline. Its neighborhood includes a good deal of subject, which means the average includes the subject's colors, which means the blurred value there is partly the subject. The same is true a few pixels out, less so, fading with distance until the blur radius is exhausted.

Paste the sharp subject back over exactly its own outline and all of that contaminated ring remains visible in the background, tracing the silhouette in a soft version of the subject's own color. A red jumper leaves a pink glow. Hair leaves a dark aura.

The fix is not a better blur, it is a wider paste. Grow the mask past the radius and the contaminated band is covered by original pixels. Everything that could have been polluted is simply not shown.

What a real lens does that this does not

Two differences remain, and being straightforward about them tells you when this page suits a photograph.

Blur varies with depth. Defocus grows the further something is from the plane of focus, so a real photograph of a corridor has a slightly soft near wall and an extremely soft far end. This applies one strength everywhere behind the subject, which is nearly correct for a background at a single distance and clearly wrong for a receding one.

Highlights become shapes. An out-of-focus point of light in a real lens is projected as a disc the shape of the aperture — round, or polygonal with visible straight sides. A gaussian blur has no aperture, so it turns a bright point into a fading smudge. Any scene with fairy lights, street lamps, or specular sparkle shows this immediately.

Neither is fixable without depth information and a different blur model, which is what a phone's portrait mode uses its multiple cameras to obtain.

Choose the photograph, not the setting

The practical consequence is that this works beautifully on some images and poorly on others, and you can tell which before you upload.

Good: a subject in front of a wall, a hedge, a crowd at one distance, a cluttered desk, a curtain. Everything behind them is at roughly one depth, so one blur is a fair approximation of what a fast lens would have produced.

Poor: a subject at the end of a long room, on a street stretching away, or in a landscape. The scene has depth and a single blur strength flattens it into a backdrop, which reads as a cutout on a soft picture rather than as a photograph with shallow focus.

Publication gate

This page ships once the workflow has been run against a subject in front of a wall, a subject in a receding corridor, a scene containing bright point lights, and a subject with loose hair, with every silhouette inspected at full size for a colored halo.

Examples

Portrait in a busy room

cafe.jpg - 2400x1600, cluttered background at one depth
prathom-blur-background.png - 1732x1155

The intended case. Everything behind the subject is at roughly one distance, so a single uniform blur is close to what a lens would have done.

Subject in a long corridor

hall.jpg - 2400x1600, background receding into the distance
hall-blur.png - 1732x1155

Reads as artificial. A lens blurs the far end far more than the near end, and a single blur strength applied to a receding scene contradicts that.

Frequently asked questions

What causes the glow around a badly blurred subject?

The blur averaging across the subject boundary. A blurred pixel just outside the outline is computed from a neighborhood that includes subject pixels, so the subject's color spreads outwards. Compositing the sharp subject back on top leaves that spread visible as a halo tracing the silhouette.

How is that avoided here?

By growing the mask further than the blur reaches. The subject is pasted back over a region wider than the radius of the blur, so every pixel that could have been contaminated is covered by original sharp image rather than by contaminated blur. It costs a slightly wider edge and removes the artifact.

Why does this look different from portrait mode on a phone?

A phone estimates the distance to every point in the scene and varies the blur accordingly, so things further away are blurred more. This has a matte, not a depth map, so everything behind the subject is blurred equally. On a shallow scene that is very close; on a deep one it is visibly not.

Can it replicate the shape of real bokeh?

Not really. A defocused point light becomes a disc shaped by the lens aperture, which is why out-of-focus highlights are circles or polygons with visible edges. A gaussian blur turns a highlight into a soft fading smudge instead. On scenes with bright points, that difference is obvious.

Is the AI Blur Background tool free, and do I need an account?

No sign-up. The blur background workflow takes an image up to 25 MB, runs it on the GPU host and hands back a file you can download directly. Nothing is charged and nothing is stamped onto the output. Because no account exists, nothing keeps your history either, so save the result within the thirty minutes the job is retained.