⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 psnr.m

📁 Function that calculate the PSNR and WSNR of two imagines
💻 M
字号:
 
function S=PSNR(I,J)
% PSNR(I,J) returns the peak signal to noise ratio) between I and J %(dB)
% I is the original image and J is a modified version of I. 
% The PSNR value is useful to calculate the distortions on an image.

if (size(I)~=size(J))
   error('The dimension of the images have to be equals')
else
 
   [m n] = size(I);
   A=double(I);
   B=double(J);
   sumaDif=0;
   maxI=m*n*max(max(A.^2));
   for u=1:m
      for v=1:n
         sumaDif = sumaDif + (A(u,v)-B(u,v))^2;
      end
   end
   if (sumaDif==0) 
      sumaDif=1;
   end
   S=maxI/sumaDif;
   S=10*log10(S);
end
 
    

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -