## 4 Materials and Methods
### Regression for SPAD Values Prediction  
SPAD readings are used to determine the greenness of plants, and this is highly correlated with their nitrogen content [53]. In this study, the plant chlorophyll index was measured using a SPAD meter (SPAD-502, Konica Minolta Sensing, Osaka, Japan) at different growth stages of wheat plants. For the field experiment, three readings were taken from five randomly selected wheat leaves within each experimental plot. SPAD readings were taken on the first, second, and third sectors of each fully expanded leaf. The final reading for each plot was the average of the fifteen measured SPAD values. In the glasshouse experiments, SPAD readings were taken concurrently with the image acquisition from cowpea leaves. Three readings were taken from fully expanded leaves located at the top, middle, and bottom part of each plant in each pot. The final plant SPAD values were calculated as the average of these readings.  
The accurate segmentation of plant images is crucial for the precise and non-destructive measurement of plant traits. Poorly segmented images can result in higher levels of pixel misclassifications during segmentation, which may ultimately affect the analysis of plant traits. To evaluate the performance of the segmentation methods used in this study, we implemented a gradient-boosting decision trees (GBRTs) algorithm called eXtreme Gradient Boosting (XGBoost) as a regression model to predict SPAD readings of plants using the segmented image data. XGBoost is an ensemble machine learning algorithm for classification or regression predictive modeling problems [54]. It is computationally efficient and highly effective for structured datasets on classification and regression predictive modeling problems [54]. XGBoost builds regression trees one by one such that the subsequent tree is trained from the residuals of the previous tree. That is, the new model (tree) improves on its performance by correcting errors made by the previously trained model (tree) [55]. Tobuild an XGBoost model, an initial tree (model) X\({}_{0}\) defined to predict a target variable y is associated with a residual (y-X\({}_{0}\)). A new model, X\({}_{1}\), is fit to the residuals from the previous model. In the next step, the previous model is combined with the new model X\({}_{1}\) to produce a boosted version of X\({}_{0}\). In this case, the mean squared error from X\({}_{1}\) will be lower than that from X\({}_{0}\). To improve the performance of X\({}_{1}\), the model could be boosted by modeling after the residuals of X\({}_{1}\) to create a new model X\({}_{2}\). This process can be repeated until the residuals have been reduced as much as possible. In this work, the XGBoost implementation uses a histogram-based split finding method, which groups features into discrete bins to improve the training speed and reduce memory usage. The hyperparameters of the XGBoost, including n_estimators (the number of trees used in the model), subsample size used to train each tree, maximum depth (max-depth) of trees, and learning rate(\(\alpha\))-(indicating how fast the model learns), were fine-tuned to optimize the performance of the models.  
The segmentation algorithms and extraction of plant traits were performed in the python 3.7 environment (python software foundation, http:www.python.org/, accessed on 1 August 2022) with scikit-learn, opencv2, and SciPy packages. The entire machine learning process was carried out on an intel core computer with a 2 GHz processor, 8.00 GB of RAM, and MS Windows 10 operating system.