how to use imwrite in matlab?

288 views (last 30 days)
Anushka
Anushka on 17 Jun 2015
Answered: kass on 29 Jan 2020
how to use imwrite in matlab?The file which that we are specifying to write,should it be already be created in the folder?

Answers (4)

B.k Sumedha
B.k Sumedha on 17 Jun 2015
Edited: B.k Sumedha on 17 Jun 2015
imwrite(A,filename,fmt);
This is the general format of imwrite. Its not necessary that image needs to be present in ur folder. Where A is ur image which u want to save,specify the file name and its format. For ex:
imwrite(im_DIF,'Image difference.bmp','bmp');
  4 Comments
Walter Roberson
Walter Roberson on 18 Apr 2016
You cannot use imwrite() to write dicom images. You need dicomwrite()

Sign in to comment.


Walter Roberson
Walter Roberson on 17 Jun 2015
No. If the file does not already exist then it will be created. If the file does already exist then it will be overwritten.
  4 Comments
Guillaume
Guillaume on 18 Jun 2015
Note: to close all open file handles:
fclose all

Sign in to comment.


Alejandro Cruz Rubio
Alejandro Cruz Rubio on 1 Jun 2019
Anyone Know how to save a block of images with imwrite?
  8 Comments
Rik
Rik on 3 Jun 2019
With the code you show you actually haven't fixed the code yet. The code below should work a lot better.
for k=1:numel(arrayCells)
filename = sprintf('Output_block_%d.png', k);%<--- lower case k, instead of upper case K
imwrite(arrayCells{k}, filename);
end

Sign in to comment.


kass
kass on 29 Jan 2020
for k=1:numel(I)
imwrite(I{k}, ['filename' num2str(k) '.pgm']);
end
%I is arraycells

Community Treasure Hunt

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

Start Hunting!