Canny邊緣檢測(cè)+霍夫變換
顏色閾值+圖像掩模的方法雖然簡(jiǎn)單,但是只能應(yīng)對(duì)一些固定顏色車道線的場(chǎng)景。圖像像素受光照影響將是一個(gè)極其常見(jiàn)的問(wèn)題。
canny邊緣檢測(cè)+霍夫變換是另外一種簡(jiǎn)單提取車道線的方法。首先依靠canny提取到原圖像的邊緣信息,再依靠霍夫變換提取滿足要求的直線
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
import numpy as np
import cv2
# Read in and grayscale the image
image = mpimg.imread('test.jpg')
gray = cv2.cvtColor(image,cv2.COLOR_RGB2GRAY)
# Define a kernel size and apply Gaussian smoothing
kernel_size = 5
blur_gray = cv2.GaussianBlur(gray,(kernel_size, kernel_size),0)
# Define our parameters for Canny and apply
low_threshold = 50
high_threshold = 150
edges = cv2.Canny(blur_gray, low_threshold, high_threshold)
# Next we'll create a masked edges image using cv2.fillPoly()
mask = np.zeros_like(edges)
ignore_mask_color = 255
# This time we are defining a four sided polygon to mask
imshape = image.shape
vertices = np.array([[(0,imshape[0]),(0, 0), (imshape[1], 0), (imshape[1],imshape[0])]], dtype=np.int32) # all image
# vertices = np.array([[(0,imshape[0]),(554, 460), (700, 446), (imshape[1],imshape[0])]], dtype=np.int32) # defining a quadrilateral region
cv2.fillPoly(mask, vertices, ignore_mask_color)
masked_edges = cv2.bitwise_and(edges, mask)
# Define the Hough transform parameters
# Make a blank the same size as our image to draw on
rho = 1 # distance resolution in pixels of the Hough grid
theta = np.pi/180 # angular resolution in radians of the Hough grid
threshold = 1 # minimum number of votes (intersections in Hough grid cell)
min_line_length = 5 #minimum number of pixels making up a line
max_line_gap = 1 # maximum gap in pixels between connectable line segments
line_image = np.copy(image)*0 # creating a blank to draw lines on
# Run Hough on edge detected image
# Output "lines" is an array containing endpoints of detected line segments
lines = cv2.HoughLinesP(masked_edges, rho, theta, threshold, np.array([]),
min_line_length, max_line_gap)
# Iterate over the output "lines" and draw lines on a blank image
for line in lines:
for x1,y1,x2,y2 in line:
cv2.line(line_image,(x1,y1),(x2,y2),(255,0,0),10)
# Create a "color" binary image to combine with line image
color_edges = np.dstack((edges, edges, edges))
# Draw the lines on the edge image
lines_edges = cv2.addWeighted(color_edges, 0.8, line_image, 1, 0)
plt.imshow(lines_edges)
plt.show()
canny邊緣后,進(jìn)行霍夫直線檢測(cè)的結(jié)果

在此基礎(chǔ)上,增加一個(gè)四邊形的圖像掩模的結(jié)果
四邊形的設(shè)定,寫(xiě)在了代碼中,只是進(jìn)行了注釋

總結(jié):
以上兩種方法只適合簡(jiǎn)單的demo,顯然并不能識(shí)別具備一定曲率的車道線,也無(wú)法適應(yīng)光照不同的情況。
聲明:本文內(nèi)容及配圖由入駐作者撰寫(xiě)或者入駐合作網(wǎng)站授權(quán)轉(zhuǎn)載。文章觀點(diǎn)僅代表作者本人,不代表電子發(fā)燒友網(wǎng)立場(chǎng)。文章及其配圖僅供工程師學(xué)習(xí)之用,如有內(nèi)容侵權(quán)或者其他違規(guī)問(wèn)題,請(qǐng)聯(lián)系本站處理。
舉報(bào)投訴
-
邊緣檢測(cè)
+關(guān)注
關(guān)注
0文章
94瀏覽量
18674 -
Canny
+關(guān)注
關(guān)注
0文章
14瀏覽量
9912 -
python
+關(guān)注
關(guān)注
57文章
4876瀏覽量
90029
發(fā)布評(píng)論請(qǐng)先 登錄
相關(guān)推薦
熱點(diǎn)推薦
Canny雙閾值邊緣檢測(cè)和弱邊緣連接詳解
在上一篇FPGA圖像處理--Canny邊緣檢測(cè)(一)里介紹了Canny邊緣檢測(cè)的NMS計(jì)算,這里
基于Canny邊緣檢測(cè)算子的圖像檢索算法
【摘要】:針對(duì)依賴傳統(tǒng)Canny算子的基于邊緣的圖像檢索系統(tǒng)所存在的不足,提出一種基于Canny邊緣檢測(cè)的圖像檢索算法。使用改進(jìn)的
發(fā)表于 04-24 10:03
【DragonBoard 410c試用體驗(yàn)】之OpenCV中canny算子邊緣檢測(cè)
有顯著變化的點(diǎn)凸顯出來(lái)。在具體編程實(shí)現(xiàn)時(shí),可通過(guò)計(jì)算梯度幅值來(lái)確定。 檢測(cè):經(jīng)過(guò)增強(qiáng)的圖像,往往鄰域中有很多點(diǎn)的梯度值比較大,而在特定的應(yīng)用中,這些點(diǎn)并不是我們要找的邊緣點(diǎn),所以應(yīng)該采用某種方
發(fā)表于 09-11 23:24
關(guān)于canny算子邊緣檢測(cè)的問(wèn)題
本帖最后由 豆吖豆 于 2017-4-4 23:14 編輯
grd=edge(Egray,'canny',0.09,'both');大神門(mén) 問(wèn)一下這個(gè)后面的0.09和both什么意思是指的是Egray圖像的上下大小還是,另外可以的話能大概說(shuō)說(shuō)這個(gè)canny
發(fā)表于 04-04 22:27
Labview圖像處理——邊緣檢測(cè)
邊緣的灰度值過(guò)度較為明顯,梯度算子可以得到較好的邊緣檢測(cè)結(jié)果。邊緣提取其實(shí)也是一種濾波,不同的算子有不同的提取效果。比較常用的方法有三種,S
發(fā)表于 12-01 12:16
基于圖像的車道線檢測(cè)
基于圖像的車道線檢測(cè),點(diǎn)擊上方“3D視覺(jué)工坊”,選擇“星標(biāo)”干貨第一時(shí)間送達(dá)文章導(dǎo)讀本文是一篇從零開(kāi)始做車道線
發(fā)表于 07-20 06:24
基于Canny 法的紅外小目標(biāo)邊緣檢測(cè)方法
從紅外圖像的特點(diǎn)出發(fā),基于Canny算法進(jìn)行了目標(biāo)邊緣檢測(cè)。首先,對(duì)源圖像進(jìn)行小波分解和重構(gòu),對(duì)圖像進(jìn)行消噪,抑制噪聲對(duì)目標(biāo)提取的影響。然后對(duì)消噪后的圖像用Canny算法進(jìn)
發(fā)表于 05-27 15:02
?12次下載
基于Canny邊緣檢測(cè)算子的圖像檢索算法
針對(duì)依賴傳統(tǒng)Canny算子的基于邊緣的圖像檢索系統(tǒng)所存在的不足,提出一種基于Canny邊緣檢測(cè)的圖像檢索算法。使用改進(jìn)的
發(fā)表于 02-11 11:22
?28次下載
基于Canny算法的改進(jìn)Kirsch人臉邊緣檢測(cè)方法
針對(duì)Kirsch邊緣檢測(cè)算法的不足,提出了一種基于Canny算法改進(jìn)的Kirsch人臉邊緣檢測(cè)算法。該算法先對(duì)原始圖像用高斯濾波器平滑,計(jì)算
發(fā)表于 02-23 14:31
?10次下載
基于邊界特征的車道標(biāo)識(shí)線檢測(cè)方法
為了得到較理想的車道的標(biāo)線邊緣,利用車道的邊緣特征對(duì)車道圖像進(jìn)行二值化和形態(tài)學(xué)處理,對(duì)車道區(qū)域
發(fā)表于 01-13 09:48
?54次下載
一套車道線檢測(cè)系統(tǒng)
車道線檢測(cè)主要用于駕駛輔助和無(wú)人駕駛系統(tǒng),根據(jù)攝像頭數(shù)量,分為單目和雙目?jī)煞N檢測(cè)系統(tǒng)。出于實(shí)時(shí)性和經(jīng)濟(jì)性的考慮,一般采用單目檢測(cè),在對(duì)采集過(guò)
發(fā)表于 01-31 11:26
?1次下載
使用iVeia視覺(jué)套件進(jìn)行Canny邊緣檢測(cè)HLS IP
iVeia使用嵌入式世界2015中的iVeia視覺(jué)套件演示了Canny邊緣檢測(cè)HLS IP
python中用區(qū)域掩模實(shí)現(xiàn)車道線檢測(cè)
如下 我們發(fā)現(xiàn)符合閾值的像素既包括了車道線,也包含了其他非車道線部分。 顯然,一個(gè)成熟的自動(dòng)駕駛感知算法,是不可能使用這種方法的。僅僅依靠顏
python中用Canny邊緣檢測(cè)和霍夫變實(shí)現(xiàn)車道線檢測(cè)方法
評(píng)論