2012-05-16 87 views

回答

1

下面是一個文件夾中任意數量圖像的通用代碼。如果您確定每個文件夾有3個圖像並且您知道每個文件夾的文件名格式,則可以簡化它。

%# Set the relative path for the database 
basePath = 'Database/CASIA Iris Image Database (version 1.0)/'; 

for iFolder = 1:108 
    %# Set current folder 
    folder = sprintf('%s%03d/', basePath, iFolder); 

    %# Find the image (e.g. bmp) files in the folder. Modify bmp for your needs. 
    %# and also modify 'left' string according to the subfolder of left images 
    filenames = arrayfun(@(x) x.name, dir([folder 'left/*.bmp']),'UniformOutput',false); 

    for iFile = 1:length(filenames) 
     img = imread([folder filenames{iFile}]); 

     %# and process the image 
     %# ... 

    end 

    %# Modify the code for to run it for right folder 
    %# ... 
end 
+0

謝謝你的幫助,烏爾.........但我面對的問題,因爲我的文件夾數據庫/ CASIA-IrisV1 /由108個文件夾(108人爲他們每個人的,我有左2個文件夾和右眼,每個左右文件夾我有3個圖像)............我修改你的代碼,但有錯誤。 – Muna

+0

這可能是因爲您忘記了路徑中的左側和右側子文件夾。相應地修改代碼。 – petrichor

+0

謝謝你的幫助... – Muna

相關問題