我正在使用以下代码读取图像并将该图像与文件夹中的 13 个图像进行比较,然后发现错误并将其导出到 Excel。
clear all;
clc;
workspace; % Make sure the workspace panel is showing.
ReferenceImage = imread('F:\R\CS\0.8\0.6\6.jpg');
[rows columns] = size(ReferenceImage);
fpath = fullfile('F:\R\CT\0.0\0.2\','*.jpg');
img_dir = dir(fpath);
for k=1:length(img_dir)
input_image=strcat('F:\R\CT\0.0\0.2\',img_dir(k).name);
noisyImage = imread(input_image);
squaredErrorImage = (double(ReferenceImage) - double(noisyImage)) .^ 2;
mse = sum(sum(squaredErrorImage)) / (rows * columns);
xlswrite('F:\R\DataX.xls',mse,'A1:A13');
PSNR = 10 * log10( 256^2 / mse);
xlswrite('F:\R\DataX.xls',PSNR,'B1:B15');
end
我希望 Excel 工作表有一个用于 MSE 的列和一个用于 PSNR 的列,其中显示了每个计算的错误。
例如让我们说,
Image Ref and Image 1, MSE =2; PSNR = 3
Image Ref and Image 2, MSE =3; PSNR = 3
Image Ref and Image 3, MSE =2; PSNR = 4
Image Ref and Image 4, MSE =5; PSNR = 8
我希望 excel 表看起来像
2 3
3 3
2 4
5 8
但相反,我正在创建的工作表是重复数字。请帮忙。