## 2 Materials and Methods
### Color Space Analysis  
The necessary pre-step for defect identification is to segment the two parts of the seedling accurately: the substrate and the seedlings. Image segmentation methods include threshold  
Figure 1: Image acquisition. (**A**) Image acquisition device; (**B**) experimental site.  
segmentation [23; 24], edge detection segmentation [25; 26], clustering algorithm segmentation [27; 28], mathematical morphology based segmentation, and semantic segmentation [29; 30]. In the images collected on the conveyor belt, there were interference factors such as reflection, shadow, and substrate debris and the morphological differences of cabbage seedlings were large. Edge detection and clustering algorithms were not applicable. Semantic segmentation based on a full convolutional neural network can be applied to the extraction of complex targets; however, sample labeling is too cumbersome, and the algorithm is not real time. The threshold segmentation algorithm is a segmentation algorithm suitable for fixed backgrounds and known foreground target colors. The algorithm is stable and real time. The mathematical morphology algorithm is a supplement to the image segmentation algorithm, mainly used to remove noise points. Therefore, the combination of threshold segmentation and the mathematical morphology algorithm was selected to segment the matrix blocks and seedlings.  
The implementation of the threshold segmentation algorithm depends on the appropriate color space. In this article, a grayscale histogram was used to determine the color space. Image color spaces include RGB, HSV, YIQ, etc. (see Figure 2). The color histogram peak feature analysis method was used to determine the image segmentation color space: Ten images of cabbage seedlings were randomly selected and converted into the RGB, HSV, and YIQ spaces respectively. Then, each color space gray histogram was accumulated (see Figure 3). As is shown in Figure 2(A1-A3) and Figure 3A, three channels of the RGB space showed peak characteristics, wherein the green channel peak characteristics of the G green channel were the most stable and the peak region corresponded to the substrate region. As is shown in Figure 2(B1-B3) and Figure 3B, among the three channels of the HSV space, the S channel showed peak characteristics, but the peak area corresponded to the background area. As is shown in Figure 2(C1-C3) and Figure 3C, neither of the three channels in the YIQ space showed a peak corresponding to the substrate region. Therefore, the RGB space G channel was selected as the color space for substrate segmentation.  
Figure 3: _Cont_.  
Figure 2: Experimental pictures in different color spaces. **(I)** the original image; **(A1–A3)** the R, G, and B channel images in the RGB color space; **(B1–B3)** the H, S, and V channel images in the HSV color space; **(C1–C3)** the Y, L, and Q channel images in the YIQ color space.  
The excess green color space (see Equation (1)) is commonly used in green target segmentation. The color component of the seedling area in the sample image was significantly higher than other areas (see Figures 4 and 5), and the threshold segmentation method could realize the segmentation of seedling regions. Therefore, the excess green color space was used to segment the seedling area.  
\[\text{ExG}=\left\{\begin{array}{cc}0&2G-B-R<0\\ 2G-B-R&0<2G-B-R<255\\ 255&2G-B-R>255\end{array}\right.. \tag{1}\]  
where \(R\), \(G\), and \(B\) are the pixel values in the RGB color space. ExG is the pixel value in the excess green color space.  
Figure 4: Experimental pictures in the excess green color space. (**I**) The original image. (**A**) The image in the excess green color space.  
Figure 3: Gray histogram of the cabbage seedling image. (**A**) RGB color space gray histogram; (**B**) HSV color space gray histogram; (**C**) YIQ color space gray histogram.