Reputation: 17025
I have a database of around 1000 images and I'm doing texture matching. I have already created the feature vectors and creating feature vectors for one image takes a few minutes. Now I'm doing the matching part. As i dont wanna calculate features for the test image again, I would like to find its index in a given folder.
example: User chooses image_XXXXX.jpg. and I want the "index" of this file i.e, whats its position in that folder
Can anyone tell me how do i find the index of a file(in a folder) chosen by user using MATLAB
?
Upvotes: 0
Views: 261
Reputation: 9317
You can use strcmp
to find this index:
% get all file names in folder
tmp = dir('*.jpg');
% logical index of the chosen file
logicalIDX = strcmp({tmp.name}, 'image_XXXXX.jpg');
% numerical index of the chosen file
numericIDX = find(logicalIDX);
% probably more interesting for this particular case:
% the numerical index of all the files that have to be processed:
numericIDX = find(~logicalIDX);
Upvotes: 1