Identify similarly named images from different folders

조회 수: 1 (최근 30일)
Xen
Xen 2015년 2월 8일
댓글: Xen 2015년 2월 9일
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).
Thanks!

채택된 답변

per isakson
per isakson 2015년 2월 8일
편집: per isakson 2015년 2월 9일
Try to make something out of this
s1 = dir( fullfile( folder_1, '*.png' );
s2 = dir( fullfile( folder_2, '*.png' );
% name_list = union( {s1.name}, {s2.name} );
name_list = intersect( {s1.name}, {s2.name} ); % thanks to @Image
for jj = 1 : length( name_list )
name_list{jj}
end
&nbsp
Addendum
On Windows, upper and lower case might cause problems. ABC.png is the same name as abc.png. Replace
name_list = intersect( {s1.name}, {s2.name} );
by
name_list = intersect( lower({s1.name}), lower({s2.name}) );
  댓글 수: 3
per isakson
per isakson 2015년 2월 9일
편집: per isakson 2015년 2월 9일
Absolutely!
Xen
Xen 2015년 2월 9일
Worked perfectly. Thanks again!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Images에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by