我不知道这个输出是否对你有好处,但正如@Yves Daoust 所说,侵蚀过程可能会使你的问题受益。
output
import cv2
import numpy as np
image = cv2.imread('hough.jpg')
gray = cv2.cvtColor(image,cv2.COLOR_BGR2GRAY)
kernel = np.ones((3,12), np.uint8) #for horizontal erosion
e_im = cv2.erode(gray, kernel, iterations=1) #performing erosion
edges = cv2.Canny(e_im,190,245,apertureSize = 3) #edges
minLineLength=333
#houghlines for detecting those erosion lines
lines = cv2.HoughLinesP(image=edges,rho=0.5,theta=np.pi/180, threshold=222,lines=np.array([]), minLineLength=minLineLength,maxLineGap=7)
a,b,c = lines.shape
# Draw the lines
if lines is not None:
for i in range(0, len(lines)):
l = lines[i][0]
cv2.line(gray, (l[0], l[1]), (l[2], l[3]), (0, 0, 255), 3, cv2.LINE_AA)
cv2.imwrite("e_im.jpg",gray)