1. 程式人生 > >從主檔案中讀取n個子資料夾中的圖片(每一子檔案中有兩個資料夾,每兩個檔案中有18張圖片)

從主檔案中讀取n個子資料夾中的圖片(每一子檔案中有兩個資料夾,每兩個檔案中有18張圖片)

tic clc; clear all; close all; str = 'F:\shijie-test\test-finger\'; pt = dir(str); foldname = []; k = 0; for i = 1 : length(pt)     ifstrcmp(pt(i).name, '.') | strcmp(pt(i).name, '..')         continue;     else         k = k + 1;         foldname{k} = pt(i).name;     end end for i = 1:length(foldname)     temp = strcat(str, foldname{i}, '\'
);     temp1 = dir(temp);     k = 0;     for j = 1:length(temp1)         ifstrcmp(temp1(j).name, '.') | strcmp(temp1(j).name, '..')             continue;         else             k = k + 1;             foldname1{i, k} = temp1(j).name;             foldname1{i, k} = strcat(temp, foldname1{i, k}, '\');         end
    end end  [m, n] = size(foldname1); for i = 1:m     for j = 1:2         temp = strcat(foldname1{i, j}, '*.bmp');         temp1 = dir(temp);         for k = 1:length(temp1)             if 1 == j                 jpgpath{i, k} = strcat(foldname1{i, j},  temp1(k).name);             end             if
2 == j                 jpgpath{i, 18 + k} = strcat( foldname1{i, j}, temp1(k).name);             end             end     end end celldisp(jpgpath); toc