Computer Vision: Image Quality Evaluation Index PSNR and SSIM

1. PSNR (Peak Signal-to-Noise Ratio) Peak Signal-to-Noise Ratio

It can be seen from the above that PSNR has one more peak value than MSE. MSE is the absolute error, and the peak value is a relative error indicator. 

Generally, for uint8 data, the maximum pixel value is 255, and for floating-point data, the maximum pixel value is 1.

The above is the calculation method for grayscale images. If it is a color image, there are usually three methods to calculate it.

  • Calculate the PSNR of the three RGB channels separately, and then take the average.
  • Calculate the MSE of the three RGB channels, and then divide it by 3.
  • Convert the image to YCbCr format, and then calculate only the PSNR of the Y component, which is the brightness component.

Among them, the second and third methods are more common.

# im1 和 im2 都为灰度图像,uint8 类型

# method 1
diff = im1 - im2
mse = np.mean(np.square(diff))
psnr = 10 * np.log10(255 * 255 / mse)

# method 2
psnr = skimage.measure.compare_psnr(im1, im2, 255)

compare_psnr(im_true, im_test, data_range=None) function prototype can be found here

For hyperspectral images, we need to calculate PSNR for different bands and then average it. This indicator is called MPSNR.

In lossy image and video compression, typical values ​​for PSNR are between 30 and 50 dB, assuming a bit depth of 8 bits, with higher bit depths being better. When 12-bit, the image processing quality is considered to be higher when the PSNR value is 60 dB or higher. For 16-bit data, typical PSNR values ​​are between 60 ~ 80db. Acceptable values ​​for wireless transmission quality loss are considered to be approximately 20 dB to 25 dB. (for reference)

2. SSIM (Structural SIMilarity) structural similarity

# im1 和 im2 都为灰度图像,uint8 类型
ssim = skimage.measure.compare_ssim(im1, im2, data_range=255)

compare_ssim(X, Y, win_size=None, gradient=False, data_range=None, multichannel=False, gaussian_weights=False, full=False, **kwargs) The function prototype can be found here

For hyperspectral images, we need to calculate SSIM separately for different bands and then average it. This indicator is called MSSIM.

Guess you like

Origin blog.csdn.net/DragonGirI/article/details/131939036