2013-03-11 111 views
0

我有一個數據庫大約有1000個圖像,我正在進行紋理匹配。我已經創建了特徵向量,併爲一個圖像創建特徵向量需要幾分鐘的時間。現在我正在做匹配部分。由於我不想再爲測試圖像計算特徵,我想在給定的文件夾中找到它的索引。文件夾中的文件索引

示例:用戶選擇image_XXXXX.jpg。我想這個文件的「索引」,即什麼是它在該文件夾中的位置

誰能告訴我如何找到用戶使用MATLAB選擇的文件(在文件夾中)的索引?

回答

1

您可以使用strcmp找到這個指數:

% 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); 
+0

感謝。這有幫助 – 2013-03-11 12:59:46

相關問題