【发布时间】:2016-04-07 02:24:11
【问题描述】:
以下是在 python 中使用 opencv 来查找相同大小的两个图像的像素差异的代码。但是,它在最后一行给了我一个错误,我不知道如何修复它。
if h1==h2:
if w1==w2:
c=np.zeros((h1,w1,3),np.uint8)
for i in range(img1.shape[0]):
for j in range(img1.shape[1]):
c[j][i]=img1[j][i]-img2[j][i]
IndexError:索引 480 超出轴 0 的范围,大小为 480
【问题讨论】:
-
感谢您的宝贵回复.. 但我尝试了您建议的这种方法。但它返回错误 TypeError: list indices must be integers, not tuple 如何将结果存储为数组以显示它作为图像。