## 2 Materials and Methods
### Segmentation Threshold Calculated by the maxIOU Algorithm  
This section analyzes the algorithm for image segmentation threshold calculation. Traditional image segmentation threshold calculation methods, such as the Otsu method and the gray histogram method, are applicable to double peak image segmentation. Although the G channel of the sample image had double peaks, the double peaks contained more background pixel interference, and the segmentation threshold obtained by the Otsu method was not accurate enough (see Figure 3A). The valley region between the double peaks of the image G channel was too wide (see Figure 3A), and the gray histogram method also had difficult searching for a suitable segmentation threshold. The seedling area did not form double peaks in the super green color space (Figure 5) and was not suitable for the Otsu method and the gray histogram method. In this article, the maxIOU algorithm is proposed (Equation (2)), which could be used to calculate the image segmentation threshold with an inconspicuous double peak feature. The maxIOU method drew on the idea of the Otsu method enumerating all segmentation threshold comparison effects, but made two important improvements:  
(1) Inter-class variance was replaced by intersection over union (IOU) as a function for evaluating the image segmentation effect. (2) The threshold corresponding to the maximum average IOU of the training set image was used as the image segmentation threshold instead of the Otsu adaptive threshold. \[\text{threshold}=i\text{ if IOU}_{\text{i}}=\text{max(IOU)} \tag{2}\]  
where IOU is the intersection over union of algorithm segmented image and labeled image; \(i\) is the color component between 0 and 255.  
maxIOU was applied to segment the substrate and seedling region. Firstly, several images were selected as Training Set 1 from the dataset. The substrate region and the seedling region of the image were manually segmented and labeled as the ground truth. Secondly, all training set images in the G channel and excel green color space were segmented with a 0-255 threshold and were repaired by morphological methods. IOU was calculated with the algorithm segment result and ground truth. Finally, the average value of the IOU corresponding to each threshold was calculated, and the maximum average IOU corresponding threshold was selected as the image segmentation threshold. IOU is a standard for measuring the accuracy of detecting corresponding objects in a specific dataset. The IOU is a number between 0 and 1, and a larger IOU indicates a better segmentation result. The IOU calculation method is shown in Figure 6 and Equation (3). Figure 5: Gray histogram of the cabbage seedling image in the excess green color space. C1 is the artificial labeled image segmentation result, which is called the ground truth. C2 is the image segmentation result by the algorithm. \(S_{i}\) is the shadow in Figure 6A, which is the intersection of C1 and C2. \(S_{u}\) is the shadow in Figure 6B, which is the union of C1 and C2. \[\text{IOU}=\frac{S_{i}}{S_{u}} \tag{3}\]  
The original images and the artificially labeled substrate area and seedling area images are shown in Figure 7 and the corresponding G channel, and excess green color space gray histogram are shown in Figure 8. As is shown in Figure 8(A3,B3), the gray histogram of the artificially labeled substrate region had a peak coincidence with the gray histogram of the complete image in the G channel, and the overlap interval was [0, selected threshold]. Therefore, it was feasible to use the threshold segmentation method to achieve the segmentation of the substrate region and the background region. As is shown in Figure 8(C3,D3), the grayscale histogram of the artificially labeled seedling region had a higher degree of coincidence with the higher color component of the grayscale histogram of the complete image. Therefore, it was feasible to use the threshold segmentation method to realize the segmentation of the seedling area and background area.