need to create a loop to load images
3 views (last 30 days)
Show older comments
Vinay Anand
on 7 Sep 2019
Edited: KALYAN ACHARJYA
on 11 Sep 2019
Hi I tryed creating a loop to compare two images for the data to process the images and to save the output in a file, but the first image gets saved but the loop dosent work from the second image onwards, pls help
this is the error what i found
0 Comments
Accepted Answer
KALYAN ACHARJYA
on 7 Sep 2019
Assuming, you are trying to compare the images from same folder, suppose image1 and image2, image2 and image 3...so on..
%Save all images name in a sequence manner before doing the operation
% names for example im1,im2,im3..or 1,2,3...so on
%Save the folder of images in the current directory
path_directory='cov_test'; % 'Folder name' having images
original_files=dir([path_directory '/*.jpg']);
%........................................^^ Note on image format
for k=1:length(original_files)-1
filename1=[path_directory '/' original_files(k).name];
image1=imread(filename1);
filename2=[path_directory '/' original_files(k+1).name];
image2=imread(filename2);
%
% Now onwards compare image1 and image2
% Your compare code and result finding
% Save the results as per requirements
end
2 Comments
More Answers (1)
Walter Roberson
on 7 Sep 2019
string() class was introduced in R2016b. It took a few releases before all of the functions were converted to accept strings as well as character vectors. If you were using somewhere around R2017a or R2017b, you might need to char() the result of your string expression to pass it to imread()
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!