# A Low Cost Vision-Based Road-Following System for Mobile Robots
## 4 Road Detection System
### Color-Based Road Detector  
The main features that are used to achieve a proper segmentation of the road image are the Hue and Saturation channels of the HSV color space. It has been shown that the Hue value is insensitive to shadows and water areas, which often cover parts of a road. The road color is extracted from each frame and used to classify each pixel. To extract the road color model, we assume that the road is in front of the camera. A small road area is extracted and it is transformed from RGB to HSV color space. The road window is located in the middle bottom of the image and has a size of 50 \(\times\) 50 pixels. The middle bottom of the image is assumed to be road pixels; see Figure 4.  
The segmentation of an image into an area associated with the road and into a non-road area is a rather crucial step. A mean-shift algorithm keeps track of the color model and establishes the segmentation criteria. The current prototype implements a road color model that is extracted frame  
Figure 4: Road window located in the middle bottom of size 50 \(\times\) 50 pixels. by frame. This adaptation makes it more reliable and robust against changes in illumination or color. This adaptation is advantageous because avoids the requirement of prior knowledge of the road and allows road detection under different environmental circumstances; however, a disadvantage is that the wrong road model extraction would produce false road detection. To avoid false road detection, we keep track of road color-histograms. The color model is adapted considering previous color models. The mean-shift tracking algorithm is an iterative scheme based on comparing the histogram of the road in the current image frame and histogram of the road color in previous image frames. The color model is updated by using (3). \[CM_{t}=(1-\alpha)CM_{t-1}+\alpha CF \tag{3}\]  
in which \(CM_{t-1}\) is the previous road color model, \(CF\) is the road color model of the actual frame and \(\alpha\) is 0.2 as a weight. Therefore, the proposed road color model is slow to adapt to a new road surface. A remembering process is applied in the sense that the contribution of a specific frame decreases exponentially the further it lies in the past. The Manhattan distance classifies every pixel into a road or non-road area. Furthermore, the segmentation is enhanced with a hysteresis threshold that filters out some of the misjudgments. To reduce the computation complexity, not all pixels are used in the segmentation. Instead, pixels in non-consecutive rows and non-consecutive columns are selected. The distance of a pixel to the road model is evaluated by using (4). \[Dist(i,j)=\frac{|H(i,j)-\overline{q}_{Hue}|+|S(i,j)-\overline{q}_{Sat}|}{2} \tag{4}\]  
in which \(i\) and \(j\) are the pixels coordinates, \(H(i,j)\), \(S(i,j)\) are the Hue and Saturation values, respectively, and \(\overline{q}_{Hue}\), \(\overline{q}_{Sat}\) are the mean values of the road model in the Hue and Saturation channels. The segmentation in the road and a non-road area is naturally affected by noise. A certain number of pixels will be misclassified; this is due to natural phenomena such as shadows, water areas, road texture, and obstacles. To reduce the noise, morphological filters (dilatation and erosion) are applied. The dilatation technique is used to fill up small noise holes, and erosion is used to eliminate disconnected line segments. The size of dilation or erosion kernel window is 3 \(\times\) 3 pixels. In the case of multi-channel images, each channel is processed independently. To select the proper road borders, a rather trivial but effective heuristic technique is performed assuming that the road has parallel lines. With these procedures, obstacles and water areas on the road can be eliminated. This assumption states that the road width should decrease gradually from bottom to top due the perspective projection of the camera, and the middle line point of the road would not change suddenly because the road in the real world is continuous.