-
Notifications
You must be signed in to change notification settings - Fork 1
Hough lines
The final step is to use the Hough transform to find the mathematical expression for the lane lines.
The math behind the Hough transform is slightly more complicated than all the weighted average stuff we did above, but only barely.
Here’s the basic concept:
The equation for a line is y = mx + b, where m and b are constants that represent the slope of the line and the y-intercept of the line respectively.
Essentially, to use the Hough transform, we determine some 2-dimensional space of m’s and b’s. This space represents all the combinations of m’s and b’s we think could possible generate the best-fitting line for the lane lines. Then, we navigate through this space of m’s and b’s, and for each pair (m,b), we can determine an equation for a particular line of the form y = mx + b. At this point, we want to test this line, so we find all the pixels that lie on this line in the photo and ask them to vote if this is a good guess for the lane line or not. The pixel votes “yes” if it’s white (a.k.a part of an edge) and votes “no” if it’s black.
The (m,b) pair that gets the most votes (or in this case, the two pairs that get the most votes) are determined to be the two lane lines.
The Hough transform instead uses a polar coordinates- / trigonometric- style representation that uses rho and theta as the two parameters.
This distinction isn’t super important (for our understanding), since the space is still being parametrized in 2-dimensions, and the logic is exactly the same, but this trigonometric representation does help with the fact that we can’t express completely vertical lines with the y = mx + b equation.
So after this step image would look like: