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?
連結已複製
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).
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
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.
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?
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);
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?
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.
