Python 在弱光图像中应用高斯模糊和Canny边缘检测后的白线检测
我有两张图像,一张是明亮的,边缘检测效果很好,白线清晰可见 然而,还有一张照片是在暗处拍摄的,光线很暗,白线很暗,几乎看不见 原始图像Python 在弱光图像中应用高斯模糊和Canny边缘检测后的白线检测,python,opencv,image-processing,opencv3.0,Python,Opencv,Image Processing,Opencv3.0,我有两张图像,一张是明亮的,边缘检测效果很好,白线清晰可见 然而,还有一张照片是在暗处拍摄的,光线很暗,白线很暗,几乎看不见 原始图像 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_
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')
弱光:
好光:
Canny边缘检测
微光
好光
我可以将哪些图像过滤器应用于这两幅图像,以便为这两幅图像检测到白线。我尝试过灰度和高斯模糊,然后再进行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')
最好尝试自适应thresholding@min2bro您的代码仅在高亮度下生成黑屏,请再次检查您的代码,尤其是内核大小
kernel\u size=125
!我没有和你一样的优势!