Lane Identification using an Adaptive Filter
Ghosts from the Bronze Age of computer vision
Many moons ago, we used to dream about real time processing of images. I worked hard to make code to do this for lane line recognition for an autonomous robot. One of the most delightful filters I designed was named (by me) the Low Filter. I found this to be a good way to remove noise, and I will summarize it below.
Image Preprocessing: Obstacle Removal
First, I noticed orange barrels look similar to white lines, so I got rid of them with some simple detection based on how I expect them to look. It was robust enough for competition at the time, circa 2006.
Low Filter: Adaptive Statistical Filter
I noticed the intensity of the lines are statistically greater than the surrounding grass and other noise. An adaptive statistical filter was developed based on this observation, called the low filter. The purpose of the low filter is to drop out pixels that are considered too low in value based on statistical information.
The low filter works row by row on each color plane separately. Pixels are deleted that are less than a threshold determined by a weighted combination of the local mean and standard deviation. Pixels above the threshold are unaltered. This filter is applied independently on all three color planes since the lines are assumed to be white or close to white in intensity.
The threshold used is defined below for each row of the image, and this threshold is varying based on row.
Threshold(row) = mean(row) + A * std(row), where A is a user defined constant.
The low filter takes out the majority of pixels considered to be noise in rows with lines, while at the same time it does not increase the noise in rows without lines as seen below.
Then I applied a 9 x 16 localized statistical area filter. This filter calculates the mean of each area and deletes those with a mean below a user-defined threshold. The results can be seen below where some noise in the middle is removed.
Next, a threshold for the low-filtered image was found using a reverse cumulative histogram. This histogram allows the program to find how many pixels would be left in an image at any given threshold according to the number of bins used. The histogram is calculated in the normal manner, with the exception of leaving out bin 0 (due to the large number of black pixels). Then a cumulative sum is calculated. Lastly, this cumulative sum is reversed to represent the number of pixels an image would have if a threshold was taken at a particular histogram bin value.
This allowed a threshold to be set based on allowing only a certain number of pixels to be left in the image. This number was based on the knowledge of the line thickness in each picture (which was approximately three pixels for the reduced image being used). For example, the assumption was if there were two lines in 45 rows, then 270 pixels would need to be retained (3x45x2). Below presents the test image after being thresholded.
I have found this filter interesting in other areas over the years, and most recently coffee grounds. So I put together this short explanation for anyone with a deeper interest in how I apply it to coffee grounds particle analysis.
Paper Citation and Abstract
McKeon, Robert & Paulik, Mark & Krishnan, Mohan. (2006). Lane Identification and Path Planning for Autonomous Mobile Robots. 6384. 10.1117/12.686278:
“This work has been performed in conjunction with the University of Detroit Mercy’s ECE Department autonomous vehicle entry in the 2006 Intelligent Ground Vehicle Competition (www.igvc.org). The IGVC challenges engineering students to design autonomous vehicles and compete in a variety of unmanned mobility competitions.
“The course to be traversed in the competition consists of a lane demarcated by painted lines on grass with the possibility of one of the two lines being deliberately left out over segments of the course. The course also consists of other challenging artifacts such as sandpits, ramps, potholes, and colored tarps that alter the color composition of scenes, and obstacles set up using orange and white construction barrels.
“This paper describes a composite lane edge detection approach that uses three algorithms to implement noise filters enabling increased removal of noise prior to the application of image thresholding.
“The first algorithm uses a row-adaptive statistical filter to establish an intensity floor followed by a global threshold based on a reverse cumulative intensity histogram and a priori knowledge about lane thickness and separation.
“The second method first improves the contrast of the image by implementing an arithmetic combination of the blue plane (RGB format) and a modified saturation plane (HSI format). A global threshold is then applied based on the mean of the intensity image and a user-defined offset.
“The third method applies the horizontal component of the Sobel mask to a modified gray scale of the image, followed by a thresholding method similar to the one used in the second method.
“The Hough transform is applied to each of the resulting binary images to select the most probable line candidates. Finally, a heuristics-based confidence interval is determined, and the results sent on to a separate fuzzy polar-based navigation algorithm, which fuses the image data with that produced by a laser scanner (for obstacle detection).”
If you like, follow me on Twitter and YouTube where I post videos of espresso shots on different machines and espresso related stuff. You can also find me on LinkedIn. You can also follow me on Medium.
Further readings of mine:
A Collection of Espresso Articles
Overdressed for an Interview at Apple
The Duality of Good Culture and Good Management
Magical experience on my wrist
Face Recognition: 3D Face Recognition from Infancy to Product