function [ PSNR,MSE ] = Psnr( im1,im2 )
%------------------------计算峰值信噪比程序———————————————-----
% im1 : the original image matrix
% im2 : the modified image matrix
if nargin < 2
D = im1;
else
if any(size(im1))~=(size(im2))
error('The input size is not equal to each other!');
end
MSE = sum(D(:).* D(:))/prod(size(x));
PSNR = 10*log10(255^2/MSE);
end
评论0