# Images Segmentation Based on Cutting the Graph into Communities
## 5 Applying to a Road Image  
We used our segmentation algorithm to determine the width of the road from its photo. This problem is relevant for automatic road inventory systems. The camera was mounted on a mobile laboratory. The camera photographed the road through the windshield. The problem is determining the width of the road from this photo of it. The camera parameters and its placement were known. Calculating the width of a road involves five steps. The road segment is highlighted in the first phase. The boundary of the road segment is defined in the second step. The left and right edge pixels of the road are determined in the third step. The road boundaries are  
Figure 4: Examples of segment highlighting in different images: (**a**) source image, (**b**) the result of the algorithm. approximated by straight lines in the fourth step. The width of the road is calculated from the line equations in the fifth step. Our algorithm was used to highlight a segment of the road. The correct calculation of the segment depends on the selection of the start point. We used an approximate model to image the road in the photo. The image includes four areas: (1) road, (2) sky, (3) objects to the left of the road, and (4) objects to the right of the road. The general model of the road image is shown in Figure 5a. We considered the case of a direct road section outside intersections. This assumption was justified. The camera operator independently selected the shooting moment. The road can go up or down the slope. The position of the chamber can be shifted from the center to the edge of the road. These factors resulted in the displacement of points A, B, C and D in the road image (Figure 5b). Our algorithm highlights segment 1. The image dimensions are \(N\times M\). The point with coordinates \((N/2,M)\) belongs to the road segment. The coordinates of the point were calculated from the upper left corner. However, this is a bad candidate for the starting point of the segment based on the computer experiment results. Road markings are present on real roads. This point is often located on the road marking line. We used the starting point with coordinates \((0.53N,\ 0.8M)\). Upward displacement is necessary to ignore the image of the windshield bottom. Solid dividing lines are an insurmountable obstacle to the algorithm. Only one lane was highlighted by the algorithm in this case. The algorithm calculated two segments in this case. The starting point of the second segment has coordinates \((0.47,\ 0.8M)\). The road segment is equal to the combination of the two segments. The two segments match when there is no solid dividing line. The option to manually select an additional segment start point was provided for complex road images with a large number of layout lines. The segment boundary is defined in the second step. The border has a thickness of one pixel. Boundary pixels are located in the segment. The pixel neighboring the top is located outside the segment. This condition uniquely defines boundary pixels. Examples of highlighting a road segment and its boundaries are shown in Figure 6.  
The road edge pixels were highlighted in the third step. The segment boundary was not a straight line for several reasons. Interference includes objects at the edge of the road, the presence of cars and other objects on the road, such as lighting features. The algorithm highlights a section of the minimally distorted edge of the road. Points A and D were calculated as the leftmost and rightmost points of the road outline. Contour areas in a width \(0.2N\) were treated as images of the edge of the road. Examples of road outline and road edge images are shown in Figure 7.  
Figure 5: Schematic model of the road image: (**a**) direct image of the road, (**b**) image of the road with displacement. The edges of the road are approximated by straight lines. \[y=ax+b. \tag{9}\]  
The least squares method is used to calculate coefficients \(a\) and \(b\). The quadratic error function \(R\) is calculated for road edge points.