Google's Pixel 2 and Pixel 2 XL flagship family boasts special camera software behind its single-lens rear camera setup which enables a bokeh-like feature called Portrait Mode, and Google has taken to its official blog to explain in detail how it all works. Using a set of special enhancements alongside the dual cameras, Portrait Mode not only brings subjects into sharp and detailed focus, but also touches up small things like lighting, color saturation, and detail to help the subject shine without erasing any of their special features like hard-earned wrinkles, distinctive moles, and unique facial quirks. The feature works on both human and non-human subjects, including inanimate objects. The goal, essentially, is to let the subject's natural beauty and visual nuances shine through in the best possible way while taking the focus off of their background.
The whole affair starts with a highly detailed, well-composed HDR+ photo. Rather than a second lens, the Pixel 2 and Pixel 2 XL have a special dual-pixel sensor on the side of the rear camera which can help create a depth map of any given scene. This allows the phone to emulate a real bokeh effect, blurring objects more as they grow further from the camera, while still drawing a distinct contrast between the sharpness of the subject and the blurry background. Front-facing selfies don't have the same sharp camera equipment and sensors to work with, so the Pixel 2 and Pixel 2 XL handle Portrait Mode on the front-facing camera by "simply" using machine learning to detect the subject of the photo, then apply a blurry mask over everything else.
Along with the explanation, Google posted some tips on how to get the most out of the new Portrait Mode feature. Users will want to space their subjects out so that their head and shoulders fill up the frame, ensuring that the subject is detected and gets the main focus. Ideally, you'll want subjects more than a few inches away from the camera, since it can't focus well on things that are too close like any other mobile setup, and a decent distance between your subject and background elements. For example, shooting a portrait against a brick wall a la Michael Jackson's Off The Wall album cover would be better with the subject a bit removed from the wall, rather than leaning against it. For group shots, it also helps to have subjects positioned at an equal distance from the camera; the depth sensors will pick up on the "layer" on which a central subject resides and search a bit harder for additional people or objects that could qualify as subjects. This will also help if you're taking a picture of a person holding an animal or an object and want to make sure both are in focus.