Saving an array as a .raw image

조회 수: 36 (최근 30일)
JoaquinB
JoaquinB 2020년 3월 20일
댓글: JoaquinB 2020년 3월 23일
Hello, i am working with image processing using Matlab.
My inputs are some 3D .raw tomography images, which i process with matlab. After the operations i would like to save my image with the original format (which is .raw) so I don't lose any information ( I know I could use other images formats but I want the original format).
B is a 280x3072x4000 logical array, which contains my image and its the array I want to save as .raw.
I tried the following code:
fid = fopen('17_M91_40J_POLAR_DMG_INF_1_8b_3072x280x4000.raw','r','b');
fwrite(fid,B,'uint8');
fclose(fid);
I generated the '17_M91_40J_POLAR_DMG_INF_1_8b_3072x280x4000.raw' just copying the original image with Windows and changing the name manually since I dont know how to generate a 'blank' raw file. The code seems to work but when I open the file it's the same as the original, it seems like fwrite don't do anything.
I attach screenshots of the original .raw image and the B array (image processed) which I would like to save
Any ideas? Thanks

채택된 답변

Ganesh Regoti
Ganesh Regoti 2020년 3월 23일
Hi,
As per my understanding, you are reading data from a .raw file, processing the data and trying to store the processed data in the same file. But as per your code, you have given only read access to the file, as per the code
fid = fopen('17_M91_40J_POLAR_DMG_INF_1_8b_3072x280x4000.raw','r','b'); %r->read access. Change it to r+ or a+
I assume that might be the issue for the data not being updated in the file. You can try changing the file access types. 'r+' and 'a+' might fit for your case. Refer the following link
Hope this helps!
  댓글 수: 1
JoaquinB
JoaquinB 2020년 3월 23일
It helped, appreciated Ganesh!

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Import, Export, and Conversion에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by