在弱光图像中应用高斯模糊和Canny边缘检测后的白线检测

时间:2020-10-09 10:32:21

标签: python opencv image-processing opencv3.0

我有两张图像,一张很亮,边缘检测效果很好,白线清晰可见。

还有另一幅图像是在黑暗中用弱光拍摄的,白线很淡,几乎看不见。

原始图片

弱光:

enter image description here

好光:

enter image description here

Canny Edge Detection

弱光

enter image description here

好光

enter image description here

我可以对这两个图像应用什么图像过滤器,以便对这两个图像都检测到白线。我尝试了灰度和高斯模糊,然后进行了Canny边缘检测,但是效果不佳

我的代码

img = mpimg.imread(filenm)

# first convert to grayscale
grayscale = cv2.cvtColor(img, cv2.COLOR_RGB2GRAY)

#apply gaussian blur before canny edge detection
kernel_size=125
gaussian_blurred = cv2.GaussianBlur(grayscale,(kernel_size, kernel_size), 0)

# Canny edge detection threshold ratio 1:3
low_threshold = 50
high_threshold = 150
edges = cv2.Canny(gaussian_blurred, low_threshold, high_threshold)


plt.imshow(edges, cmap='Greys_r')

0 个答案:

没有答案
相关问题