## 3 Proposed Methods
### Taillight Detection
#### 3.1.3 Candidate Region Clustering  
In this step, a candidate region clustering algorithm derived from the connected-component analysis method [29] is introduced for determining the region and pixel coordinates of each candidate taillight. To achieve this target, our idea is labeling each interesting point based on its preceding neighbor, beginning from the first point in the image. All points that have the same label are put into one list, which represents one candidate taillight region. The preceding neighbor of a point \(p(x,y)\) is defined as any interesting point that has one of the following pixel coordinates: \((x-1,y-1)\), \((x-1,y)\), \((x-1,y+1)\), or \((x,y-1)\). If \(p\) has at least one preceding neighbor point, a point \(q\), which has the minimum label among all preceding neighbors of \(p\), is picked, as illustrated in Figure 7. The point \(p\) is assigned into the region of \(q\), and the region of each remaining preceding neighbor of \(p\) is also merged into \(q\)'s region. Otherwise, \(p\) is assigned to a new region with a new label. The details of this algorithm are provided as Algorithm 1.  
Figure 6: Interesting point enhancement: (a) thresholding result; (b) enhancement result.  
Figure 7: Example of point labeling. The preceding neighbor has the minimum label of 1.  
Assuming that \(x\_min_{T}\), \(x\_max_{T}\), \(y\_min_{T}\), and \(y\_max_{T}\) are the minimal and maximal values of the horizontal and vertical coordinates for the point in taillight region \(T\), these values can be determined as  
\[x\_min_{T}=\textbf{min}\{x_{i}|(x_{i},y_{i})\in T\}, \tag{5}\]  
\[x\_max_{T}=\textbf{max}\{x_{i}|(x_{i},y_{i})\in T\}, \tag{6}\]  
\[y\_min_{T}=\textbf{min}\{y_{i}|(x_{i},y_{i})\in T\}, \tag{7}\]  
\[y\_max_{T}=\textbf{max}\{y_{i}|(x_{i},y_{i})\in T\}, \tag{8}\]  
where **min** and **max** functions aim to respectively get the minimum and maximum value from the set. The pixel coordinates (\(x_{T},y_{T}\)) of \(T\) are estimated based on these maximal and minimal values.  
\[\begin{cases}x_{T}=\dfrac{x\_min_{T}+x\_max_{T}}{2}\\ y_{T}=\dfrac{y\_min_{T}+y\_max_{T}}{2}\end{cases}, \tag{9}\]  
A minimum bounding box of taillight \(T\) is defined as the smallest rectangle in which all points of \(T\) lie. The top-left corner of the minimum bounding box has the pixel coordinates (\(x\_min_{T}\), \(y\_min_{T}\)), while the bottom-right corner has the pixel coordinates (\(x\_max_{T}\), \(y\_max_{T}\)). Therefore, its width \(w_{T}\) and height \(h_{T}\) can be calculated as  
\[\begin{cases}w_{T}=x\_max_{T}-x\_min_{T}\\ h_{T}=y\_max_{T}-y\_min_{T}\end{cases}, \tag{10}\]As illustrated in Figure 8, a minimum bounding box is presented as a green rectangle, which contains its candidate region. The centroid of this rectangle, which is illustrated with a yellow dot, is chosen as the pixel coordinates of this region. From there, each candidate region is represented by its corresponding minimum bounding box for being used in the further stages of the positioning process.  
Figure 9 shows a result of the generation phase, which is obtained after the candidate region clustering step. We can observe that many of the generated candidate regions are not taillights but just outliers. Therefore, they need to be reduced in the verification phase to obtain a better detection result.  
Figure 8: Example of a minimum bounding box.