import cv2
import numpy as np
edges_img.jpg
edge_img = cv2.imread('edges_img.jpg',cv2.IMREAD_GRAYSCALE)
mask = np.zeros_like(edge_img)
mask = cv2.fillPoly(mask,np.array([[[81,240],[212,143],[230,143],[386,238]]]),color=255)
#像素点用画图就能测出来
把鼠标放在图片上就可以测出像素点
cv2.imshow('mask',mask)
cv2.waitKey(0)
输出结果:
masked_edge_img = cv2.bitwise_and(edge_img,mask)
cv2.imshow('masked',masked_edge_img)
cv2.waitKey(0)
输出结果: