FORUMS
Remove All Ads from XDA

Extracting Both Images from P9 Dual Camera

3 posts
Thanks Meter: 0
 
By jbudman, Junior Member on 21st September 2016, 08:08 AM
Post Reply Email Thread
27th September 2016, 12:46 PM |#11  
PerpulaX's Avatar
Member
Flag Berlin
Thanks Meter: 9
 
More
I did some poking around on my lunch break. I threw a wide-aperture image into JPEGsnoop and it came up with two images in the file (four if you count the thumbnails, as well), the first one being the processed, "bokeh" image, while the second is the original color image without any processing. I assume that this is the image that is used to re-process the wide-aperture image when editing the focus point or aperture through the gallery app.

JPEGsnoop also told me that there's more data after the image segments. Since it couldn't work out what that data is for (this is past the end of the actual JFIF file), I checked it out using a hex editor. I found a marker "edof" (extended depth-of-field?) followed by what looks like some header data, followed lots of repeating bytes. This block is about 1/16 the size of the image in pixels (so 1 byte for each 4x4 pixel block). I'm not sure whether that's a small greyscale version of the image itself or a depth map, but I suspect it's the latter.

So, I'm afraid that it will be impossible to extract the monochrome image sensor data from a wide-aperture image, as it's not there anymore.
The Following User Says Thank You to PerpulaX For This Useful Post: [ View ] Gift PerpulaX Ad-Free
 
 
27th September 2016, 12:49 PM |#12  
Junior Member
Thanks Meter: 14
 
More
Quote:
Originally Posted by PerpulaX

I've read somewhere that the resulting image is a normal JPG file that is way too large, so it seems that there is additional data after the end of the actual JPG image. This would also explain why the capability to adjust depth of field is lost once the file is opened and saved by any application. I'll have a look at such a file when I have some spare time; maybe I'll find out more.

I confirm that: I did few shots on a single subject (always using tripod);
- the pictures in normal mode and with wide aperture with the BW camera covered results in 2.5 MB weight (max resolution; the photo's Title/Subject/Description is marked as "edh"
- the same subject in wide aperture mode (with the BW camera fully working) results in 5.5 MB weight (more than double); the photo's Title/Subject/Description is marked as "edf"; if this photo is opened with some image editing software, no alpha layers or other visual information appears anywhere; if the photo is saved back, the size will became comparable to the same photo without wide aperture effect

As depth information are not appearing in any editing software, I suppose they are hidden inside the jpeg file with some kind of steganography technique. I tried to examine the file with some ready-to-use tool (like stegdetect, that should be capable to detect if a jpeg file is standard or has something hidden) but I get only some mismatching header error, nothing that can let me understand where and how the depth information are stored and, primarily, if the black and white picture is also stored inside.
27th September 2016, 02:03 PM |#13  
dragon-tmd's Avatar
Senior Member
Flag BRD
Thanks Meter: 63
 
Donate to Me
More
The cam seems to be making two Images for every shot. You can for - instance - make a picture and then edit it with the onboard effects. If i make the picture e.g. partially B&W, I can see, that it does use an original B&W picture taken with the original shot. This is not an artificial B&W.

The question is, where it is stored or are the necessary informations only "combined"?
9th December 2016, 10:28 PM |#14  
Junior Member
Thanks Meter: 0
 
More
PerpulaX, ScareIT you guys are right,
- the 992x744 depth map is coded on 8 bits at the end of the file, use HxD editor to extract the image (check the tags in ascii code "edof" & "DepthEn" ).
- displayed jpg is the saved one after blur processing on your sd card
- hidden jpeg in exif is the original image shot , without blur processing.
So it explains why you can re-edit your picture anytime on your P9 even after renaming... or simply have fun with the depth map for detouring in photoshop for instance
2nd May 2017, 12:56 AM |#15  
Junior Member
Thanks Meter: 3
 
More
Made a python script to automate the EDOF and image extraction. It's simple but it works.

https://github.com/jpbarraca/dual-camera-edof
3rd May 2017, 11:10 AM |#16  
Senior Member
Flag Rome
Thanks Meter: 93
 
Donate to Me
More
Quote:
Originally Posted by zoubla88

PerpulaX, ScareIT you guys are right,
- the 992x744 depth map is coded on 8 bits at the end of the file, use HxD editor to extract the image (check the tags in ascii code "edof" & "DepthEn" ).
- displayed jpg is the saved one after blur processing on your sd card
- hidden jpeg in exif is the original image shot , without blur processing.
So it explains why you can re-edit your picture anytime on your P9 even after renaming... or simply have fun with the depth map for detouring in photoshop for instance

Can you explain what is possible to do in post-process? What can I do with the photo?
3rd May 2017, 12:40 PM |#17  
Junior Member
Thanks Meter: 3
 
More
You can do exactly the same thing as the Huawei gallery app (at least).
For Photoshop there are plenty of tutorials using Depth Maps with the Lens Blur plugin
8th May 2017, 10:21 AM |#18  
Senior Member
Flag GHAZIABAD
Thanks Meter: 36
 
More
Thumbs up
Quote:
Originally Posted by ScareIT

Yes, I did.
I'm thinking about making a full post about photo comparation. Let's see

Waiting for more details and experience sharing from you
9th May 2017, 12:43 PM |#19  
Member
Thanks Meter: 10
 
More
Quote:
Originally Posted by Tijauna

Yes unfortunately I think this is simply a feature that huawei lied about. The phone doesn't actually use both lenses at the same time to produce better quality normal photos; the monochrome lens is only used for bw mode or to obtain depth information for the wife aperture mode. The two lenses are not used in conjunction to provide better low light performance. You can try it yourself as stated earlier in the thread, cover the bw lens with your finger and compare the photos with normal ones: they'll look the same...

Hy!
I think, that P9 does take two pictures and combines them in low light conditions. Here is two example, when something went wrong with the combination of images, and the two images becomes visible: https://goo.gl/photos/cK5q2TEisEU7rmpz9


What do you think?

Abel
2nd July 2017, 02:27 PM |#20  
Junior Member
Thanks Meter: 5
 
More
So the file size is increased when B&W is uncovered but gives no actual benefit to the picture? Damn it, as useless as Interpolation!
10th October 2017, 10:08 AM |#21  
Junior Member
Thanks Meter: 0
 
More
Hey I tried using that script on a P10 photo, but I guess I'm not enough programmer to get this to work.
I think I didn't even install the programs right. Is there an easier way to extract the depth map?
Or can anybody give a step-by-step description of how and what to install?
Post Reply Subscribe to Thread

Guest Quick Reply (no urls or BBcode)
Message:
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes