峰值信噪比PSNR

通常用PSNR来评价一幅图像压缩后和原图像相比质量的好坏
PSNR越高,压缩后失真越小


均方差MSE
峰值信噪比PSNR

MAX是图像的灰度级,一般就是256

function psnr=compute_psnr(im1,im2)
if size(im1, 3) == 3,
    im1 = rgb2ycbcr(im1);
    im1 = im1(:, :, 1);
end

if size(im2, 3) == 3,
    im2 = rgb2ycbcr(im2);
    im2 = im2(:, :, 1);
end

imdff = double(im1) - double(im2);
imdff = imdff(:);

rmse = sqrt(mean(imdff.^2));
psnr = 20*log10(255/rmse);

你可能感兴趣的:(峰值信噪比PSNR)