Öme*_*Gül 2 matlab jpeg image-processing
我有原始图像和原始图像的扭曲图像.我想计算失真图像的PSNR,这样我就可以用dB来测量失真.图像类型为彩色jpeg.
我不知道你之前使用过什么,但你可以使用以下代码来计算更改图像的PSNR:
I = imread('original.jpg');
Ihat = imread('changed.jpg');
% Read the dimensions of the image.
[rows columns ~] = size(I);
% Calculate mean square error of R, G, B.
mseRImage = (double(I(:,:,1)) - double(Ihat(:,:,1))) .^ 2;
mseGImage = (double(I(:,:,2)) - double(Ihat(:,:,2))) .^ 2;
mseBImage = (double(I(:,:,3)) - double(Ihat(:,:,3))) .^ 2;
mseR = sum(sum(mseRImage)) / (rows * columns);
mseG = sum(sum(mseGImage)) / (rows * columns);
mseB = sum(sum(mseBImage)) / (rows * columns);
% Average mean square error of R, G, B.
mse = (mseR + mseG + mseB)/3;
% Calculate PSNR (Peak Signal to noise ratio).
PSNR_Value = 10 * log10( 255^2 / mse);
Run Code Online (Sandbox Code Playgroud)