need to create a loop to load images

조회 수: 2 (최근 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