我有两张图像,一张很亮,边缘检测效果很好,白线清晰可见。
还有另一幅图像是在黑暗中用弱光拍摄的,白线很淡,几乎看不见。
原始图片
弱光:
好光:
Canny Edge Detection
弱光
好光
我可以对这两个图像应用什么图像过滤器,以便对这两个图像都检测到白线。我尝试了灰度和高斯模糊,然后进行了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')