# Navigation Path Extraction and Experimental Research of Pusher Robot Based on Binocular Vision
## 2 Materials and Methods
### Image Preprocessing
#### 2.5.1 Sky Removal  
During the working process of the robot, there were generally feed belts and dairy cow pens beside the road, and the background was generally the sky and the roof outside the dairy cow barn. After identifying the areas on both sides, the road and sky range in the middle could be obtained. Then, road feature information and navigation paths could be extracted by sky removal. Therefore, the image transformation should be utilized to remove the sky in the background element. OpenCV was used to read the RGB values of the sky area. The sum of squared deviations (SS) of the RGB values of the sky (252, 240, 200) and other elements were calculated through the threshold processing function, as a measure of the similarity between the current pixel and the background, as shown in Equation (13). \[\text{SS}\ =\ (p_{0}-SC_{0})^{2}+(p_{1}-SC_{1})^{2}+(p_{2}-SC_{2})^{2} \tag{13}\]  
where, \(p_{0}\), \(p_{1}\) and \(p_{2}\) were the G, B and R values of the other elements in the image, respectively; \(SC_{0}\), \(SC_{1}\) and \(SC_{2}\) were the G, B and R values of a point in the sky, respectively  
Combined with the actual environment of the cattle farm, the threshold was determined to be 9000 after many tests. The test results showed that more pixels were covered and a better processing result was obtained. Filling the sky color with black (0, 0, 0) eliminates unnecessary image factors, which was beneficial to subsequent image segmentation processing and reduced computational costs. For each GBR image pixel, the values of the \(B\), \(G\) and \(R\) channels were converted to the same value, and the grayscale effect was observed. As shown in Equation (14), in this study, the average value method was used to average the \(G\), \(B\), and \(R\) values of each pixel on the original image, replace the original pixels and convert the original image to a grayscale image. The processing effect is shown in Figure 10.  
\[B_{1}\ =\ R_{1}\ =\ G_{1}\ =\ \frac{(B+G+R)}{3}\ =\ Gray \tag{14}\]  
where, \(B\), \(G\) and \(R\) are the values of each component of the RGB image from which the sky was removed; Gray is the value to be replaced; and \(B_{1}\), \(G_{1}\) and \(R_{1}\) are the values of the replaced components. Figure 10: Image preprocessing effect. (**a**) Original RGB image; (**b**) sky-removed RGB image; (**c**) grayscale image. The K-means clustering is also often used for such problems. The K-means algorithm is also more widely used in practice due to its good scalability and low complexity. During the task of the sky removal of background elements, the number of clusters can be determined as 2. A total of 50 images were randomly selected from each of the RGB images acquired during the work outside and inside the barn and tested using the K-means algorithm. The average success rate of clustering by K-means was 79%, in which 47 of the 50 images outside the barn were successfully clustered, and 32 of the 50 images inside the barn were successfully clustered. The similarity measure between classes is calculated by the discrete sum of squares method, which is slow due to the need to calculate the inter-class distance in each clustering step; the K-means clustering algorithm is sensitive to the initial clustering center and cannot specify a more accurate initial clustering center, which easily falls into the local optimal solution in the face of complex situations and can easily remove the road elements by mistake. Considering the above situation, we used the following algorithm for the sky removal operation. The global threshold algorithm used the threshold segmentation method of threshold de-binarization on the entire image to segment the pixels from the image [28]. The RGB images inside and outside the barn were randomly selected for a segmentation test, and the maximum value in the threshold segmentation was 255. The key to the global threshold segmentation was to choose the specified value.