Saving an array as a .raw image

32 次查看(过去 30 天)
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!

更多回答(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