Figure 2. R channel grayscale map, G channel grayscale map, and differential grayscale map
(a) (b) (c)
Figure 3. R Channel 3D Gray Distribution Map, G Channel 3D Gray Distribution Map, Difference 3D Gray Distribution Map
Compared with Figure 3b, Figure 3a shows that the distribution of background pixel values in the R and G channels is roughly the same, but there are small differences. For example, the hanging hole red paint in Figure 3b is significantly darker in brightness than in 3a. When the G channel is subtracted from the R channel, the result in this area is negative. To ensure that image details are not lost, the absolute value of the difference is usually taken as the result and stored in the corresponding pixel coordinates. However, based on prior information, it is known that in the RGB color model, there are multiple mixed colors in an image. The R component in the red, brown, and yellow series colors is usually greater than the G component. This does not highlight the gray level difference in the area to be segmented, which can cause the gray level peak of the interfering pixel area to be similar to the target hanger, and even the average gray level value of the interfering pixel area to be higher than the target hanger, Although retaining more edge information in the image, it also introduces a large amount of interference.
The reason why is not used in this article is that we do not want to construct the grayscale difference too clearly. When there are dark blue or green areas in the background, the constructed grayscale difference formula enlarges the background clutter, resulting in the problem of image oversegmentation.
This article adopts the following formula to construct a differential grayscale image:

1.3 Image segmentation and morphological processing

This article uses the Otsu algorithm to perform threshold segmentation on the constructed differential grayscale image, completing the separation of crane grab boom and background. The Otsu algorithm solves a binary classification problem, which satisfies the requirement of maximum inter class variance and minimum intra class variance. The Otsu algorithm is more suitable for grayscale histograms with bimodal features. Namely, construct a grayscale difference map to meet the bimodal features as much as possible. If the absolute value of the difference is taken to construct a grayscale image, as shown in Figure 4a.