Approximation quality metrics
[PSNR,MSE,MAXERR,L2RAT]
= measerr(X,XAPP)
[...] = measerr(...,BPS)
[
returns
the peak signaltonoise ratio, PSNR
,MSE
,MAXERR
,L2RAT
]
= measerr(X
,XAPP
)PSNR
, mean square
error, MSE
, maximum squared error, MAXERR
,
and ratio of squared norms, L2RAT
, for an input
signal or image, X
, and its approximation, XAPP
.
[...] = measerr(...,
uses
the bits per sample, BPS
)BPS
, to determine the peak
signaltonoise ratio.





Default: 8 



The mean square error (MSE) is the squared norm of the difference between the data and the approximation divided by the number of elements. 




Measure approximation quality in an RGB image.
X = imread('africasculpt.jpg'); Xapp = X; Xapp(X<=100) = 1; [psnr,mse,maxerr,L2rat] = measerr (X,Xapp) figure; subplot(1,2,1); image(X); subplot(1,2,2); image(Xapp);
Approximate an image and calculate approximation quality metrics.
Load an image.
load woman;
Define the image approximation.
Xapp = X; Xapp(X<=50) = 1;
Calculate approximation quality metrics.
[psnr,mse,maxerr,L2rat] = measerr(X,Xapp)
psnr = 26.5884 mse = 142.6411 maxerr = 47 L2rat = 0.9910
Create a plot.
figure; colormap(map); subplot(1,2,1); image(X); subplot(1,2,2); image(Xapp);
HuynhThu, Q.Scope of validity of PSNR in image/video quality assessment, Electronics Letters, 44, 2008, pp. 800–801.