一、PSNR.m
clear;
name = 'balloons336';
file_path = ['result\',name,'\'];%图像文件夹路径
gndname = 'balloons6_1.bmp';
gnd = imread(strcat(file_path,gndname));%读ground-truth图像
img_path_list = dir(strcat(file_path,'*.bmp'));%获取该文件夹中所有bmp格式的图像
img_num = length(img_path_list);%获取图像总数量
fid = fopen(strcat(file_path,'psnr.txt'),'w');
for i = 1:img_num %逐一读取图像
image_name = img_path_list(i).name;%图像名
if ~strcmp(image_name,gndname) %字符串比较,如果不相等...
image = imread(strcat(file_path,image_name));
[PSNR,MSE]=GetPSNR(image,gnd);
fprintf(fid,' %f \t\t %f \t\t %s \r\n',PSNR,MSE,image_name);
end
end
fclose(fid);
注释:第二行name= ,为 result\ 的文件名
第三行file_path= ,这里result为PSNR.m同一目录下的文件,可根据实际情况更改。
第四行gndname= ,这里为ground-truth,存放路径为 result\balloons336\ 。
二、SSIM.m
function [mssim, ssim_map] = ssim(img1, img2, K, window, L)
%========================================================================
%SSIM Index, Version 1.0
%Copyright(c) 2003 Zhou Wang
%All Rights Reserved.
%
%The author is with Howard Hughes Medical Institute, and Laboratory
%for Computational Vision at Center for Neural Science and Courant
%Institute of Mathematical Sciences, New York University.
%
%----------------------------------------------------------------------
%Permission to use, copy, or modify this software and its documentation
%for educational and researc