Approximation quality metrics
[...] = measerr(...,BPS)
the peak signal-to-noise ratio,
PSNR, mean square
MSE, maximum squared error,
and ratio of squared norms,
L2RAT, for an input
signal or image,
X, and its approximation,
[...] = measerr(..., uses
the bits per sample,
BPS, to determine the peak
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.
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);
The following equation defines the PSNR:
where MSE represents the mean square error and B represents the bits per sample.
The mean square error between a signal or image, X, and an approximation, Y, is the squared norm of the difference divided by the number of elements in the signal or image:
Huynh-Thu, Q.Scope of validity of PSNR in image/video quality assessment, Electronics Letters, 44, 2008, pp. 800–801.