【问题标题】:read and show raw depth image in matlab在 matlab 中读取并显示原始深度图像
【发布时间】:2018-12-26 21:18:22
【问题描述】:

我有一组 .raw 深度图像。图像格式为 500X290,每像素 32 字节。当我使用 IrfanView 图像查看器打开它们时,我正确地看到了深度图像,如下所示: displayed image in IrfanView

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

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

DepthImage 是一个 290X500 类型的双精度矩阵。 我从这段代码中得到的是这张图片: displayed image in Matlab viewer

当我将 fread 参数从“bit32”更改为“bit24”时,我得到了这个: displayed image in Matlab with bit24

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

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

【问题讨论】:

    标签: matlab color-depth


    【解决方案1】:

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

    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)
    

    【讨论】:

    • 在 IrfanView 中,我打开它时标头大小等于 0 字节,这意味着没有标头。 .raw 文件像 .bin 文件一样加载,使用 notepad++ 打开时没有什么是可以理解的。我上传了原图。
    • 您现在在帖子下找到了文件。
    • 感谢它对我有用。我不知道如何将 R、G、B 彼此分开。你做的方式很棒。
    • 你知道为什么 R 和 G 通道只是噪音吗?
    • 可能是相机参数需要调整?我有使用 Basler 机器视觉相机的经验。他们的软件中有很多调整的可能性。你用什么相机?另一个想法是图像可能是用蓝色滤镜制作的。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2010-11-28
    • 2013-02-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-04-13
    相关资源
    最近更新 更多