# Grid Anchor Lane Detection Based on Attribute Correlation
## 3 Methods
### Calculation of the Grid Anchor Labels  
The grid anchor \(A^{s}\), which represents lane lines, is also the output of the prediction model. To compute the loss function, it is necessary to generate lane line label data \(T^{s}\) for the grid anchors. The process of obtaining label values for each anchor's attributes begins by determining the lane line segment within the anchor. Typically, lane line label data are represented as coordinate point sequences. For the kth lane line, this can be expressed as follows:  
\[Lane^{k}=\left\{\left(x_{1}^{k},y_{1}^{k}\right),\left(x_{2}^{k},y_{2}^{k} \right),\cdots,\left(x_{m}^{k},y_{m}^{k}\right),\cdots,\left(x_{l}^{k},y_{l}^ {k}\right)\right\} \tag{3}\]  
where \(\left(x_{m}^{k},y_{m}^{k}\right)\) denotes the mth coordinate point of the kth lane line (\(k\in\{1,\cdots,n\}\), \(m\in\{1,\cdots,l\}\)), and \(l\) represents the number of coordinate points in a single lane line.  
When the number of anchors covering the image is large, the area covered by each anchor becomes smaller, and the lane line within the anchor can be approximated as a line segment (as shown in Figure 4). Consequently, the lane line segment within an anchor can be represented by the intersection points between the lane line and the anchor's boundaries. The attribute values of each grid anchor are computed individually (Algorithm 1). During the computation, two adjacent coordinate points from each lane line are sequentially selected to form a lane line segment (Statements 2-9 in Algorithm 1). The intersection coordinates are then determined by this lane line segment and the four boundaries of the grid anchor. If an intersection point exists, the two adjacent points belong to the kth lane line, and the value of the kth channel in the instance attribute is set to 1 (Statement 6). Since all other channel values of this attribute are initialized to 0 (Statement 1), no further modification is required.  
```
1 Initialization:\(A^{s}_{c,i,j}\gets 0\,,\;c\in\{0,\ldots,n+5\}\)
2 forall\(k\in[1,n]\)do
3 forall\(m\in[1,l-1]\)do
4 Compute the intersection points between the lane line segment formed by \(\left(x^{k}_{m},y^{k}_{m}\right)\)and \(\left(x^{k}_{m+1},y^{k}_{m+1}\right)\)and the anchor boundaries.
5 if intersection points exist then
6 Record the intersection coordinates, and \(T^{s}_{k,i,j}=1,\;T^{s}_{n+5,j}=\frac{x^{k}_{m+1}-x^{k}_{m}}{y^{k}_{m+1}-y^{k}_ {m}}\).
7 endif
8 endfor
9 endfor
10 if the number of intersection points is 2 then
11 if\(x^{p1}_{i,j}=\frac{(i+1)W}{W_{s}}\)and \(x^{p1}_{i,j}=\frac{(i+1)W}{W_{s}}\)then
12 The anchor is classified as background, all attribute values are set to 0, and the program ends.
13 endif
14 The anchor is classified as lane lines, and the attribute values are calculated based on the two intersections.
15 endif
16 ifthe number of intersection points is 1 then
17 if\(y^{p}_{i,j}=\frac{(j+1)H}{H_{s}}\)then
18 The anchor is classified as background, all attribute values are set to 0, and the program ends.
19 endif
20 The anchor is classified as lane lines, and the attribute values are calculated based on the single intersection.
21 endif
```  
**Algorithm 1**The transformation process of label data from lane line coordinates to anchor attribute values.  
Figure 4 shows three types of intersections between lane lines and the anchor boundaries.