I want to open and read a .raw
image in MATLAB. My file can be downloaded here. I have tried the following three code snippets, but neither gives the expected results.
Code Snippet #1
row=576; col=768;
fin=fopen('m-001-1.raw','r');
I=fread(fin,row*col,'uint8=>uint8');
Z=reshape(I,row,col);
Z=Z';
k=imshow(Z);
It shows this picture:
Code Snippet #2
f=fopen('m-001-1.raw');
a=fread(f);
input_img = reshape(a,768, 576, 3);
input_img = imrotate(input_img, -90);
imwrite(input_img, 'm-001-1.jpg');
This saves a blank (just white) image in .jpg
format.
Code Snippet #3
id = fopen('m-001-1.raw', 'r');
x = fread(id, [576,768], 'short');
When I use imshow(x)
, this picture shows:
How do I read this picture correctly?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…