Saving muliple images in matlab
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Mayur Deogade
am 6 Sep. 2020
Kommentiert: Mayur Deogade
am 8 Sep. 2020
How to save multiple images in matlab.
Input is taken as 1 image
then, this image is processed with different factors and then i need to save all the processed image and then need to call these images as required?
0 Kommentare
Akzeptierte Antwort
Image Analyst
am 6 Sep. 2020
To create a filename with factors embedded in it, use sprintf().
To write the image, use imwrite()
To recall the images, use imread() and imshow().
To do it multiple times, use a for loop.
3 Kommentare
Image Analyst
am 6 Sep. 2020
See the FAQ for how to use sprintf() The FAQ
Basically it's something like this:
baseFileName = sprintf('My Image Prefix %d_%.1f.png', intFactor1, dblFactor2);
fullFileName = fullfile(folder, baseFileName);
So you just use %d, %f, or %s depending on whether your factor is an integer, floating point number, or a string/character array, respectively. And you can have whatever prefix letters before those, and whatever file extension you want. For another example:
folder = 'D:\whatever\images'
numImages = 20;
intFactor1 = sort(randi(9000, 1, numImages));
dblFactor2 = rand(1, numImages);
for k = 1 : numImages
str = datestr(now); % Current date stamp
baseFileName = sprintf('Image_%4.4d_%4.4d_%.1f %s.png', k, intFactor1(k), dblFactor2(k), str(1:11));
fullFileName = fullfile(folder, baseFileName);
fprintf('Now writing %s to disk.\n', fullFileName);
% imwrite(yourImage, fullFileName);
end
You'll get
Now writing D:\whatever\images\Image_0001_0006_0.5 06-Sep-2020.png to disk.
Now writing D:\whatever\images\Image_0002_0079_0.8 06-Sep-2020.png to disk.
Now writing D:\whatever\images\Image_0003_0676_0.4 06-Sep-2020.png to disk.
Now writing D:\whatever\images\Image_0004_1527_0.3 06-Sep-2020.png to disk.
etc.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Convert Image Type finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!