Read nth image from a folder and compare it with nth image from different folders and store the result

3 views (last 30 days)
So i have 3 folders say F1,F2,F3. Each folder contains images. i.e F1 conatins a1, a2,...; F2= b1,b2,....; F3=c1,c2,....; I want to read image (a1,b1) ,do some operation and store the value in a text file or a m x n table preferably. Similarly i want to read (a2,b2) , (a3, b3) and so on and do the same operation and update the text file. I want to repeat the same thing for (a1, c1), (a2, c2),etc and store it in another file/table. How do i do that?
The names of the files are not simply a1, b1, etc they are very randomly named so the program should read the nth file from F1,nth file from F2 and nth file from F3.
  1 Comment
Image Analyst
Image Analyst on 28 Nov 2022
If they are randomly names how do you know if "fkjsalf.png" from F1 matches up with "eiruwoeiru.PNG" from F2 or 'xcvnxc.PNG" from F2? How do you plan on associating a given file from F1 with the right corresponding file from F2, F3, etc.if their names are all different????
Also even if the names are the same in two folders, it's not guaranteed that the operating system will say the 3rd file from each folder has the same names. The orders may be different even if all the names are the same.

Sign in to comment.

Answers (1)

David Hill
David Hill on 28 Nov 2022
a=dir('F1/');b=dir('F2/');c=dir('F3/');
for k=1:length(a.name)
i1=imread([a(k).folder,'/',a(k).name]);
i2=imread([b(k).folder,'/',b(k).name]);
%do some stuff
end

Products


Release

R2016a

Community Treasure Hunt

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

Start Hunting!