1 function [psnr, mssim ] = psnrssim(Iref, I2, nbits, lmax)
3 % =======================================================================
6 % Last Modified: 2011-12-08
7 %========================================================================
9 %========================================================================
10 %Input : (1) Iref: the ref image
11 % (2) I2 : the image being compared
12 % (3) lmax: max length of paths
13 %========================================================================
15 IcutA = zeros(size(Iref,1), lmax) ;
16 IcutB = [ zeros(lmax, size(Iref,2)- 2*lmax) ; ones(size(Iref)-[ 2*lmax 2*lmax ]) ; zeros(lmax, size(Iref,2)-2*lmax) ] ;
17 Icut = [ IcutA IcutB IcutA] ;
19 Irefcut = double(Iref).*double(Icut) ;
20 I2cut = double(I2).*double(Icut) ;
22 psnr = 10*log10((2^nbits)^2/(mean(mean((I2cut-Irefcut).^2)))) ;
24 mssim = ssim(Irefcut, I2cut) ;