1 function y=PSNR(noisyImage,restoredImage)
\r
3 % Compute the PSNR of two gray scale image
\r
4 % Traditional progarmming using loops
\r
5 % Class input : [0,1]
\r
11 error('Input must be grayscale image');
\r
13 if size(noisyImage)~=size(restoredImage)
\r
14 error('The images must have the same size');
\r
17 %if ~isa(noisyImage,'double')
\r
18 % noisyImage=double(noisyImage)./255.00;
\r
20 %if ~isa(restoredImage,'double')
\r
21 % restoredImage=double(restoredImage)./255.00;
\r
26 d1=max(noisyImage(:));
\r
27 d2=max(restoredImage(:));
\r
33 if isnan(noisyImage(i,j)) || isinf(restoredImage(i,j))...
\r
34 || isnan(restoredImage(i,j)) || isinf(noisyImage(i,j))
\r
37 MSE=MSE+((abs(noisyImage(i,j)-restoredImage(i,j))).^2);
\r
41 MSE=MSE./(N(1)*N(2));
\r
43 y=10*log10((d.^2) /MSE)
\r