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?
-
1\$\begingroup\$ Could you provide a source for the claim that this information is stored in the JPEG? \$\endgroup\$– Philip Kendall ♦Commented Jan 15, 2017 at 7:18
-
\$\begingroup\$ 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. \$\endgroup\$– MikeDCommented Jan 15, 2017 at 9:16
-
\$\begingroup\$ @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. \$\endgroup\$– Jogging SongCommented Jan 15, 2017 at 13:24
-
\$\begingroup\$ @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. \$\endgroup\$– Jogging SongCommented Jan 15, 2017 at 13:29
-
1\$\begingroup\$ I'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? github.com/drewnoakes/metadata-extractor \$\endgroup\$– Drew NoakesCommented Jan 15, 2017 at 23:37
3 Answers
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.
-
\$\begingroup\$ Does your software also automatically use the depth map to simulate bokeh? \$\endgroup\$– xiotaCommented Aug 2, 2019 at 8:42
-
\$\begingroup\$ 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. \$\endgroup\$ Commented Aug 2, 2019 at 8:54
-
\$\begingroup\$ 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. \$\endgroup\$– xiotaCommented Aug 2, 2019 at 9:10
-
1\$\begingroup\$ It 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). \$\endgroup\$ Commented Aug 2, 2019 at 9:24
-
\$\begingroup\$ @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 facebook.com/help/1703757313215897/?helpref=hc_fnav \$\endgroup\$– cmaranguCommented Mar 24, 2020 at 17:36
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
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:
-
\$\begingroup\$ Are you associated with the Android program you are linking to? \$\endgroup\$– scottbb ♦Commented Mar 11, 2020 at 5:53
-
1\$\begingroup\$ And 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! \$\endgroup\$ Commented Mar 11, 2020 at 19:26
-
\$\begingroup\$ Yes, I can, updated comment. \$\endgroup\$ Commented Mar 12, 2020 at 10:36
-
\$\begingroup\$ 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. \$\endgroup\$– FreeManCommented Mar 12, 2020 at 14:09
-
\$\begingroup\$ 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. \$\endgroup\$ Commented Mar 12, 2020 at 18:19