# A Low Cost Vision-Based Road-Following System for Mobile Robots
## 4 Road Detection System
### Image Processing Module  
The image preprocessing process prepares the image in a state that makes it more effective to use in the algorithm. The raw image has undesirable characteristics that must be eliminated before use, for example, noise generated by the camera sensor, by the environment or by other factors. Another undesirable factor is the illumination that changes the properties of the image with different strength. First, the image is downsized to reduce the size and increase the processing speed. Then, a median filter is applied to reduce noise in the image, followed by white balance and RGB normalization to improve the image quality and reduce the illumination effects. The original input image is 1280 \(\times\) 960 pixels and is compressed to 640 \(\times\) 480 pixels. The downsizing process is done by a nearest-neighbor interpolation, which means that a weighted average of pixels is performed in the nearest neighborhood. The scaling factor during the downsizing process is 2. Thus, the value of pixel \((x,y)\) in the target image is set to the value of the pixel \((x_{o},y_{o})\) in the original image, \(x_{o}=2x\), \(y_{o}=2y\). The objective of the downsizing is to cut the size of the image and reduce time consumption complexity in the following process. In some cases, the focus of an algorithm is reduced to a small portion of the image because the other portion is meaningless. The image is reduced in size by taking account of the ROI. The ROI is extracted by cutting the image in the focus area and deleting the other part. This process enhances the time consumption, and by focusing only on the interest region, better results will be expected. The ROI is determined in an image according to vanishing points. In our system, the detection of vanishing point is based on literature [24], which presents a method for the automatic detection of vanishing points based on finding point alignments in a dual space, where converging lines in the image are mapped to aligned points. After the vanishing points are detected, the part of the image over it is eliminated, which corresponds to the skyline and horizon. Also, the bottom 1/5 of the image is excluded because that portion of the image corresponds to the frame of the robot; see Figure 3 as an example of image after ROI cropping. The ROI area can be adjusted depending on the location of the camera on the robot. The ROI parameters can be adjusted in configuration files. Figure 3: Image after ROI cropping. The image contains only the region of interest after ROI is extracted. However, the noise is not eliminated in the image. Noise is a common effect due to the camera sensor and the procedure to convert the analogue 3D world to an image. A median filter is applied to reduce the impulse noise. A blur filter with a two-dimensional window, each one of size \(7\times 7\) pixels, is applied. For every pixel, the output values will be the median of the whole image pixel. After the filter is applied, the abrupt peaks values will be eliminated. However, the illumination condition is changing all the time, since the robot is working in outdoor environments. The illumination condition is influenced by many factors, such as the intensity of sunlight that changes from time to time, or to the location of the camera related to sunlight that is not fixed; also, shadows can appear in the road, and so on. The white balance is adjusted and RGB normalization is performed to reduce the illumination effect. The white balance technique adjusts the intensities of colors taking into account the whole image. For each pixel in the image, the (\(R\), \(G\), \(B\)) value is calculated by using (1). \[R^{\prime}=\frac{Y_{avg}}{R_{avg}},G^{\prime}=\frac{Y_{avg}}{G_{avg}},B^{ \prime}=\frac{Y_{avg}}{B_{avg}} \tag{1}\]  
in which \(Y_{avg}\) is defined as \((R_{avg}+G_{avg}+B_{avg})/3\) and \(R_{avg}\), \(G_{avg}\), \(B_{avg}\) are the average of \(R\), \(G\), \(B\) channels.