1、原始图像
lenna512.bmp
2、对比图像
lenna512_low_dynamic_range.bmp
3、MATLAB程序代码
img1 = imread('lenna512.bmp'); img2 = imread('lenna512_low_dynamic_range.bmp'); [h1 w1] = size(img1); %Get image size of img1 img1 = double(img1); %Convert the unit8 image to double img2 = double(img2); B = 8; %Encode a pixel using 8-bit binary MAX = 2^B-1; %Calculate how many gray levels the image has MSE = sum(sum((img1 - img2).^2)) / (h1 * w1); %Calculate the mean square error PSNR = 20 * log10(MAX / sqrt(MSE)); %Calculate the PSNR in dB
4、计算结果