How do you save one or all the images from an array as .png files in a folder.
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Oliver Ferenczi
am 21 Apr. 2020
Bearbeitet: Devineni Aslesha
am 24 Apr. 2020
Hi, I have an array where there are 18 images stored making the array 18x4 double. I would like to be able to save these indivdual images in a folder. The number of images in the array will vary.
Is this possible? If so how can you do it?
Thank you
0 Kommentare
Akzeptierte Antwort
Devineni Aslesha
am 24 Apr. 2020
Bearbeitet: Devineni Aslesha
am 24 Apr. 2020
Hi
To save the images from an array as .png files in a folder, please see the below code.
a = [zeros(9,4); ones(9,4);];
numImages = size(a,1);
workingDir = 'C:\Desktop\Images';
mkdir(workingDir);
for i=1:numImages
baseFileName = sprintf('image%d.png',i);
fullFileName = fullfile(workingDir,'images',baseFileName);
imwrite(a(i,:),fullFileName);
end
Make sure to save this .m file in the workingDir and create the folder 'images' in the workingDir before running the .m file.
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Convert Image Type finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!