Search code examples
matlabautosave

MATLAB how can I save an image?


I tried the commands:

 imshow(originalImage);
 imsave;

it works, but I want the matlab to automatically save the image in bmp format (in the current folder). I tried to use:

 save('myimage.bmp','originalImage');

the picture was saved, but on the image itself, instead of the picture, I saw this message: "windows photo viewer can't open this picture because the file apears to be damaged, corrupted, or is too large". (the size of the picture is 5kb).

Thanks!


Solution

  • Use the function imwrite to do that:

    imwrite(image_matrix, 'myimage.bmp', 'bmp')
    

    imwrite documentation on mathworks