我想拍两张相同的照片并使用库来指示或突出差异所在(显示差异)。我使用了下面的代码,但是在看到输出时出现错误。两张照片完全相同,唯一的区别是一张含有癌细胞。换句话说,代码带有突出显示的癌细胞。(如附图所示)但如果有其他方法我可以去,请告诉我!
这是代码:
from PIL import Image ,ImageChops
img1 = Image.open('./download1.jpg')
img2 = Image.open('./download.jpg')
diff = ImageChops.difference = (img1, img2)
if diff.getbbox():
diff.show()
这是我收到的错误输出
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-79-e547971e9933> in <module>()
5 diff = ImageChops.difference = (img, img2)
6
----> 7 if diff.getbbox():
8 diff.show()
AttributeError: 'tuple' object has no attribute 'getbbox'