Skip to content
tezvyn:
Menu

How does smartphone Portrait Mode produce bokeh?

Source: interviewMediumHow cards are made

Summary

depth estimation plus synthetic rendering.

Key points

estimate per-pixel depth via dual-pixel or stereo or learning, segment the subject, then apply depth-dependent blur.

What's really being asked

The interviewer checks whether you understand Portrait Mode as a combination of depth estimation, segmentation, and physically motivated rendering, and that the hard parts are at object boundaries.

The full answer

First you need a depth signal. Phones get it from dual-pixel sensors that yield tiny disparity between the left and right halves of each pixel, from a second rear camera giving stereo baseline, or from a learned monocular depth network when only one view exists. Second you need subject segmentation or matting, often a neural network that isolates the person, refined to capture fine boundaries like hair. Third you render the blur: rather than a flat Gaussian, you apply a spatially varying blur whose radius grows with depth behind the focal plane and synthesize disk-shaped bokeh from bright highlights, mimicking a real lens. The depth map and the segmentation mask are typically fused so the subject stays sharp while the background is progressively blurred.

The mistakes people make

Saying it is just a Gaussian blur of everything outside a mask, with no depth gradient. Ignoring depth estimation entirely. Forgetting the boundary and hair challenges that make matting hard.

What usually comes next

Why dual-pixel disparity is small and noisy, how learned depth is supervised, handling translucent or thin structures, and rendering convincing bokeh highlights rather than mush.

A concrete example

The Pixel approach combines a person-segmentation network with dual-pixel disparity to build a depth map, then renders a depth-dependent blur so a face stays crisp, the shoulders blur slightly, and the distant background blurs heavily with rounded highlight disks, approximating an optical large aperture.

Interview question

What is the main reason Portrait Mode needs a depth map rather than just a foreground mask?

  • a.To detect faces for autofocus
  • b.To apply blur that increases with distance for realistic bokehCorrect
  • c.To reduce sensor noise in low light
  • d.To correct white balance across the scene
Why?

A binary mask only separates subject from background; depth lets blur scale with distance so far objects blur more than near ones, mimicking a real lens. Face detection and white balance are separate concerns.

Just read this? Test yourself on what you have been reading.

Read the original → research.google

Put your scrolling time to good use

Learn one idea, try a quiz and save useful cards for revision. Tezvyn makes it easy to learn and stay current in your tech field, a few minutes at a time.

The iPhone app is on the way

We are building it. Until it lands, nothing here is held back from you: every interview card, your saved cards, streaks and the job board all work in Safari, plus hundreds of free practice quizzes of thirty questions each. Sign in and it all carries over to the app the day it arrives.

Want it as an icon? Tap Share at the bottom of Safari, then Add to Home Screen. It opens full screen and the cards you have read stay available offline.

Get it on Google PlayiPhone app coming soon

We are hiring for this. Every open role lists the topics its interview covers, so you can prepare for the real thing rather than guessing.

See open roles