Saving an array as a .raw image

18 ビュー (過去 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 Center および File ExchangeBiomedical Imaging についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by