## 4 Taillight Detection and Light Signal Identification Based on Image Processing
### Taillight Signal Identification
#### 4.3.2 Brake Light Identification Method  
Traditionally, the methods of color threshold segmentation or shape matching are usually used to determine the taillight state. Although these methods can roughly detect the outline and area of the taillight, they cannot judge the current taillight lighting state. In this paper, by analyzing and comparing the on and off states of the brake light, and by observing, we find that when the brake light is on, the inner layer is yellowish because of its stronger brightness, while the outer layer is red because of its weaker brightness. When the brake light is off, its color is more uniformly red. To summarize, the taillight status can be monitored according to brightness and color information. Therefore, the histogram features of the original taillight area image are analyzed. Figure 13 shows the image when the taillight is off. Figure 13b shows the image when the taillight is turned on.  
The histogram of the lighting state statistics of the taillights is shown in Figure 14a. The histogram of the closing status of the tail light is shown in Figure 14b. There are obvious differences between the taillight distributions in the two states.  
The on status of the brake light is a continuous lighting process. The 5-frame taillight image with an interval of 1 s is randomly selected, as shown in Figure 15a-e. We can see clearly the on and off process of the brake lights. In a period of 5 s, we calculate the histogram features of the left and right taillights in the image and those in the background image. If the taillights on the two sides satisfy the conditions of continuous lighting of the histogram characteristic parameters at the same time in the same time interval, the brake lights can be recognized as lit.  
Figure 14: Gray-level histograms. (**a**) Taillight histogram in the lit state; (**b**) Taillight histogram in unlit state.  
Figure 13: Vehicle taillight area image. (**a**) Unlit left taillight image; (**b**) Illuminated left taillight image.  
If we segment the left taillight image in the five frames in Figure 15, as shown in Figure 16a-e, and calculate the statistics of the histogram characteristic parameters, as shown in Table 6. Within 5 s after the background frame is determined, if the histogram characteristic parameters of the vehicle taillight area images are larger than that of the background frames in two continuous frames or more, the taillights of the preceding vehicle are recognized as lit.  
According to the five images extracted at equal intervals within 5 s, the histogram feature parameter list mentioned above is obtained, and obvious changes can be noted. The first two points are the parameters corresponding to the two frames when the light is off, and the last three points are the parameters corresponding to the three frames when the light is on. By analyzing the histogram feature parameters, we can know that the average value, entropy, and variance of the taillights when they are not lit are less than the values when the taillights are lit. The energy when the taillights are lit is greater than the energy when the taillights are not lit. Whether the tail light is on can be determined by setting a dynamic threshold.