필터 지우기
필터 지우기

Problems reading .RAW file

조회 수: 2 (최근 30일)
Xie Yiru
Xie Yiru 2019년 7월 8일
댓글: Walter Roberson 2019년 7월 9일
Hello
I have a strange problem when trying to read in a grayscale image of 12bit. there are always strange gray background when I am trying to load them in Matlab. I wish only black background and white cross.
q10.jpg
this is image with strange grey background
image.png
this is the image I wish
Do you know what may be the reason for such a problem ?
Thanks in advance
my code
fid=fopen('image.dat','rt');
q2=fread(fid,[3840 2160],'*ubit12');
q10=uint16(q2');
fclose(fid);
  댓글 수: 5
Xie Yiru
Xie Yiru 2019년 7월 9일
yes i have tried. But I still get the image like the first one with grey background. Can you maybe try one time and tell me the code. I have raw File linkes
Jan
Jan 2019년 7월 9일
@Xie Yiru: "which mode should I use to open the image file?" - See Guillaume's answer: Without the 't' in fopen.

댓글을 달려면 로그인하십시오.

답변 (1개)

Guillaume
Guillaume 2019년 7월 9일
편집: Jan 2019년 7월 9일
Your image is read incorrectly because you specified 't' in the fopen call. 't' means text mode and will replace some bytes sequences (specifically \r\n) by a different one (\r), which is certainly not what you want.
Without it, your image is read properly
fid = fopen('image.dat'); %you don't even need to specify 'r' since it's the default
q2 = fread(fid, [3840, 2160], '*ubit12');
fclose(fid);
imshow(q2, []);

카테고리

Help CenterFile Exchange에서 Audio and Video Data에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by