Save Kinect Depth Image in Matlab?

Using Kinect, I can get a depth image in which each pixel of the depth image stores the distance (in millimeter) between the camera and the object. Now I want to save them for later use. What is the recommendation?

I am going to save the depth image as an image (jpg / png, etc.). However, the value is usually between 50 and 10,000 mm, while a regular image element can store from 0 to 255. Then I will need to scale the data to a range of 0-255, and this may use the data in some way.

+6
source share
2 answers

You can use any format, for example tiff or png, which supports 16-bit grayscale images, since your data will correspond to 16-bit (2 ^ 16-1 = 65535).

The advantage of using these formats is, of course, that you can read them using another program. Most likely, you will not want to use the jpeg format due to compression artifacts.

Here is what the matlab documentation says about imwrite for png format:

By default, imwrite uses 8 bits per pixel if the image is double or uint8; 16 bits per pixel if the image is uint16; 1 bit per pixel if the image is logical.

So, you will be fine if your data is saved as uint16.

+8
source

You can save the matrix directly to disk using the save () and load () commands. But then only Matlab can read it. This is the best choice as you do not lose accuracy at all.

If you must scale the values ​​to 0..255, then do not scale it linearly. For a closer object, you need higher accuracy. So just apply the following function to the ln (DepthImage - 49) * 25 matrix to get about 0..255 values. Now save the image, and when you upload it, apply the inverse function. Thus (using the lan function) your accuracy will be less harmful

+2
source

Source: https://habr.com/ru/post/890352/


All Articles