我尝试匹配两张图片,以找出它们之间的分数。但是出现了一些维度错误,无法解决该问题。以下是我的代码:
这会产生一个错误:
如何解决这个问题?
from skimage.measure import compare_ssim
#import argparse
#import imutils
import cv2
img1="1.png"
img2="2.png"
# load the two input images
imageA = cv2.imread(img1)
imageB = cv2.imread(img2)
# convert the images to grayscale
grayA = cv2.cvtColor(imageA, cv2.COLOR_BGR2GRAY)
grayB = cv2.cvtColor(imageB, cv2.COLOR_BGR2GRAY)
# compute the Structural Similarity Index (SSIM) between the two
# images, ensuring that the difference image is returned
(score, diff) = compare_ssim(grayA, grayB, full=True)
diff = (diff * 255).astype("uint8")
print("SSIM: {}".format(score))
这会产生一个错误:
raise ValueError('Input images must have the same dimensions.')
ValueError: Input images must have the same dimensions.
如何解决这个问题?
imageA.shape
和imageB.shape
是什么? - GPhilo