Self Driving Cars - White Lane lines identification with RGB thresholds

White Lane lines identification with RGB thresholds

Every color has RGB values.

For example, RGB values of

white = [255, 255, 255]
black = [0, 0, 0]

So when you have a picture of road and your task is to identify the lanes on the road, its easy to identify the lanes based on the color.

For the image used in this blog post, we can see that the lanes are in white color.

Image of Road with lane lines

Objective:

Our objective is to convert the image displayed above into something which looks like below.

Image of Road with lane lines

Solution Breakup:

Since our objective is to convert all the pixels except lanes to black, We’ll solve this problem using the following steps:

  1. Define thresholds for red, green, and blue values
  2. Get the copy of the original image and convert the image into an array
  3. Replace all the values of the image which are less than the thresholds(RGB defined in step 1) to 0 (remember 0 for black?)

Code:

Code for the above steps is available at github

I tried several RGB thresholds in multiples of 10 to highlight the lane lines. On the top of each image, I displayed the RGB thresholds that I used to highlight the lane lines and black out the rest of the image.

Result:

As you can see starting from [200, 200, 200] the lane lines seem to appear clearly.

Image of Road with lane lines tried with multiple RGB thresholds

Reference:

Related