1)首先,我将失真图像与另一个jpeg图像进行比较,结果为26.77 dB。
2)然后,我从失真的图像中消除了噪声,然后再次进行比较,然后得出了较低的psnr,即26.20 dB。。
任何人都可以纠正我的错误,为什么失真图像的PSNR更高?`
附加Psnr码
grayImage = imread('img84.jpeg');
I=rgb2gray(grayImage);
% I=rgb2gray(grayImage);
[rows columns] = size(grayImage);
Display the first image.
subplot(2, 2, 1);
imshow(grayImage, []);
title('YUV Frame ', 'FontSize', fontSize);
set(gcf, 'Position', get(0,'Screensize')); % Maximize figure.
Get a second image by adding noise to the first image.
noisyImage = imread('frame84.jpg');
J=rgb2gray(noisyImage);
[rows columns] = size(noisyImage);
Display the second image.
subplot(2, 2, 2);
imshow(noisyImage, []);
title('Before Processing', 'FontSize', fontSize);
------ PSNR CALCULATION ----------------------------------------------------------
squaredErrorImage = (double(grayImage) - double(noisyImage)) .^ 2;
title('Squared Error Image', 'FontSize', fontSize);
mse = sum(squaredErrorImage(:)) / (rows * columns);
Calculate PSNR (Peak Signal to Noise Ratio) from the MSE according to the formula.
PSNR = 10 * log10( 256^2 / mse);
message = sprintf('The mean square error is %.2f.\nThe PSNR = %.2f', mse, PSNR);
msgbox(message);