IamAI blog

Depth of field segmentation

February 10, 2020

MODEL

Model

Encoder Takes an input image and generates a high-dimensional feature vector Decoder Takes a high-dimensional feature vector and generates a semantic segmentation mask There are 3 major building blocks: Convolution Down-Sampling Up-Sampling

The encoder in the network computes progressively higher-level abstract features as the receptive fields in the encoder increase with the depth of the encoder. The spatial resolution of the feature maps is reduced progressively via a down-sampling operation, whereas the decoder computes feature maps of progressively increasing resolution via un-pooling (Zeiler and Fergus, 2014) or up-sampling

EXAMPLES

In this example, we will show how can we blur part of the background and emphasize the foreground. Starting with the original image:

Input image

We are calculating depth map and converting it into grayscale:

Depth mask

Gray mask

Based on the given threshold we extract the foreground and inverted mask

Inverted mask

Black and white mask

This helps us to make foreground image with transparent background: 

Transparent background mask

When we concatenate this image with blured version of original image:

Blured

We get the end result:

Result

Original


Written by Vladimir Obradović who lives and works in The Hague, The Netherlands. Tech Coach, Startup Co-founder, Innovator and Disruptor You should follow him on Twitter