Detecting Color Features

As we all know, the best bike lanes are painted in green. The green paint will make the bike lane more smooth and conspicuous. Thus our first step is evaluating the bike lane color feature. When we read the image in OpenCV, images will be stored as a color matrix using RGB model. That is the matrix stored the RGB components value of the image. This is good for us because it makes it possible for us treat the image as numbers so that in the end we can build a function that returns a number. Our thought is to calculate how “green” is the bike lane image. The hard part in this process is how to define the bike lane green, since the bike lane green is a very specific color, in order to keep more features as we can, we should create a precise color range for the green color. In this step, we use image processing software to find the RGB components for the color and set lower and upper bound according to the RGB components. With lower and upper we can create a mask and do color filtering, in this step we will filter out colors out of our range, thus keep the green color only. Which means that the resulting image after filtering will have some components as 0, thus we can calculate the difference between original image and the resulting image. The more green kept, the more components kept and the higher the sum will be. This number is our color score.
Our steps can be conclude as :
  1. Convert image to HSV color model matrix.
  2. Create color bound for "bike lane green".
  3. Filter out colors that are not in the range.
  4. Calculate color score based on image color matrix after filtering.