我有这段代码,我想打印这两幅图像中差异中心的(x,y)
坐标
import cv2
import numpy as np
original = cv2.imread("images/original_1.png")
duplicate = cv2.imread("images/original_1_edit.png")
#start image process
# check if 2 images are equals
if original.shape == duplicate.shape:
print("The images have same size and channels")
differenc = cv2.subtract(original, duplicate)
#check the channelas RGB
b, g, r = cv2.split(differenc)
cv2.imshow("differenc", differenc)
if cv2.countNonZero(b) == 0 and cv2.countNonZero(g) == 0 and cv2.countNonZero(r) == 0:
print("The images completely Equal")
cv2.imshow("Original", original)
cv2.imshow("Duplicate", original)
cv2.waitKey(0)
cv2.destroyAllWindows()
当你减去这些图像时,结果显示了差异。你可以把它变成一个面具使用阈值。然后可以找到差异的轮廓,并使用boundingRect计算中心。你知道吗
结果:
代码:
如果您的意思是打印两个不同图像的中心:
我用了PIL,代表枕头你可以下载它使用pip安装枕头
相关问题 更多 >
编程相关推荐