Items with no label
3335 Discussions

How can I get the 16 bit depth image from D435?

EAlta
Beginner
6,452 Views

Im adquiring data of a d435 depth camera from the realsense viewer, When I save the snapshot of the depth image, i get an 8 bit (1-256) grayscale image when in the specifications, is said that the camera gives a 16 bit depth image.

Do you know how can i get the 16 bit image?

0 Kudos
12 Replies
MartyG
Honored Contributor III
4,414 Views

I tried replicating your settings with my D415 but no matter what I did, the bit value of the Z16 PNG depth image snapshot was always 24 bit. I'm sorry that I couldn't recreate your problem.

0 Kudos
EAlta
Beginner
4,415 Views

Hi MartyG. You are right, the png is of 24 bits but it has 3 channels (RGB, which are matrices of 240 x424 ) each one of 8 bits (from 0 to 255 per chanel) and as it is a gray scale image R=G=B. so at the end you only have one chanel of 8 bits.

If it were a 16 bits image the range of values would be from 0 to 65535 (2^16).

The value of 240x424 depends on the resolution you specify on the realsense viewer (in my last image it was of 1280x720).

0 Kudos
MartyG
Honored Contributor III
4,415 Views

I did a lengthy further investigation of your issue but was unfortunately unable to develop a solution, so I will have to let someone else have a try at answering it. I do apologize. Good luck!

0 Kudos
EAlta
Beginner
4,415 Views

Thanks for your time MartyG.

jb455.

0 Kudos
gpapp1
Beginner
4,415 Views

Hi,

According to this https://github.com/IntelRealSense/librealsense/issues/815 Incorrect PNG file format for Viewer? · Issue # 815 · IntelRealSense/librealsense · GitHub, only 24-bit RGB PNG is supported now.

 

I think it saves the colorized depth image. You might be better off with the RAW.

-Gabor

0 Kudos
ROhle
Novice
4,415 Views

Depth.Raw is 16 bit grayscale. It can be imported by ImageJ (free/cross-platform from NIH) as 16-bit Signed, using little-endian byte order, with File->Import->Raw.

From there you can export it in whatever format you want.

0 Kudos
ASriv7
New Contributor I
4,415 Views

Is it unsigned or signed? Unsigned gives correct depth values for me.

0 Kudos
ROhle
Novice
4,415 Views

I have been using signed 16-bit in ImageJ. Tried un-signed today and it gives identical results. My stereo analysis gives 32-bit negative values along the z-axis (in the viewer perspective)... so I end up converting Depth.raw files to 32-bit anyway.

0 Kudos
EAlta
Beginner
4,414 Views

Hi @rjo__

I used imageJ to open the .raw file, as you suggested, obtaining the following result:

The obteined image, seems to be duplicated and is not 848x480 (It should be 848x480 because I specified it in the realsense viewer when I obtained the data).

Do you know how can I fix this problem?

0 Kudos
idata
Employee
4,414 Views

When you save snapshot of the depth image, you will get 3 files (*.png, *.raw, *.csv)

the png file is *not* the depth image!

The actual depth data you can find in the raw file.

you can load it to Matlab with the following script:

fid = fopen("FilesName.Raw");

Depth = fread(fid, [1280 720], '*uint16')';

fclose(fid);

EAlta
Beginner
4,414 Views

Thank you @RoobiDahan

I implemented the code you suggested on matlab:

I used [848 480] because I used this configuration on the realsense viewer when I obtained the data.

The result I get from the raw file is this:

The image is like "duplicated", and as you can see in the workspace from matlab, its size is 120x848, when it should be 480x848,

The image content seems to be ok, but it is not of the size it should be.

Do you know how can I fix this issue?

0 Kudos
idata
Employee
4,414 Views

No I didn't,

but try to use this code to create close image to the png image of the viewer, this way you could now what part of the file is missing or maybe the file is corrupt.

newDepthRaw = double(sort(DepthRaw(:)));

newDepthRaw(newDepthRaw == 0) = [];

newDepthRaw = newDepthRaw(1:round(length(newDepthRaw)*0.95));

Imin = min(newDepthRaw(:));

Imax = max(newDepthRaw(:));

newDepthRaw = (double(DepthRaw) - Imin)/(Imax - Imin);

newDepthRaw(newDepthRaw < 0) = 0;

newDepthRaw(newDepthRaw > 1) = 1;

A = jet; A(1,3) = 0;

figure; imagesc(newDepthRaw); colormap(A);

DepthRaw - is the depth file you load.

0 Kudos
Reply