【发布时间】:2017-03-31 05:24:00
【问题描述】:
我正在尝试正确转换 RAW 图像,以便我可以在 MATLAB 中查看它。图片可以下载here。我正在使用How can I read in a RAW image in MATLAB? 中提供的代码版本 但是,它对我来说不能正常工作。以下是我稍作修改的版本:
clear;
row=966; col=1296;
fin=fopen('C:\Users\user\Desktop\test2.raw','r');
I=fread(fin, col*row*3,'uint8=>uint8'); %// Read in as a single byte stream
I = reshape(I, [col row 3]); %// Reshape so that it's a 3D matrix - Note that this is column major
Ifinal = flipdim(imrotate(I, -90),2); % // The clever transpose
imshow(Ifinal);
fclose(fin); %// Close the file
我得到了什么:
我应该得到什么:
我不确定为什么它不适合我,但如果我使用成像程序 (ImageJ),如果我将图像类型选择为“24 位 BGR”,我可以正确转换 RAW 文件。图片的像素格式为 8 Bit BAYRG。
【问题讨论】:
-
我想指出。我遇到麻烦的主要原因是 MATLAB reshape 函数首先按列填充。因此需要转置。
标签: image matlab binaryfiles bgr file-import