Saving muliple images in matlab

5 visualizaciones (últimos 30 días)
Mayur Deogade
Mayur Deogade el 6 de Sept. de 2020
Comentada: Mayur Deogade el 8 de Sept. de 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?

Respuesta aceptada

Image Analyst
Image Analyst el 6 de Sept. de 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 comentarios
Image Analyst
Image Analyst el 6 de Sept. de 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.
Mayur Deogade
Mayur Deogade el 8 de Sept. de 2020
Thanks for your help

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Convert Image Type en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by