MATLAB Answers

Identify similarly named images from different folders

1 view (last 30 days)
Xen on 8 Feb 2015
Commented: Xen on 9 Feb 2015
Lets say I have folder A with five images (named: '5', '2', 'pic', '4', 'photo'), and another folder B with two images (named: '4', 'pic'), all of the same format and type. I want to make a for loop which identifies the similarly named images from each folder in order to perform some analysis on them, i.e. read image '4' from each folder and do the analysis, then image 'pic' from each folder and do the analysis (order does not matter).

Accepted Answer

per isakson
per isakson on 8 Feb 2015
Edited: per isakson on 9 Feb 2015
Try to make something out of this
s1 = dir( fullfile( folder_1, '*.png' );
s2 = dir( fullfile( folder_2, '*.png' );
% name_list = union( {}, {} );
name_list = intersect( {}, {} ); % thanks to @Image
for jj = 1 : length( name_list )
On Windows, upper and lower case might cause problems. ABC.png is the same name as abc.png. Replace
name_list = intersect( {}, {} );
name_list = intersect( lower({}), lower({}) );

More Answers (0)

Community Treasure Hunt

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

Start Hunting!

Translated by