How to extract depth images from Pixel 4 / google camera Android phone Portrait images

I have a Pixel 4 android phone which can take “Portrait” images that use a depth map to “blur” the background, focusing on the foreground.

I also have a Looking Glass Factory Portrait holographic display which can display holographic images.

Currently, the HoloPlayStudio software (version 0.3.5 beta) that comes with it only natively supports iPhone portrait photos, but will import RGB+D photos, so I need to extract the depth image (and the original image without the blurred background)

I want to extract a depth map from my android photos so that I can (manually) create RGB+D photos (which have a regular jpeg image next to the corresponding depth map).

This website makes it easy to see/download the different layers embedded in the Pixel 4A “Portrait” mode jpeg image: https://www.photopea.com/

Download the original image and the depth map, glue them together with the depth map on the right and you have an RGB-D image suitable for HoloPlayStudio.

You can also extract the original and Depth Map images using the exiftool.

The command that I found worked was suggested by Phil here:
https://exiftool.org/forum/index.php?topic=11701.0

It extracts the 2nd trailer image, which is the depth image:

exiftool input.jpg -trailer -b | exiftool - -trailer -b > dept.jpg

Incidentally, the FIRST trailer image is the non-blurred original image…

exiftool input.jpg -trailer -b > original_image.jpg

So if you extract the trailer from the original image, it will be the depth map, and you won’t have to chain exiftool together on the command line as above…

exiftool original_image.jpg -trailer -b > depth.jpg

Completely unrelated to extracting depth images, but possibly needed to create holograms from a linear slide movie is the following ffmpeg command that will extract 3 seconds of a video starting at the 2 second mark into PNG image frames:

ffmpeg -ss 00:02 -i <input> -t 00:03 filename%05d.png

Leave a Reply

Your email address will not be published.