Some mobile phones support changing the depth of field using depth information calculated from dual cameras. If the depth information is stored in the jpg file, how can it be extracted?
-
1Could you provide a source for the claim that this information is stored in the JPEG? – Philip Kendall Jan 15 '17 at 07:18
-
If you can tell me what the EXIF information is for that, I can probably make the software if it can't be done with EXIFTOOL. – MikeD Jan 15 '17 at 09:16
-
@PhilipKendall If I take a picture without using dual cameras, the size of the jpg file may be about 2Mbytes. If I use the dual cameras function to take the same scene, additional 2Mbytes is needed for the jpg file. I guess that depth information is saved in the jpg file. After you have taken the image, you can reload the jpg file and modify DOF in camera app on an Android phone. – Jogging Song Jan 15 '17 at 13:24
-
@MikeD I don't know which filed is used for depth information. JPEG file standard allows users to add private data. I try JPEGsnoop and not succeed. – Jogging Song Jan 15 '17 at 13:29
-
1I've seen some Google phones that store depth information as Base 64 encoded data in XMP segments. Seems like a weird way to store it, but I'm sure they have a reason. Do you have a sample image? Could you open an issue on my project's issue tracker and attach it? https://github.com/drewnoakes/metadata-extractor – Drew Noakes Jan 15 '17 at 23:37
-
@DrewNoakes If I can capture such jpg image, I will share it with you. Currently I don't have such image. Do you have sample jpg file from google phones with depth information? – Jogging Song Jan 19 '17 at 08:52
-
Yes, you can find them in a related repo of that project. Check the wiki. – Drew Noakes Jan 19 '17 at 09:14
-
I'm voting to close this question as off-topic because it is about image analysis, not photography. – Olivier Jul 02 '18 at 19:29
3 Answers
Portrait Mode images saved by Google Camera contain the original image and depth map in the metadata. They can be extracted with exiftool:
exiftool -b -ImageData image.jpg > image.gimage.jpg
exiftool -b -Data image.jpg > image.gdepth.jpg
Google Cardboard panoramas contain audio and 3d image data.
exiftool -trailer:all= image.jpg -o image.1.jpg
exiftool -b -ImageData image.jpg > image.2.jpg
exiftool -b -AudioData image.jpg > image.audio.mp4
For dual camera Android phones, the exact command required depends on which tags a specific phone or app uses to store extra images. To find the name of the tags, use:
exiftool image.jpg | grep -i binary
For example, the original images stored by the Samsung S9+ can be extracted with the following commands:
exiftool -trailer:all= image.jpg -o image.1.jpg
exiftool -b -EmbeddedImage image.jpg > image.2.jpg
- 26,951
- 4
- 39
- 126
I am the author of Photopea.com - in-browser photo editor.
Photopea supports depth-maps. Open your JPG in Photopea. A depth-map (and the original sharp image) will be added as two extra layers. You can save them separately as JPG, PNG, etc.
Just wanted to let you know, that you can do it without downloading or installing anything, or using a command line :)
UPDATE: There is a lens blur filter (Filter - Blur - Lens Blur), where you can produce a bokeh effect based on a depth map.
- 186
- 2
-
Does your software also automatically use the depth map to simulate bokeh? – xiota Aug 02 '19 at 08:42
-
Do you mean keeping one object sharp, and blurring everything what is closer or further than that object? There is no such feature, but I can implement it. But usually, cameras produce such image themselves. – Ivan Kuckir Aug 02 '19 at 08:54
-
What do you believe to be the purpose of the depth map? I don't use your software, so it doesn't matter to me what you decide to implement. Just wondered whether your software is capable of doing anything useful with the depth map. – xiota Aug 02 '19 at 09:10
-
1It can only "extract" it at the moment (as a layer of pixels). You can save the depth map as PNG to be used in other software (what the person above asked for). – Ivan Kuckir Aug 02 '19 at 09:24
-
@xiota depth map can be serve a variety of purposes outside of the software us'ed to extrackt them. U can use depth map to impress all your friends on facebook with 2.5D photos https://www.facebook.com/help/1703757313215897/?helpref=hc_fnav – cmarangu Mar 24 '20 at 17:36
-
I have to make a ported application called ExifTool on Android. You can easily download it and try to extract the depth information or export the binary file from a photo.
Link download: Exif Tool on Android
How to use:
- 111
- 2
-
-
1And if you are associated that's fine, but please mention it in the answer. Also, the answer at the moment doesn't describe how one would use exiftool on android to extract the depth map. Could you please add that as well? Thanks! – Saaru Lindestøkke Mar 11 '20 at 19:26
-
-
Thanks for the update with instructions, but you still haven't disclosed whether you're associated with the product or not. Promoting a product you're associated with is quite OK, but acknowledgement of that is expected. If you're not associated, you can just include some text like "I'm a happy user of ..." to indicate that. – FreeMan Mar 12 '20 at 14:09
-
I don't think this is needed on this post. But, It's OK to say that is my product, I have to update my comment in this post. Thank you for pointing me. – Võ Anh Kiệt Mar 12 '20 at 18:19
-
There is no depth map in Xiaomi Redmi 8 photoes. How can I capture images with the depth map? – user2085899 Mar 15 '20 at 22:00
-
@rostamiani : the depth map of photo on Xiaomi is storing with different way compare with Google Camera. Some phone is have different struct, that can cause this data is not available. – Võ Anh Kiệt Mar 16 '20 at 04:40
-
@VõAnhKiệt Thanks. Ten how can I access depth image? Im really interesting to have it. I installed Google Camera and it works but there is no depth image in the portrait photos. Maybe GCam cannot access the Depth Cam. Do you know another way to access depth? using Android Camera or GCam? Thanks – user2085899 Mar 16 '20 at 05:03
-
According to this, I just only test on the photo taken by Google Pixel, this photo is show above. The exiftool is created by Phil Harvey, seem like this is support depth map of photo taken by google pixel and samsung device only. – Võ Anh Kiệt Mar 16 '20 at 08:12
