我想使用ssim
在2个图像中比较相似性。
我收到此错误window_shape is incompatible with arr_in.shape
。
为什么? (这是什么意思?)
from skimage.measure import structural_similarity as ssim
from skimage import io
img1 = io.imread('http://pasteio.com/m85cc2eed18c661bf8a0ea7e43779e742')
img2 = io.imread('http://pasteio.com/m1d45b9c70afdb576f1e3b33d342bf7d0')
ssim( img1, img2 )
即使两次向同一文件输入相同的文件,我也会收到相同的错误
ssim(img1,img1)
最佳答案
您需要确保图像大小相同,才能将其与scikit的ssim进行比较:
from skimage.measure import compare_ssim
from skimage.transform import resize
from scipy.ndimage import imread
import numpy as np
# resized image sizes
height = 2**10
width = 2**10
a = imread('a.jpg', flatten=True).astype(np.uint8)
b = imread('b.jpg', flatten=True).astype(np.uint8)
a = resize(a, (height, width))
b = resize(b, (height, width))
sim, diff = compare_ssim(a, b, full=True)
关于python - ssim图片比较错误 '' window_shape与arr_in.shape不兼容”,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/32077285/