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?

 채택된 답변

Image Analyst
Image Analyst 2020년 9월 6일

0 개 추천

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

Mayur Deogade
Mayur Deogade 2020년 9월 6일
How to use the sprintf() for storing different images
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 2020년 9월 8일
Thanks for your help

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Image Processing Toolbox에 대해 자세히 알아보기

질문:

2020년 9월 6일

댓글:

2020년 9월 8일

Community Treasure Hunt

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

Start Hunting!

Translated by