matlab深度图显示
时间: 2023-11-06 20:07:53 浏览: 64
Matlab中可以使用imshow函数来显示深度图像。深度图像需要被转换成uint16类型的矩阵后才能被正确显示。具体的代码如下所示:
```
filepath = 'E:\Downloads\datasets\BIWI\kinect_head_pose_db\hpdb\01\frame_00003_depth.bin';
f = fopen(filepath, 'r');
width = typecast(uint8(fliplr(fread(f,4))), 'uint32');
height = typecast(uint8(fliplr(fread(f,4))), 'uint32');
depth = uint16(zeros(width*height,1));
i = 0;
while i < width * height
skip = bin2dec((vec2mat(dec2bin(fliplr(fread(f,4)'),8),1)'));
read = bin2dec((vec2mat(dec2bin(fliplr(fread(f,4)'),8),1)'));
for j=0:read-1
depth(i+skip+j) = bin2dec((vec2mat(dec2bin(fliplr(fread(f,2)'),8),1)'));
end
i = i + skip + read;
end
fclose(f);
depth = reshape(depth ,[width ,height])';
imshow(depth*16);
```