## 4 Materials and Methods
### Comparing Segmentation Performance  
The performance of the MLP segmentation method was compared to the two ML-based segmentation methods and two well-known color-threshold methods: ExG (excess green) and ExGR (excess green-red). ExG is a simple color-index-based method that provides a clear distinction between soil and plant vegetation by increasing the contrast of the green part of the spectrum against the red and blue parts [56]. It operates on the bimodal distribution of pixels and is given by the expression ExG = \(2\times\mathrm{G}-\mathrm{R}-\mathrm{B}\), where R, G, and B are the pixel values of the red, green, and blue color channels, respectively. ExGR was introduced by [PERSON] et al. [57], where two color indices, ExG and excess red (ExR), were combined to reduce the residual background pixels, achieving a high segmentation accuracy. ExGR is expressed as ExG \(-\) (\(1.4\times\mathrm{R}-\mathrm{G}\)), where R and G are the mean values of the red and green channels, respectively, and ExG is the excess green index. Both ExG and ExGR indices were combined with automatic Otsu thresholding to segment the images.  
To evaluate the performance of the different methods, ten images each for glasshouse and field plants were randomly selected and segmented using all the five segmentation methods. The performance of all the methods was evaluated with reference images in which plant vegetations were manually segmented from the ten plants, using Adobe Photoshop Software (Adobe Inc., Maidenhead, UK). Figure 10 shows two examples of the test images and the manually segmented reference images for glasshouse and field conditions. Three quality factors, namely Qseg [7], Sr [58], and an error factor (Es) [59], expressed in Equations (3)-(5) were used to evaluate the quality of the segmentation methods.  
\[\mathrm{Qseg}=\frac{\sum_{\mathrm{x,y=0}}^{\mathrm{x,y=h,w}}(\mathrm{S(p)x,y \cap R(p)x,y})}{\sum_{\mathrm{x,y=0}}^{\mathrm{x,y=h,w}}(\mathrm{S(p)x,y\cup R (p)x,y})} \tag{3}\]  
\[\mathrm{Sr}=\frac{\sum_{\mathrm{x,y=0}}^{\mathrm{x,y=h,w}}(\mathrm{S(p)x,y \cap R(p)x,y})}{\sum_{\mathrm{x,y=0}}^{\mathrm{x,y=h,w}}(\mathrm{R(p)x,y})} \tag{4}\]  
\[\mathrm{Es}=\frac{\sum_{\mathrm{x,y=0}}^{\mathrm{x,y=h,w}}(\mathrm{S(p)x,y \cap R(\mathrm{!p})x,y})}{\sum_{\mathrm{x,y=0}}^{\mathrm{x,y=h,w}}(\mathrm{R(p) x,y})} \tag{5}\]  
where S is the segmented plant, (S(p) = 255), or background pixels (S(p) = 0); R is the reference image; indices h and w are the height and width of the image, respectively; and x and y are the pixels' coordinates. The segmentation accuracy is based on the logical operations logical or (\(\cup\)), logical n (\(\tau\)), and logical not (!). It is compared on a pixel-by-pixel basis of the segmented image (S) to the reference image (R).  
Figure 9: Feature-selection process involving correlation analysis and feature ranking based on importance score. (**a**) is the heatmap of all extracted features and (**b**) is a plot of feature importance for feature selection. Abbreviations: RGB (R = red, G = green and B = blue channels); HSV (H = hue, S = saturation, and V = value); ybr (y = luma, b = blue component, and r = red component); Lab (L = lightness, and a and b = chromaticity); YUV (Y = luma or brightness, U = blue projection, and V = red projection); Lux (L = luminance, u = blue axis, and v = red axis); hls (h = hue, l = lightness, and s = saturation); and XYZ (X and Z = spectral weighting curves, and Y = luminance).  
Qseg measures the consistency on a pixel-by-pixel basis between the S and R images and ranges between 0 and 1, where 1 is perfect segmentation and vice versa. Similarly, Sr measures the consistency of plant pixels between image regions [59]. The Es measures the section of misclassified plant pixels in relation to the true total plant pixels selected from dataset.