Artificial Intelligence 11 min read

Unlocking Realistic Bokeh: Depth‑Aware Algorithms Behind Holiday Video Effects

This article explains the optical principles of bokeh (scatter blur), describes a depth‑aware variable‑focus algorithm developed by Kuaishou’s audio‑video team, and details practical optimizations such as saliency detection, edge‑preserving weighting, and adaptive spot‑light effects that enable realistic, customizable holiday video filters.

Kuaishou Audio & Video Technology
Kuaishou Audio & Video Technology
Kuaishou Audio & Video Technology
Unlocking Realistic Bokeh: Depth‑Aware Algorithms Behind Holiday Video Effects

Bokeh Blur Principle

Common blur methods such as mean or Gaussian blur lack depth information and therefore cannot produce realistic bokeh. Bokeh blur, based on optical scatter blur principles, creates a depth‑of‑field effect that closely mimics professional camera equipment.

Optical Basis of Bokeh

Bokeh (also called out‑of‑focus rendering) is achieved by adjusting aperture and focal length so that regions outside the depth of field appear blurred, while the subject remains sharp. The size of the blur (circle of confusion) depends on aperture size, focal length, and subject distance.

The imaging formula of a lens relates object distance D , image distance V , and focal length F . When an object lies outside the focal plane, its light forms a blur circle rather than a point.

Depth Estimation and Saliency Detection

Since real‑world images lack explicit depth, the algorithm first estimates depth for each pixel and uses a lightweight saliency detection model to automatically locate the focus point. This provides a fast, accurate way to approximate object distance for subsequent blur calculations.

Depth‑Modulated Bokeh Algorithm

The blur weight for a pixel is computed from its depth relative to the focus depth, yielding a depth‑aware kernel. Unlike global Gaussian blur, this kernel varies with depth, producing realistic bokeh that respects the scene’s depth structure.

To avoid halo artifacts at edges, an edge‑preserving term reduces the weight of neighboring pixels whose depth differs significantly from the center pixel. An adaptive edge term further adjusts the weight based on the focus position (foreground vs. background).

Flexible Spot Effects

Spot effects are a special case of bokeh where additional weight terms are introduced:

Brightness weight: brighter pixels contribute more, shaping the spot.

Shape control weight: allows arbitrary spot shapes.

Breathing modulation: a sinusoidal function creates a pulsating light‑spot effect.

Real‑World Optimizations

Various practical enhancements improve visual quality:

Solid‑background detection adds seed spots to uniform backgrounds so that spot effects still appear.

Hollow‑spot overlap suppression uses non‑maximum suppression to reduce clutter from overlapping hollow spots.

Long‑strip spot suppression applies connected‑component analysis to prevent continuous spot streaks in bright linear regions.

Conclusion

The depth‑aware bokeh algorithm delivers realistic, variable‑focus blur with high export volume, making it suitable for holiday video templates and other creative video applications. Future work includes interactive refocusing and cinematic video effects.

References

Fernando, R. GPU Gems: Programming Techniques, Tips and Tricks for Real‑Time Graphics. Pearson Higher Education, 2004.

Haines, E., et al. Real‑Time Rendering, Fourth Edition, 2018.

computer visionimage processingDepth EstimationVideo EffectsBokeh
Kuaishou Audio & Video Technology
Written by

Kuaishou Audio & Video Technology

Explore the stories behind Kuaishou's audio and video technology.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.