效果
处理前
处理后,标注路线 斜率
代码
图像处理
#
equ = cv2.equalizeHist(gray)
#
gaussian = cv2.GaussianBlur(gray, (3, 3), 0, 0, cv2.BORDER_DEFAULT)
#
median = cv2.medianBlur(gaussian, 5)
#
sobel = cv2.Sobel(median, cv2.CV_8U, 1, 0, ksize = 3)
#
ret, binary = cv2.threshold(sobel, 30,255, cv2.THRESH_BINARY)
#
element1 = cv2.getStructuringElement(cv2.MORPH_RECT, (3, 1))
element2 = cv2.getStructuringElement(cv2.MORPH_RECT, (2, 1))
#
erosion = cv2.erode(binary, element1, iterations = 1)
#
dilation = cv2.dilate(erosion, element2, iterations = 1)