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).
According to this 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.
1 of 1 people found this helpful
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')';
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.