ImportError: cannot import name 'structural_similarity' error

Om Sao picture Om Sao · Mar 15, 2019 · Viewed 16.5k times · Source

In my image comparision code following: https://www.pyimagesearch.com/2014/09/15/python-compare-two-images/

While using from skimage.measure import structural_similarity as ssim

and then s = ssim(imageA, imageB)

I am getting error:

from skimage.measure import structural_similarity as ssim

ImportError: cannot import name 'structural_similarity'

Answer

Om Sao picture Om Sao · Mar 15, 2019

I found the solution. As this question is unique and not covered anywhere. So, posting the answer.

#from skimage.measure import structural_similarity as ssim
from skimage import measure
.
.
.
#s = ssim(imageA, imageB)
s = measure.compare_ssim(imageA, imageB)

Change commented line to uncommented line.