# Rapid Detection of Key Phenotypic Parameters in Wheat Grains Using Linear Array Camera
## 2 Materials and Methods
### Research on Image Processing Methods
#### 2.3.2 Research on the Extraction Method for Phenotypic Parameters  
The phenotypic parameters of wheat grain are important reference indicators reflecting the quality and morphological characteristics. The original images of wheat grains are obtained through the image acquisition device built in this study. Based on the Halcon image processing software, a method for extracting the wheat grain phenotypic parameters is designed. Firstly, the characteristic regions of the wheat grains are extracted through the preprocessing method designed in the previous section, and a wheat grain mask is obtained, as shown in the final processing method depicted in Figure 11. Secondly, since wheat grains are approximately elliptical when obtaining the pixel values of their phenotypic parameters, the values of, for example, grain length and grain width can be obtained through a minimum circumscribed circle and a minimum circumscribed rectangle. Then, the true values of the parameters can be obtained through numerical conversion in the camera calibration section. A schematic diagram of a wheat grain is shown in Figure 12.  
Figure 12: Schematic diagram of a wheat grain. On this basis, the bud points are located and determined. First, it is necessary to determine the coordinate position of the center point of the seed in the image. The seed contour is obtained through the preprocessing method. The position of the center point of the seed circle is determined according to the minimum circumscribed circle, which is the geometric center of the seed. Then, the size of the seed is determined through the best-fitting ellipse, which is subsequently used to calculate the direction and positioning of the bud points, as shown in Figure 12. The calculation formula based on the fitting ellipse is as follows:  
\[r_{1}=\sqrt{2\bigg{(}\mu_{2,0}+\mu_{0,2}+\sqrt{\left(\mu_{2,0}-\mu_{0,2} \right)^{2}+4\mu_{1,1}^{2}}\bigg{)}}, \tag{5}\]  
\[r_{2}=\sqrt{2\bigg{(}\mu_{2,0}+\mu_{0,2}-\sqrt{\left(\mu_{2,0}-\mu_{0,2} \right)^{2}+4\mu_{1,1}^{2}}\bigg{)}}, \tag{6}\]  
\[\theta=\frac{1}{2}arctan\frac{2\mu_{1,1}}{\mu_{0,2}-\mu_{2,0}}, \tag{7}\]  
where \(\mu_{2,0}\) and \(\mu_{0,2}\) reflect the grayscale variation situations of the image in the horizontal and vertical directions, respectively; \(\mu_{1,1}\) reflects the joint distribution relationship of the image grayscale in the two directions; \(r_{1}\) and \(r_{2}\) represent the major and minor semi-axes of the fitted ellipse, respectively; and \(\theta\) represents the rotation angle of the fitted ellipse. Based on the above content, the bud-point determination can be theoretically determined: the central coordinates of the wheat grain and the lengths of the major axis and minor axis are determined through the minimum circumscribed circle, and the other parameters are determined through the equivalent ellipse. As shown in Figure 6, point \(o\) is the center of the seed, and the length of the seed is \(2r_{1}\). The endpoint, \(A\), of the endosperm of the seed is calculated by adding the offsets in the \(x\) and \(y\) directions to the central coordinates of the seed, where the offset in the x direction is \(r_{1}\times cos\theta\), and the offset in the y direction is \(r_{1}\times sin\theta\). During the germination cultivation process of wheat grains, the germination point is not near the endpoint, \(A\), of the endosperm. Therefore, based on the above formula, a coefficient, \(k\), is introduced, which represents the distance from the central point to point \(A_{1}\). When \(k\) is 1, it represents the coordinate of the endpoint, \(A\). A suitable value of \(k\) is determined so that \(kr_{1}\) represents position \(A_{1}\) of the germination point. The specific expression is as follows:  
\[Ax=ox+kr_{1}\times cos\theta, \tag{8}\]  
\[Ay=oy-kr_{1}\times sin\theta, \tag{9}\]  
Point \(A_{1}\) is the germination point of the wheat in the two-dimensional image. The specific value of the coefficient \(k\) is determined through the experimental analysis in Section 2.4.