Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
353 views
in Technique[技术] by (71.8m points)

find correlation images in folders and print result in excel using matlab

I tried to compare my template image ( image2 ) with image folders names as test* ( test1 , test 2 .... test n) to find correlation between my template image with images from that folder , then print result in that folder then go to next folder test2 .. till test n , thats mean the result of find correlation with each image in folder test1 its print as excel file named ( any name ) store in folder test1 and the content of that excel file as follow : first row contain the names of images in folder test1 , second row contain the correlation result if 0 or 1 after that its jump to next folder test2 ...test3.... etc

the following code i tried long time

xls_sheet = 'Sheet1'; 
column_range = 'B'; % Initialisation of the column range
srcFolders = dir('D:	est*');
xls_filename = 'result.xls';
for folder = 1:length(srcFolders)
path = strcat('D:',srcFolders(folder).name);
xlswrite('D:srcFiles(i)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';
srcFolders = dir('D:');
 for folder = 1:length(srcFolders)
  srcFolders(folder).fullname = strcat('image:',srcFolders(folder).name);
 end
 xlswrite('D:xlsFile', {srcFolders(:).fullname}, 'Sheet1','A2');
 for i = 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 the  second row
   else
 xlswrite(xls_filename, {'1'}, xls_sheet, file_range ); %Writing '1' in the   second row
end
end
row_range = char(row_range + 1); %Moving to the next row
column_range = char(column_range + 1); %Moving to the next column
end

i print names of files in first row , and my questions how :

1- we can print excel file in each test* folders .

2- how can i repeat this process for all test* folders . in the result i hope to get excel file in each and every folder in test1 , test 2 ... that contain 1 for corr=1 and 0 for others for all images in that folder.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...