How does selfie segmentation work?

Selfie segmentation is based on trained neural networks. By studying the datasets of people's heads and shoulders they are able to learn how to distinguish between humans and environment.

More information about topic 

Face segmentation