Python 如何使用openCV检测卫星航空图像中的街道线?

Python 如何使用openCV检测卫星航空图像中的街道线?,python,opencv,image-processing,hough-transform,Python,Opencv,Image Processing,Hough Transform,我对openCV真的很陌生,我必须检测卫星图像中的街道线条 这是原始图像 我应用了不同的阈值,我能够区分背景和前景 retval, threshold = cv2.threshold(img1,150, 255, cv2.THRESH_BINARY) plt.imshow(threshold) 在此之后,我平滑以消除HoughLines的噪波 # Initialize output out = cv2.cvtColor(threshold, cv2.COLOR_GRAY2BGR) # M

我对openCV真的很陌生,我必须检测卫星图像中的街道线条

这是原始图像

我应用了不同的阈值,我能够区分背景和前景

retval, threshold = cv2.threshold(img1,150, 255, cv2.THRESH_BINARY)
plt.imshow(threshold)

在此之后,我平滑以消除HoughLines的噪波

# Initialize output
out = cv2.cvtColor(threshold, cv2.COLOR_GRAY2BGR)

# Median blurring to get rid of the noise; invert image
threshold_blur = 255 - cv2.medianBlur(threshold, 5)

plt.imshow(threshold_blur,cmap='gray', vmin = 0, vmax = 255)

现在,当我应用hough线时,我得到了这个

# Detect and draw lines
lines = cv2.HoughLinesP(threshold_blur, 1, np.pi/180, 10, minLineLength=10, maxLineGap=100)
for line in lines:
    for x1, y1, x2, y2 in line:
        cv2.line(out, (x1, y1), (x2, y2), (0, 0, 255), 2)
plt.imshow(out)

我需要这样的线条


为什么它不起作用?我该怎么办?

不确定您是否只想使用openCV来实现这一点,您可能还想使用tensorflow之类的工具

但如果您只想使用openCV,这里有几个选项:

你可以试着去做。使用,并循环通过这些轮廓,找到具有一定最小长度的对象,并使用该长度创建从a到B的直线


另一个解决方案是训练a来检测街道部分的图像并连接这些点。不过这要花很多时间。

您是否尝试过反转图像?这很可能是Hough线变换期望图像具有暗背景和亮线。这些级联也可以用于图像分割吗?