find correlation images in folders and print result in excel using matlab -
i tried compare template image ( image2 ) image folders names test* ( test1 , test 2 .... test n) find correlation between template image images folder , print result in folder go next folder test2 .. till test n , thats mean result of find correlation each image in folder test1 print excel file named ( name ) store in folder test1 , content of excel file follow : first row contain names of images in folder test1 , second row contain correlation result if 0 or 1 after jump next folder test2 ...test3.... etc
the following code tried long time
xls_sheet = 'sheet1'; column_range = 'b'; % initialisation of column range srcfolders = dir('d:\test*'); xls_filename = 'result.xls'; folder = 1:length(srcfolders) path = strcat('d:\',srcfolders(folder).name); xlswrite('d:\srcfiles(i)\xls_filename',{srcfolders(folder).name},xls_sheet,folder_range); %writing name of folder in first row sear = strcat(path, '\*.bmp'); srcfiles = dir(sear); row_range = '2'; srcfolders = dir('d:\'); folder = 1:length(srcfolders) srcfolders(folder).fullname = strcat('image:\',srcfolders(folder).name); end xlswrite('d:\xlsfile', {srcfolders(:).fullname}, 'sheet1','a2'); = 1 : length(srcfiles) filename = strcat(path,'\',srcfiles(i).name); image1= imread(filename); image2 = imread('d:\act','jpeg'); x = corr2(image1,image2); file_range = strcat(column_range, row_range); if (x = 0) xlswrite(xls_filename, {'0'}, xls_sheet, file_range ); %writing '0' in second row else xlswrite(xls_filename, {'1'}, xls_sheet, file_range ); %writing '1' in second row end end row_range = char(row_range + 1); %moving next row column_range = char(column_range + 1); %moving next column end
i print names of files in first row , , questions how :
1- can print excel file in each test* folders .
2- how can repeat process test* folders . in result hope excel file in each , every folder in test1 , test 2 ... contain 1 corr=1 , 0 others images in folder.
Comments
Post a Comment