简体   繁体   中英

How to detect street lines in satellite aerial image using openCV?

I am really new to openCV,I have to detect lines of streets in sattelite imagery

this is the original image

在此处输入图片说明

I applied different thresholds and I am able to differentiate background and fg

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

在此处输入图片说明

after this, I smoothened to remove noise for 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)

在此处输入图片说明

Now when I applied hough lines I am getting this

# 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)

在此处输入图片说明

I need lines like this

在此处输入图片说明

Why it's not working and what should I do?

Not sure if you would want to do this with only with openCV you may also want to use something like tensorflow.

But if you want to use only openCV here are a few options:

You could try to do dilate and erode . And use findContours , and loop through those contours to find objects with a certain minimum length, and use that to create a line from A to B.

Another solution would be to train a cascade to detect parts of the images that are street sections and connect those points. This is a lot more time consuming though.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM