matab 从多个文件夹读数据,分别计算指标
clear all; close all; clc load modelparameters.mat blocksizerow = 96; blocksizecol = 96; blockrowoverlap = 0; blockcoloverlap = 0; dataset = {'DICM','LIME','MEF','NPE','VV'};%不同的文件夹名 num_set = length(dataset); ext = {'*.jpg', '*.png', '*.bmp'};%不同的图片文件格式 record_results_txt = ['Quality_Results','.txt']; results = fopen(fullfile(record_results_txt), 'wt');%写入.txt文档 for idx_set = 1:2 %for 区间左右都是闭区间 fprintf(results, '**********************\n'); fprintf(results, 'Set: %s\n', dataset{idx_set});%写入results文档 filepaths = []; for idx_ext = 1:length(ext) filepaths = cat(1, filepaths, dir(fullfile('./source', dataset{idx_set}, ext{idx_ext}))); end ret = 0; for idx_im = 1:length(filepaths) name_HR = filepaths(idx_im).name; %fprintf('%s \n',name_HR)%文件的输出顺序依然是1.jpg 10.jpg 2.jpg %fprintf('%s \n',fullfile('./source', dataset{idx_set}, name_HR)) HR = imread(fullfile('./source', dataset{idx_set}, name_HR));%读取所有文件 quality = computequality(HR,blocksizerow,blocksizecol,blockrowoverlap,blockcoloverlap, ... mu_prisparam,cov_prisparam);%一般=最后都要加; 不然每次都要输出 ret = ret + quality; end fprintf(results,"avgrage quality: %.4f\n",ret); end fclose(results);%记住要关闭 fprintf('finshed!!!!');