Skip to content

Instantly share code, notes, and snippets.

@Shellbye
Created September 19, 2017 11:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Shellbye/1d57fdac431c559f52ab2942e45c22eb to your computer and use it in GitHub Desktop.
Save Shellbye/1d57fdac431c559f52ab2942e45c22eb to your computer and use it in GitHub Desktop.
compare two image similarity
# -*- coding:utf-8 -*-
# Created by shellbye on 2017/9/19.
from PIL import Image
from skimage.measure import compare_ssim as ssim
import numpy as np
# requirements
# pip install scikit-image
# pip install pillow
def load_image(infilename):
img = Image.open(infilename)
img.load()
data = np.asarray(img, dtype="int32")
return data
if __name__ == '__main__':
imageA = load_image('images/1.jpg')
imageB = load_image('images/2.jpg')
s = ssim(imageA, imageB, multichannel=True)
print(s)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment