How to perform thresholding
While for a human it is easy to follow a lane, for a computer, this is not something that is so simple. One problem is that an image of the road has too much information. We need to simplify it, selecting only the parts of the image that we are interested in. We will only analyze the part of the image with the lane, but we also need to separate the lane from the rest of the image, for example, using color selection. After all, the road is typically black or dark, and lanes are usually white or yellow.
In the next sections, we will analyze different color spaces, to see which one is most useful for thresholding.
How thresholding works on different color spaces
From a practical point of view, a color space is a way to decompose the colors of an image. You are most likely comfortable with RGB, but there are others.
OpenCV supports several color spaces, and as part of this pipeline, we need to choose the two best channels from a variety of color...