我有一些名为div.find('input:required:not(:readonly, :disabled)')
的文件夹,从测试1到测试100,例如,我需要在第一行打印文件夹名称作为标题。
然后我需要检查我的测试图像image2与这些文件夹中的每个图像如果我的测试图像2和每个文件夹测试*的每个图像之间的差异大于0.05将写入1否则写入0.直到testn。
我的代码如下:
test*
谢谢
答案 0 :(得分:0)
%On every 'folder loop', increment the column range so you have 1 column by folder
%On every 'file loop', increment the row range so you have 1 row by file
xls_filename = 'foo.xls'; %The name of your xls file
xls_sheet = 'sheet_name'; % Put here the name of the sheet you want to write in
column_range = 'A' % Initialisation of the column range
srcFolders = dir('D:\test*');
for folder = 1:length(srcFolders)
path = strcat('D:\',srcFolders(folder).name);
folder_range = strcat(column_range, '1');
xlswrite(xls_filename, {srcFolders(folder).name}, xls_sheet, folder_range); %Writing the name of the folder in the first row
sear = strcat(path, '\*.bmp');
srcFiles = dir(sear);
row_range = '2';
for i = 1 : length(srcFiles)
filename = strcat(path,'\',srcFiles(i).name);
Image1= imread(filename);
Image2 = imread('D:\2','jpeg');
x = diff( Image2 , Image1);
file_range = strcat(column_range, row_range);
if (x >= 0.05)
xlswrite(xls_filename, {'0'}, xls_sheet, file_range ); %Writing '0' in the second row
else
xlswrite(xls_filename, {'1'}, xls_sheet, file_range ); %Writing '1' in the second row
end
row_range = char(row_range + 1); %Moving to the next row
end
column_range = char(column_range + 1); %Moving to the next column
end