我有一组.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
答案 0 :(得分:0)
图像元数据标头可能存在问题,例如“拍摄日期和时间”,“相机类型”。使用记事本++打开图像以检查“日期和时间”。如果您上传原始的原始图片,尝试起来会更容易。
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)