Skip to content

data missing from16 bit png depth map #2

@AugmentedRealityCat

Description

@AugmentedRealityCat

There seems to be a problem with the 16 bit PNG depth map you can download from the first tab, and even the preview seems to have similar problems.

Here is a picture used to create a depthmap

00027

And here is the preview we get of the resulting depth map. You can clearly see that some parts are completely black - like if they were missing, or clipped out from the range covered by the depth data.
preview_8bpc

As for the actual 16 bit PNG it's almost completely black - on the curves histogram you can see all the data is squeezed to the left.
a

I have the impression the raw data coming from the depth analysis is good (at first glance it seems to be interpreted correctly by both the 3d model and the 3d panorama mesh extraction process) but that it needs to be interpreted differently to create useful PNGs and provide the user with a representative preview of the complete data.

If you try to interpret the 16 bit PNG to rescale the depth data using a wider color range it will not work as there is a bit of data there, but only just a couple of bits ! If you map them using brightness curve adjustments in photoshop you get this.

b

As you can see, there is huge color banding as there is not enough data in the image to provide a subtler gradient.

I can provide examples and tests to illustrate the problem, but I'm guessing that it's probably just a simply math mistake in converting the raw depth values to 16 bit.

I would check the following line:

raw_depth = Image.fromarray((depth*256).astype('uint16'))

I have changed it myself to 8192 (65 536 / 8) and it almost seems to work ! But the values, instead of going from 0 to 255 (if we were to interpret the image in 8 bits) they go from 50 to 155 approximately. So there seems to be both an offset to compensate for, and the need for a larger multiplier than 8192.

That gives you something like this - it's a very decent depthmap and it might be a properly scaled one as well.
d

And if you adjust the brightness curve to pseudo-normalize it (extend it manually to cover the full range from black to full white) you get a nice depthmap in appearance, without any banding or clipping.

e

If I change the multiplier to 16384, then I can see there is an overflow, and the furthest distances are indicated with a gradient that restarts from black up to a dark grey.

c

Again, I interpret this as an offset that we have to compensate for somehow, which I tried to do manually using curves in photoshop. It's a dirty solution, but it shows that there is indeed an offset that we can compensate for.

f

We should also consider the colorspace used to encode the file itself, and check if that colorspace and associated gamma are indicated as such by the PNG in its metadata. This could lead to some problems as well - I had to put a counter-gamma of 0.4545 to interpret that depthmap in 3d in a way that made sense.

And, finally, there is also the fact that Photoshop and many libraries and the software that use them are not correctly saving 16 bit PNG files - they only use 15 bits for some reason. This is probably not related to what I have documented here, but we should keep this possibility in mind if nothing else works.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions