Saving an array as a .raw image

33 vues (au cours des 30 derniers jours)
JoaquinB le 20 Mar 2020
Commenté : JoaquinB le 23 Mar 2020
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');
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

Réponse acceptée

Ganesh Regoti
Ganesh Regoti le 23 Mar 2020
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 commentaire
JoaquinB le 23 Mar 2020
It helped, appreciated Ganesh!

Connectez-vous pour commenter.

Plus de réponses (0)


En savoir plus sur Import, Export, and Conversion dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by