This Python function calculates the structural similarity (SSIM) index for grayscale or color images. The index range from -1 to +1, closer to +1 indicates the high similarity to the reference image, -1 informs the highest dissimilarity.
Example: SSIM value and map image.
SSIM value | SSIM map image |
---|---|
0.9407032 |
Python
Python Imaging Library (PIL)
NumPy library (numpy)
Matplotlib
[1]. Wang, Zhou, Alan C. Bovik, Hamid R. Sheikh, and Eero P. Simoncelli. "Image quality assessment: from error visibility to structural similarity." IEEE transactions on image processing 13, no. 4 (2004): 600-612.
[2]. Wang, Zhou, Eero P. Simoncelli, and Alan C. Bovik. "Multiscale structural similarity for image quality assessment." In The Thrity-Seventh Asilomar Conference on Signals, Systems & Computers, 2003, vol. 2, pp. 1398-1402. Ieee, 2003.
Please provide feedback for further improvements.