I'm trying to compare the structural similarity of two images with the skimage package but it only works if use two images saved on my pc and not when I use an image created by ImageGrab from PIL even it's basically the same image.
def structural_sim(img1, img2):
sim, diff = structural_similarity(img1, img2, full=True)
return sim
#doesn't work
tempScreen = ImageGrab.grab(bbox=(985,193,1895,704))
sim = structural_sim(tempScreen, cv2.imread('08-55-48.PNG', 0))
#works
tempScreen = ImageGrab.grab(bbox=(985,193,1895,704))
tempScreen.save("temp.PNG")
sim = structural_sim(cv2.imread('temp.PNG', 0), cv2.imread('08-55-48.PNG', 0))
The error is the following
AttributeError: shape. Did you mean: 'save'?
How can I correctly use the result of ImageGrab.grab
without using .save
and then cv2.imread
?