# Quality Assessment of Components of Wheat Seed Using Different Classifications Models
## 2 Materials and Methods
### Calculating the Shape Features  
The algorithm for morphological features was written in the main image pre-processing program, which upon receiving the binary and labelled image, calculated the features separately for each grain. By using the calibration coefficient, the length unit was converted from pixels to millimetres and the features were converted accordingly. Calculations of the features such as area (A), periphery (P), main axis length, smallest axis length, length, width, rigidity, equivalent diameter and eccentricity was conducted by the regionprops function in MATLAB tools. For calculating other features, the following functions were employed in MATLAB:  
Thinness Ratio (TR): It measured the roundness of the kernel.  
\[\mathrm{TR}=\frac{\mathrm{p}^{2}}{4\pi\mathrm{A}} \tag{1}\]  
Aspect Ratio: Major Axis Length/Minor Axis Length.  
Rectangular Aspect Ratio: Length/Width.  
Area Ratio: (Length \(\times\) Width)/Area.  
Maximum Radius (mm): It was the maximum distance between a pixel on the boundary and the centre of the kernel.  
Minimum Radius (mm): It was the minimum distance between a pixel on the boundary and the centre of the kernel.  
Radius Ratio: Maximum Radius/Minimum Radius. Mean Radius (\(\mu_{\mathrm{R}}\)): It was the mean of all radii of the kernel region.  
Standard Deviation of all Radii (\(\sigma_{\mathrm{R}}\)): It was the standard deviation of the distances of all pixels on the boundary from the centre of the kernel.  
Haralick Ratio: \(\mu_{\mathrm{R}}/\sigma_{\mathrm{R}}\).  
Fourier Descriptors: The one-dimensional distance function \(\mathrm{d}_{\mathrm{k}}\) was calculated for all pixels on the boundary of a kernel as follows:  
\[\mathrm{d}_{\mathrm{k}}=\left[(\mathrm{i}_{\mathrm{k}}-\mathrm{c}_{\mathrm{ ik}})^{2}+\left(\mathrm{i}_{\mathrm{k}}-\mathrm{c}_{\mathrm{jk}}\right)^{2} \right]^{1/2} \tag{2}\]  
where  
(\(\mathrm{i}_{\mathrm{k}}\),\(\mathrm{j}_{\mathrm{k}}\)) = kth pixel coordinates on the boundary of the kernel;  
(\(\mathrm{c}_{\mathrm{ik}}\),\(\mathrm{c}_{\mathrm{jk}}\)) = centroid of the kth kernel.  
The magnitude of the Fourier descriptors was calculated as follows:  
\[\mathrm{FD}_{\mathrm{u}}=\left[\mathrm{R}_{\mathrm{u}}{}^{2}+\mathrm{I}_{ \mathrm{u}}{}^{2}\right]^{1/2} \tag{3}\]  
For u = 0, 1, 2,... (N - 1). The real value of the descriptor was defined as follows:  
\[\mathrm{R}_{\mathrm{u}}=\sum_{\mathrm{k}=0}^{\mathrm{N}-1}\mathrm{d}_{\mathrm{ k}}\cdot\mathrm{cos}\left[\frac{2\pi\mathrm{ku}}{\mathrm{N}}\right] \tag{4}\]  
Additionally, the imaginary value of the descriptor was defined as follows:  
\[\mathrm{I}_{\mathrm{u}}=\sum_{\mathrm{k}=0}^{\mathrm{N}-1}\mathrm{d}_{\mathrm{ k}}\cdot\mathrm{sin}\left[\frac{2\pi\mathrm{ku}}{\mathrm{N}}\right] \tag{5}\]  
where  
N = number of pixels on the boundary of the kernel.  
The first seven Fourier descriptors (u = 0, 1, 2, 3, 4, 5 and 6) were used for analysis.  
Calculating moments: Spatial moments are a set of invariant moments, insensitive to transition, congruence, reflection, and rotation [11]. These moments are statistical measurements of the object's attributes. Seven standard invariant moments were calculatedfor the binary image of each grain using normalized central moments introduced by [15]. A total of 31 shape features was found for each grain.