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.
Our objective is to convert the image displayed above into something which looks like below.
Since our objective is to convert all the pixels except lanes to black, We’ll solve this problem using the following steps:
- Define thresholds for red, green, and blue values
- Get the copy of the original image and convert the image into an array
- 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 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.
As you can see starting from [200, 200, 200] the lane lines seem to appear clearly.