PSNR and SSIM Test
PSNR (Peak Signal-to-Noise Ratio)
PSNR (Peak Signal-to-Noise Ratio) is a widely used metric in digital image processing, especially in the evaluation of image compression quality. Image compression is essential for reducing the storage size and bandwidth required for transmitting images over networks. In this context, PSNR offers a quantitative measure of how closely a compressed image retains the quality of the original image.
The PSNR value is derived from the MSE (Mean Squared Error) between the original and the compressed image. The MSE represents the average of the squares of the differences between corresponding pixels in the two images. It is calculated using the formula:
where is the pixel value of the original image, is the pixel value of the compressed image at coordinates , and is the size of the images in terms of pixels.
The PSNR is then calculated from the MSE as follows:
Here, represents the maximum possible pixel value of the image, which is 255 for 8-bit images. The PSNR is expressed in decibels (dB), and a higher PSNR value indicates a lower level of error, meaning the compressed image is more similar to the original image.
The significance of PSNR in image compression lies in its ability to provide a clear, objective measure of the quality of compressed images. It is particularly useful for comparing the performance of different compression algorithms. By evaluating the PSNR values, developers can optimize algorithms to achieve the best balance between compression rate and image quality. Moreover, PSNR is valuable for adjusting compression parameters to meet specific quality requirements, which is essential for applications like digital television, online video streaming, and satellite imagery.
In summary, PSNR, through its reliance on the MSE formula, serves as a cornerstone in assessing the efficacy of image compression techniques. It not only aids in the development of new compression algorithms but also in the fine-tuning of existing ones to ensure that they deliver the highest possible image quality.
Structural Similarity Index Measure (SSIM)
The Structural Similarity Index Measure (SSIM) is a perceptual metric that quantifies the image quality degradation caused by processing such as compression or transmission. It measures the similarity between two images by evaluating changes in structural information, luminance, and contrast.
The SSIM index between two image windows
and
of size
is given by:
where:
-
is the average of -
is the average of -
is the variance of -
is the variance of -
is the covariance of and -
and are constants to stabilize the division-
is the dynamic range of pixel values (typically ) -
and are small constants, typically and
-
The SSIM index ranges from -1 to 1:
- 1: Indicates perfect similarity between the two images, meaning they are identical in terms of structural content, luminance, and contrast.
- 0 to <1: Indicates varying degrees of similarity, with values closer to 1 indicating higher similarity.
- 0: Indicates no structural similarity between the two images.
- <0 to -1: Indicates structural dissimilarity, which is rarely encountered in practical scenarios as it suggests negative correlation.
In practical applications, an SSIM index close to 1 signifies that the images being compared are highly similar, while values further from 1 indicate greater dissimilarity.