交通车道线中的阴影移除

时间:2018-02-07 09:47:48

标签: python opencv image-processing background-subtraction shadow-removal

我正在研究车道线检测。我目前的工作策略是:

  1. 定义一个感兴趣的区域,其中泳道线可以是

  2. 使图像变形以获得鸟瞰图

  3. 将图像转换为YUV色彩空间

  4. 规范化Y频道

  5. 拟合二阶多项式和滑动窗口方法

  6. 每件事都很好但有阴影的地方算法不起作用。 我尝试过自适应阈值处理,otssu阈值处理但没有成功。

    没有阴影的源图像: enter image description here

    没有阴影的已处理源图像:

    enter image description here

    带影子的源图片:

    enter image description here

    带阴影的已处理源图片:

    enter image description here

    在第二张图像中,可以看到未检测到阴影区域。实际上阴影会使图像值下降,所以我试图使用低于前一个图像的新值来阈值图像,这里可以找到新的图像:

    enter image description here

    这种技术不起作用,因为它带来了很多噪音

    目前我正在尝试背景减法和阴影去除技术,但它不起作用。从过去的2个星期开始,我对这个问题感到震惊。 真的很感激任何帮助......

    import cv2
    import matplotlib.pyplot as plt
    import numpy as np 
    from helper_functions import undistort, threshholding, unwarp,sliding_window_polyfit
    from helper_functions import polyfit_using_prev_fit,calc_curv_rad_and_center_dist
    from Lane_Lines_Finding import RoI
    img = cv2.imread('./test_images/new_test.jpg')
    new =undistort(img)
    new = cv2.cvtColor(new, cv2.COLOR_RGB2BGR)
    #new = threshholding(new)
    h,w = new.shape[:2]
    # define source and destination points for transform
    imshape = img.shape
    vertices = np.array([[
                          (257,670),
                          (590, 446),
                          (722, 440),
                          (1150,650)
                          ]], 
                          dtype=np.int32)  
    p1 = (170,670)
    p2 = (472, 475)
    p3 = (745, 466)
    p4 = (1050,650)
    
    vertices = np.array([[p1,
                          p2,
                          p3,
                          p4
                          ]], 
                          dtype=np.int32)  
    masked_edges = RoI(new, vertices)
    #masked_edges = cv2.cvtColor(masked_edges, cv2.COLOR_RGB2BGR)
    
    
    src = np.float32([(575,464),
                      (707,464), 
                      (258,682), 
                      (1049,682)])
    dst = np.float32([(450,0),
                      (w-450,0),
                      (450,h),
                      (w-450,h)])
    warp_img, M, Minv = unwarp(masked_edges, src, dst)
    warp_img = increase_brightness_img(warp_img)
    warp_img = contrast_img(warp_img)
    YUV = cv2.cvtColor(warp_img, cv2.COLOR_RGB2YUV)
    Y,U,V = cv2.split(YUV)
    Y_equalized= cv2.equalizeHist(Y)
    YUV = cv2.merge((Y,U,V))
    thresh_min = 253
    thresh_max = 255
    binary = np.zeros_like(Y)
    binary[(Y_equalized>= thresh_min) & (Y_equalized <= thresh_max)] = 1
    
    kernel_opening= np.ones((3,3),np.uint8)
    opening = cv2.morphologyEx(binary, cv2.MORPH_OPEN, kernel_opening)
    kernel= np.ones((7,7),np.uint8)
    dilation = cv2.dilate(opening,kernel,iterations = 3)
    

1 个答案:

答案 0 :(得分:1)

阴影去除在图像处理中不是一件容易的事,你可以尝试很多方法。但请查看本文第3部分http://lxu.me/mypapers/XuL_ShadowRemoval.pdf。看起来他们有一个不错的算法,并且写得很好而且简洁。