need to create a loop to load images

3 ビュー (過去 30 日間)
Vinay Anand
Vinay Anand 2019 年 9 月 7 日
編集済み: KALYAN ACHARJYA 2019 年 9 月 11 日
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

採用された回答

KALYAN ACHARJYA
KALYAN ACHARJYA 2019 年 9 月 7 日
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 件のコメント
Vinay Anand
Vinay Anand 2019 年 9 月 10 日
thank you it works
KALYAN ACHARJYA
KALYAN ACHARJYA 2019 年 9 月 10 日
編集済み: KALYAN ACHARJYA 2019 年 9 月 11 日
My pleasure Vinay

サインインしてコメントする。

その他の回答 (1 件)

Walter Roberson
Walter Roberson 2019 年 9 月 7 日
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()

Community Treasure Hunt

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

Start Hunting!

Translated by