在 MATLAB 中读取并显示原始深度图像



我有一组.raw深度图像。图像格式为 500X290,每像素 32 字节。当我使用 IrfanView 图像查看器打开它们时,我正确地看到深度图像,如下所示:在伊尔凡视图中显示的图像

现在我想在 Matlab 中读取和显示相同的深度图像。我喜欢这个:

 FID=fopen('depthImage.raw','r');
 DepthImage = fread(FID,[290,500],'bit32');
 fclose(FID);
 colormap winter;
 imshow(DepthImage);

深度图像是一个290X500类型的双矩阵。我从这段代码中得到的是这张图片:在 Matlab 查看器中显示的图像

当我将 fread 参数从"bit32"更改为"bit24"时,我得到这个:在 Matlab 中使用 bit24 显示图像

我猜 DepthImage 中的每个元素都包含 32 位,其中每 8 位对应于 R、G、B 和 D 值。 但是我怎样才能正确读取图像并像 IrfanView 中的图像一样显示它?

原始文件:https://drive.google.com/file/d/1aHcRmMKvi5gtodahR5l_Dx8SbK_920c5/view?usp=sharing

图像元数据标头可能存在问题,例如"拍摄日期和时间"、"相机类型"。使用记事本++打开图像以检查"日期和时间"。如果您上传原始原始图像,尝试事情会更容易。

Upd:好的,这是个东西。检查是否有帮助

 FID=fopen('camera00000000000014167000.raw','r');
 DepthImage = fread(FID,290*500*4,'int8');
 DepthImageR = DepthImage(1:4:end);
 DepthImageG = DepthImage(2:4:end);
 DepthImageB = DepthImage(3:4:end);
 DepthImageD = DepthImage(4:4:end);
 dataR = reshape(DepthImageR, 500,290);
 dataG = reshape(DepthImageG, 500,290);
 dataB = reshape(DepthImageB, 500,290);
 dataD = reshape(DepthImageD, 500,290); % all equal to 64 - useless
 figure()
 subplot(2,2,1)
 image(dataR)
 subplot(2,2,2)
 image(dataG)
 subplot(2,2,3)
 image(dataB)
 subplot(2,2,4)
 data = zeros(500,290,3);
 data(:,:,1) = dataR;
 data(:,:,2) = dataG;
 data(:,:,3) = dataB;
 image(data)

最新更新