Created
September 19, 2017 11:37
-
-
Save Shellbye/1d57fdac431c559f52ab2942e45c22eb to your computer and use it in GitHub Desktop.
compare two image similarity
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- 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