【发布时间】:2020-07-08 06:38:02
【问题描述】:
我正在尝试识别图中的一组线条,但我无法确定应该为霍夫变换选择哪些合适的参数。
img = 255 - cv2.imread('isolate.png', 0)
blank = np.zeros(img.shape) + 255
dilation = cv2.dilate(img, np.ones((2,2)), iterations = 1)
processed = cv2.bitwise_not(dilation)
cv2.imwrite('lol.png', processed)
# cv2.imwrite('process.png',dilation)
lines = cv2.HoughLinesP(processed,rho = 1,theta = 1*np.pi/180,threshold = 100,minLineLength = 180,maxLineGap = 1)
for line in lines:
# import pdb; pdb.set_trace()
x1, y1, x2, y2 = line[0]
cv2.line(processed, (x1, y1), (x2, y2), (255, 0, 0), 1)
cv2.imwrite("result.png", processed)
【问题讨论】:
-
尝试反转图像。霍夫检测黑色背景上的白线
标签: python python-3.x numpy opencv hough-transform