Saving muliple images in matlab
4 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
採用された回答
Image Analyst
2020 年 9 月 6 日
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 件のコメント
Image Analyst
2020 年 9 月 6 日
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.
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Convert Image Type についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!