# Nondestructive Classification of Maize Moldy Seeds by Hyperspectral Imaging and Optimal Machine Learning Algorithms

^{1}

^{2}

^{3}

^{4}

^{*}

## Abstract

**:**

## 1. Introduction

## 2. Materials and Methods

#### 2.1. Hyperspectral Imaging and Data Acquisition

#### 2.2. Image Processing and Spectral Extraction

#### 2.3. JYSSA Algorithm to Optimize the RF Mode

- (1)
- Full wavelength with feature selected band as input with input sizes of 462 and 186.
- (2)
- Initialize the S population to assign explorers and followers and iterate through the loop by searching the S population’s search range in reverse.
- (3)
- Calculate the fitness value for each individual, ranked in order of high and low.
- (4)
- Update the explorer, follower, and probe positions according to Equations (2)–(4).
- (5)
- Calculate the fitness value again and reorder it, determine whether the maximum number of iterations and the expected convergence effect are satisfied, and if so, continue to the next step; otherwise return to (3).
- (6)
- Select elite S, obtain dynamic boundaries, and update elite S positions using the elite reversal strategy.
- (7)
- Update the fitness value again, determine whether the optimal individual is found, and pass the number of trees and feature subsets to the RF model if found; otherwise, repeat Steps (2)–(6).

#### 2.4. Model Prediction and Testing

_{n}denotes the total number of corn seeds labeled as n; T

_{n}denotes the true label; n denotes the total number of corn seeds in the test set with the true label; ${C}_{p}$ denotes the total number of correctly predicted classes for the entire process p of the total number of maize seeds; and ${C}_{m}$ denotes the total number of maize seeds in the entire dataset.

## 3. Results and Discussion

#### 3.1. Analysis of Spectral Curves of Maize Seeds with Different Degrees of Mildew

#### 3.2. Data Dimensionality Reduction and Feature Selection

#### 3.3. Optimal Model Parameters

#### 3.4. Comparison of Classification Models and Experimental Results

#### 3.5. Application Validation

## 4. Discussion

## 5. Conclusions

## Author Contributions

## Funding

## Institutional Review Board Statement

## Data Availability Statement

## Acknowledgments

## Conflicts of Interest

## References

- Zhang, G.; Bahn, S.-C.; Wang, G.; Zhang, Y.; Chen, B.; Zhang, Y.; Wang, X.; Zhao, J. PLDα1-knockdown soybean seeds display higher unsaturated glycerolipid contents and seed vigor in high temperature and humidity environments. Biotechnol. Biofuels
**2019**, 12, 9. [Google Scholar] [CrossRef] [PubMed] - Zhuo, Y.; Yang, P.; Hua, L.; Zhu, L.; Zhu, X.; Han, X.; Pang, X.; Xu, S.; Jiang, X.; Lin, Y. Effects of Chronic Exposure to Diets Containing Moldy Corn or Moldy Wheat Bran on Growth Performance, Ovarian Follicular Pool, and Oxidative Status of Gilts. Toxins
**2022**, 14, 413. [Google Scholar] [CrossRef] [PubMed] - Chen, Z.; Fan, W.; Luo, Z.; Guo, B. Soybean seed counting and broken seed recognition based on image sequence of falling seeds. Comput. Electron. Agric.
**2022**, 196, 106870. [Google Scholar] [CrossRef] - Volkov, A.; Prohorova, L.; Shabalin, R. Exposure of maize bioagrocenoses to diseases at no-till. In Proceedings of the IOP Conference Series: Earth and Environmental Science; IOP Publishing, Ltd.: Bristol, UK, 2021; p. 042005. [Google Scholar]
- Paraginski, R.T.; Colussi, R.; Dias, A.R.G.; Zavareze, E.d.R.; Elias, M.C.; Vanier, N.L. Physicochemical, pasting, crystallinity, and morphological properties of starches isolated from maize kernels exhibiting different types of defects. Food Chem.
**2019**, 274, 330–336. [Google Scholar] [CrossRef] [PubMed] - Hui, L.; Jingzhu, W.; Cuiling, L.; Xiaorong, S.; Le, Y. Study on Pretreatment Methods of Terahertz Time Domain Spectral Image for Maize Seeds. IFAC-PapersOnLine
**2018**, 51, 206–210. [Google Scholar] [CrossRef] - Liu, S.; Marinelli, D.; Bruzzone, L.; Bovolo, F. A review of change detection in multitemporal hyperspectral images: Current techniques, applications, and challenges. IEEE Geosci. Remote Sens. Lett.
**2019**, 7, 140–158. [Google Scholar] [CrossRef] - Xia, C.; Yang, S.; Huang, M.; Zhu, Q.; Guo, Y.; Qin, J. Maize seed classification using hyperspectral image coupled with multi-linear discriminant analysis. Infrared Phys. Technol.
**2019**, 103, 103077. [Google Scholar] [CrossRef] - Wei, Y.; Li, X.; Pan, X. Nondestructive classification of soybean seed varieties by hyperspectral imaging and ensemble machine learning algorithms. Sensors
**2020**, 20, 6980. [Google Scholar] [CrossRef] [PubMed] - He, X.; Feng, X.; Sun, D.; Liu, F.; Bao, Y.; He, Y. Rapid and nondestructive measurement of rice seed vitality of different years using near-infrared hyperspectral imaging. Molecules
**2019**, 24, 2227. [Google Scholar] [CrossRef] - Liu, Q.; Wang, Z.; Long, Y.; Zhang, C.; Fan, S.; Huang, W. Variety classification of coated maize seeds based on Raman hyperspectral imaging. Spectrochim. Acta Part A Mol. Biomol. Spectrosc.
**2022**, 270, 120772. [Google Scholar] [CrossRef] - Chakhar, A.; Ortega-Terol, D.; Hernández-López, D.; Ballesteros, R.; Ortega, J.F.; Moreno, M.A. Assessing the accuracy of multiple classification algorithms for crop classification using Landsat-8 and Sentinel-2 data. Remote Sens. Environ.
**2020**, 12, 1735. [Google Scholar] [CrossRef] - Nie, P.; Zhang, J.; Feng, X.; Yu, C.; He, Y.; Chemical, A.B. Classification of hybrid seeds using near-infrared hyperspectral imaging technology combined with deep learning. Sensors Actuators B Chem.
**2019**, 296, 126630. [Google Scholar] [CrossRef] - Zhang, J.; Dai, L.; Cheng, F. Classification of frozen corn seeds using hyperspectral VIS/NIR reflectance imaging. Molecules
**2019**, 24, 149. [Google Scholar] [CrossRef] - Yang Sai, Z.Q.; Huang, M. Application of Joint Skewness Algorithm to Select Optimal Wavelengths of Hyperspectral Image for Maize Seed Classification. Spectrosc. Spectr. Anal.
**2017**, 37, 990–996. [Google Scholar] - Orcan, F. Parametric or non-parametric: Skewness to test normality for mean comparison. Int. J. Assess. Tools Educ.
**2020**, 7, 255–265. [Google Scholar] [CrossRef] - Alimohammadi, F.; Rasekh, M.; Sayyah, A.H.A.; Abbaspour-Gilandeh, Y.; Karami, H.; Sharabiani, V.R.; Fioravanti, A.; Gancarz, M.; Findura, P.; Kwaśniewski, D.J.I.A. Hyperspectral imaging coupled with multivariate analysis and artificial intelligence to the classification of maize kernels. Int. Agrophys.
**2022**, 36, 83–91. [Google Scholar] [CrossRef] - Jiang, J.; Qiao, X.; He, R. Use of Near-Infrared hyperspectral images to identify moldy peanuts. J. Food Eng.
**2016**, 169, 284–290. [Google Scholar] [CrossRef] - Yuan, D.; Jiang, J.; Qi, X.; Xie, Z.; Zhang, G. Selecting key wavelengths of hyperspectral imagine for nondestructive classification of moldy peanuts using ensemble classifier. Infrared Phys. Technol.
**2020**, 111, 103518. [Google Scholar] [CrossRef] - Belete, D.M.; Huchaiah, M.D. Grid search in hyperparameter optimization of machine learning models for prediction of HIV/AIDS test results. Int. J. Comput. Appl.
**2021**, 1–12. [Google Scholar] [CrossRef] - Liu, X.; Li, P.; Meng, F.; Zhou, H.; Zhong, H.; Zhou, J.; Mou, L.; Song, S. Simulated annealing for optimization of graphs and sequences. Neurocomputing
**2021**, 465, 310–324. [Google Scholar] [CrossRef] - Xue, J.; Shen, B. A novel swarm intelligence optimization approach: Sparrow search algorithm. Syst. Sci. Control Eng.
**2020**, 8, 22–34. [Google Scholar] [CrossRef] - Tuerxun, W.; Chang, X.; Hongyu, G.; Zhijie, J.; Huajian, Z. Fault diagnosis of wind turbines based on a support vector machine optimized by the sparrow search algorithm. IEEE Access
**2021**, 9, 69307–69315. [Google Scholar] [CrossRef] - Tang, Y.; Li, C.; Li, S.; Cao, B.; Chen, C. A fusion crossover mutation sparrow search algorithm. Math. Probl. Eng.
**2021**, 2021, 9952606. [Google Scholar] [CrossRef] - Tallada, J.G.; Wicklow, D.T.; Pearson, T.C.; Armstrong, P.R. Detection of Fungus-Infected Corn Kernels Using Near-Infrared Reflectance Spectroscopy and Color Imaging. Trans. ASABE
**2011**, 54, 1151–1158. [Google Scholar] [CrossRef] - Pang, L.; Wang, L.; Yuan, P.; Yan, L.; Xiao, J. Rapid seed viability prediction of Sophora japonica by improved successive projection algorithm and hyperspectral imaging. Infrared Phys. Technol.
**2022**, 123, 104143. [Google Scholar] [CrossRef] - Zhang, C.; Ding, S. A stochastic configuration network based on chaotic sparrow search algorithm. Knowl.-Based Syst.
**2021**, 220, 106924. [Google Scholar] [CrossRef] - Ouyang, C.; Zhu, D.; Wang, F. A learning sparrow search algorithm. Comput. Intell. Neurosci.
**2021**, 2021, 3946958. [Google Scholar] [CrossRef] [PubMed] - Zhang, W.; Li, X.; Zhao, L. A fast hyperspectral feature selection method based on band correlation analysis. IEEE Geosci. Remote Sens. Lett.
**2018**, 15, 1750–1754. [Google Scholar] [CrossRef] - Kivi, M.E.; Majidnezhad, V. A novel swarm intelligence algorithm inspired by the grazing of sheep. J. Ambient Intell. Humaniz. Comput.
**2022**, 13, 1201–1213. [Google Scholar] [CrossRef]

**Figure 6.**Spectral curves of five kinds of maize seeds with different degrees of mildew: (

**a**) A1 maize seed spectral curve; (

**b**) A2 maize seed spectral curve; (

**c**) A3 maize seed spectral curve; (

**d**) A4 maize seed spectral curve; (

**e**) A5 maize seed spectral curve.

**Figure 7.**Spectral curve preprocessing: (

**a**) original spectral curve; (

**b**) spectral curve after smoothing; (

**c**) spectral curve after SVN; (

**d**) spectral curve after MSC.

**Figure 10.**Convergence of algorithm adaptation curves: (

**a**) convergence curves of 462 bands; (

**b**) convergence curves of 186 bands.

**Figure 11.**Comparison of the training set and test set: (

**a**) training set of 462 bands; (

**b**) test set of 462 bands; (

**c**) training set of 186 bands; (

**d**) test set of 186 bands.

**Figure 12.**Visualization of predicted moldy maize seeds. (

**a**) Different mold visualization images; (

**b**) 462-band RF model prediction visualization map; (

**c**) 462-band SSA-RF model prediction visualization map; (

**d**) 462-band JYSSA-RF model prediction visualization map; (

**e**) 186-band RF model prediction visualization map; (

**f**) 186-band SSA-RF model prediction visualization map; (

**g**) 186-band JYSSA-RF model prediction visualization map.

Seed Number | Degree of Mold and Mildew | Number of Seeds |
---|---|---|

A1 | Healthy | 77 |

A2 | Mild mildew | 56 |

A3 | Moderate mold | 63 |

A4 | Heavier mold | 70 |

A5 | Heavy mold | 70 |

Algorithm | Optimal Adaptation | N_Estimators Optimal Solution | Max_Features Optimal Solution |
---|---|---|---|

SSA | 0.151 | 14 | 139 |

JYSSA | 0.151 | 41 | 100 |

Algorithm | Optimal Adaptation | N_Estimators Optimal Solution | Max_Features Optimal Solution |
---|---|---|---|

SSA | 0.155 | 31 | 47 |

JYSSA | 0.147 | 25 | 96 |

Models | Seed Tags | Precision | Recall | Sample Size | Accuracy |
---|---|---|---|---|---|

JYSSA-RF | 0 | 0.88 | 1.00 | 15 | 0.85 |

1 | 0.78 | 0.78 | 9 | ||

2 | 0.67 | 0.50 | 12 | ||

3 | 0.79 | 0.85 | 13 | ||

4 | 0.67 | 0.67 | 12 | ||

SSA-RF | 0 | 0.88 | 1.00 | 15 | 0.85 |

1 | 0.78 | 0.78 | 9 | ||

2 | 0.90 | 0.75 | 12 | ||

3 | 1.00 | 0.77 | 13 | ||

4 | 0.73 | 0.92 | 12 | ||

RF | 0 | 0.88 | 1.00 | 15 | 0.77 |

1 | 0.78 | 0.78 | 9 | ||

2 | 0.89 | 0.67 | 12 | ||

3 | 1.00 | 0.85 | 13 | ||

4 | 0.73 | 0.92 | 12 |

Models | Seed Tags | Precision | Recall | Sample Size | Accuracy |
---|---|---|---|---|---|

JYSSA-RF | 0 | 0.88 | 1.00 | 15 | 0.85 |

1 | 0.60 | 0.67 | 9 | ||

2 | 0.70 | 0.58 | 12 | ||

3 | 0.88 | 0.54 | 13 | ||

4 | 0.62 | 0.83 | 12 | ||

SSA-RF | 0 | 0.88 | 1.00 | 15 | 0.85 |

1 | 0.78 | 0.78 | 9 | ||

2 | 0.82 | 0.75 | 12 | ||

3 | 1.00 | 0.77 | 13 | ||

4 | 0.79 | 0.92 | 12 | ||

RF | 0 | 0.93 | 1.00 | 14 | 0.74 |

1 | 0.93 | 0.93 | 14 | ||

2 | 1.00 | 0.93 | 14 | ||

3 | 1.00 | 0.93 | 14 | ||

4 | 0.93 | 1.00 | 14 |

Models | Seed Tags | Precision | Recall | Sample Size | Accuracy |
---|---|---|---|---|---|

JYSSA-RF | 0 | 0.93 | 1.00 | 14 | 0.94 |

1 | 0.93 | 0.93 | 14 | ||

2 | 1.00 | 0.86 | 14 | ||

3 | 0.92 | 0.86 | 14 | ||

4 | 0.88 | 1.00 | 14 | ||

SSA-RF | 0 | 0.93 | 1.00 | 14 | |

1 | 0.93 | 1.00 | 14 | 0.93 | |

2 | 0.81 | 0.93 | 14 | ||

3 | 1.00 | 0.86 | 14 | ||

4 | 1.00 | 0.77 | 14 | ||

RF | 0 | 0.93 | 1.00 | 14 | |

1 | 0.93 | 0.93 | 14 | ||

2 | 1.00 | 0.93 | 14 | 0.91 | |

3 | 1.00 | 0.93 | 14 | ||

4 | 0.93 | 1.00 | 14 |

Models | Seed Tags | Precision | Recall | Sample Size | Accuracy |
---|---|---|---|---|---|

JYSSA-RF | 0 | 0.93 | 1.00 | 14 | 0.96 |

1 | 0.93 | 0.93 | 14 | ||

2 | 0.92 | 0.86 | 14 | ||

3 | 1.00 | 0.86 | 14 | ||

4 | 0.81 | 0.93 | 14 | ||

SSA-RF | 0 | 0.93 | 1.00 | 14 | |

1 | 0.93 | 0.93 | 14 | 0.94 | |

2 | 1.00 | 0.86 | 14 | ||

3 | 0.93 | 0.93 | 14 | ||

4 | 0.93 | 1.00 | 14 | ||

RF | 0 | 0.93 | 1.00 | 14 | |

1 | 0.93 | 0.93 | 14 | ||

2 | 1.00 | 0.93 | 14 | 0.91 | |

3 | 1.00 | 0.92 | 14 | ||

4 | 0.93 | 1.00 | 14 |

Publisher’s Note: MDPI stays neutral with regard to jurisdictional claims in published maps and institutional affiliations. |

© 2022 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (https://creativecommons.org/licenses/by/4.0/).

## Share and Cite

**MDPI and ACS Style**

Hu, Y.; Wang, Z.; Li, X.; Li, L.; Wang, X.; Wei, Y.
Nondestructive Classification of Maize Moldy Seeds by Hyperspectral Imaging and Optimal Machine Learning Algorithms. *Sensors* **2022**, *22*, 6064.
https://doi.org/10.3390/s22166064

**AMA Style**

Hu Y, Wang Z, Li X, Li L, Wang X, Wei Y.
Nondestructive Classification of Maize Moldy Seeds by Hyperspectral Imaging and Optimal Machine Learning Algorithms. *Sensors*. 2022; 22(16):6064.
https://doi.org/10.3390/s22166064

**Chicago/Turabian Style**

Hu, Yating, Zhi Wang, Xiaofeng Li, Lei Li, Xigang Wang, and Yanlin Wei.
2022. "Nondestructive Classification of Maize Moldy Seeds by Hyperspectral Imaging and Optimal Machine Learning Algorithms" *Sensors* 22, no. 16: 6064.
https://doi.org/10.3390/s22166064