Urgent.News

What's breaking now, across hundreds of outlets.

Tech

Before you ship background blur, price the halo fix: about 2.5x CPU per 1080p frame

If you let a user blur the background behind a matted person, the fix for the glow around their shoulders is not free. On 1080p frames, filling the person's hole with Telea inpainting before the blur took 398.0 ms per frame on the CPU, against 162.4 ms for the plain blur. That is about 2.5 times. On a simple wall it removed nearly all of the halo. On a busy bookshelf it removed much less, and in…

When you add background blur to a person in a video, the glow around their shoulders that results is not free. On a 1080p frame, filling the person's hole with Telea inpainting before applying the blur takes 398.0 ms on the CPU, compared to 162.4 ms for a plain blur – about 2.5 times longer. The halo's intensity varies depending on the background, with it being removed almost entirely on a simple wall but having little effect on a busy bookshelf in some cases.

However, in one scenario, it even made things worse. The halo originates from the person's color mixing into the background, with darker jackets creating darker edges and brighter jackets causing brighter rims. The stronger the blur, the larger the halo becomes, reaching up to 66 pixels in width for a Gaussian sigma of 40. There is a noticeable threshold around sigma 2.3 where the halo's impact becomes noticeable.

Implementing the fix – removing the person first, filling the hole with Telea, then blurring and pasting back the person – reduces the halo's visibility significantly. For instance, on a black figure against a light wall, the first 4-pixels error decreases from 21.53 to 0.53. This is particularly relevant for products offering a strength slider, as the top of the slider is where the halo's cost becomes too high to ignore.

There are three key risks to consider before committing to this fix: a mask that is too small can leave an edge in the background, making the error only slightly reduce; increasing the hole's size doesn't always guarantee a better result; and feathering the edge does not improve the background fill. Importantly, Telea and normalized convolution estimates do not recreate the real background behind the person, which may be a limitation to keep in mind.

A practical budget rule is that at 1080p, plain blur takes 162.4 ms per frame on one CPU thread, normalized convolution takes 389.8 ms, and Telea takes 398.0 ms. For a 10-second clip at 30 fps (300 frames), the approximate CPU time would be around 49 seconds for plain blur and 119 seconds for the other methods. ImgIng, a video matting service, has a beta version that experiences similar halo issues, which can be addressed by exporting a transparent video (WebM) and applying the fix on your own system.

However, keep in mind that these numbers are estimates based on OpenCV on a CPU, an Apple-silicon Mac, and one run, and do not account for GPU acceleration or browser performance.

Rewritten by urgent.news; may contain errors — check the original.

Source: dev.to

Read the original at dev.to →

Report a problem with this story

More in Tech

What Is Running in the Background of Your Mac?

Why I built Daemon Inspector, what it found on my own Mac, and what the App Sandbox taught me along the way. What Is Running in the Background of Your Mac?Every Mac runs dozens of programs you never…

  • Daemon Inspector reveals hidden background programs on Mac
  • Categorizes items by owner, necessity, and status
  • Provides commands to disable/remove items safely

Bind a license to a key the device holds

A hardware fingerprint feels like it binds a license to a machine. It does not. It binds the license to a string the machine computed about itself — a hash of the machine GUID, the volume serial, the…

What is actually running in the background of your Mac?

Why I built Daemon Inspector, what the app found on my own Mac — and what the app sandbox taught me. What is actually running in the background of your Mac?

  • Your Mac runs dozens of background programs unseen in the Dock
  • Daemon Inspector reveals owners and origins of these background services
  • It provides safe commands to disable unknown or unwanted background services

More from Wednesday 25 November →