Vision-Based Defect Classification and Weight Estimation of Rice Kernels

Xiang Wang, Kai Wang, Xiaohong Li, Shiguo Lian

Abstract

Rice quality estimation is a critical process with significant food safety and socio-economic implications. Traditionally, this task has relied on manual inspection, which is prone to subjectivity and human error. This paper presents an automated visual quality estimation system designed to classify rice kernels by defect type and evaluate quality through weight ratios. To address challenges such as imbalanced data and kernels with multiple defects, we propose a multi-stage workflow that utilizes deep learning for localization and classification. Furthermore, we introduce a novel "weight-per-pixel" metric to estimate the relative weight of kernels from 2D images. Experimental results demonstrate that the system achieves high precision in a contactless manner, offering a robust alternative to manual sorting.

Introduction

Rice grading is a high-stakes agricultural task that directly influences market pricing and consumer safety. Quality is typically determined by the presence of defects such as chalkiness, spotting, or breakage. However, manual inspection is labor-intensive and inconsistent. While computer vision offers a potential solution, two primary technical hurdles have persisted: the accurate classification of "dual-defect" kernels (e.g., a grain that is both broken and chalky) and the estimation of physical weight from two-dimensional image data.

This research addresses these challenges by integrating a specialized hardware environment with a multi-stage deep learning architecture and a class-specific density metric to provide a comprehensive, automated grading solution.

System Methodology

Hardware Configuration

To ensure high-quality data acquisition, the authors developed a controlled imaging environment. This setup includes a specialized imaging box equipped with a white dome light to provide uniform, shadowless illumination. A non-reflective black mat serves as the background, maximizing the contrast of the rice kernels and ensuring that internal structures, such as chalkiness and glossiness, are clearly visible to the sensor.

Multi-Stage Classification Workflow

Rather than employing a single monolithic model, the system utilizes a branched architecture to handle the nuances of different defect types:

  • Branch A (General Defects): A YOLOv5 model is trained to identify and localize "Sound" (undamaged), "Broken," "Spotted," and "Yellow-Colored" kernels using standard color imagery.
  • Branch B (Chalky Defects): Recognizing that color can sometimes obscure internal grain structures, the system converts images to grayscale for chalkiness detection. A second YOLOv5 model locates these kernels, followed by a ResNeXt classifier that distinguishes between "Partial-Chalky" (PC) and "Mass-Chalky" (MC) categories.
  • Fusion and Multi-Label Handling: The results from both branches are merged. If a kernel is identified by both branches, it is assigned "dual properties." This allows the system to accurately categorize complex grains without requiring a separate class for every possible defect combination, which helps mitigate the "long tail" data problem during training.

Weight-per-Pixel Metric

In the rice industry, quality is measured by weight ratios rather than simple counts. To bridge the gap between 2D pixel area and physical mass, the researchers introduced the weight-per-pixel metric ($\rho_t$). By pre-calculating the average density (mass divided by projected 2D area) for each specific defect type, the system can estimate the weight of an individual kernel by multiplying its segmented area by its class-specific density. This approach accounts for the fact that different defects (like chalkiness or breakage) significantly alter the density and transparency of the grain.

Experimental Setup and Results

Dataset

The system was trained and validated on a custom dataset of 322 high-resolution images. Each image contains between 40 and 80 kernels, all of which were manually labeled by professional quality inspectors. The dataset covers six primary categories: Sound (SO), Partial-Chalky (PC), Mass-Chalky (MC), Yellow-Colored (YC), Spotted (SP), and Broken (BR).

Performance Metrics

The system was evaluated using 5-fold cross-validation, yielding the following results:

  • Classification Precision: The model achieved over 90% precision for Sound, Broken, Yellow, and Spotted kernels. The dedicated grayscale branch significantly improved the recall for Mass-Chalky kernels compared to standard single-stage baselines.
  • Weight Estimation Accuracy: The mean error for weight ratio estimation remained under 2% across all defect categories, with a maximum error threshold of less than 3%.
  • Efficiency: The automated, contactless nature of the system allows for rapid processing, significantly reducing the time required compared to manual weighing and sorting.

Discussion and Conclusion

The research highlights two critical insights: first, that grayscale processing is superior for identifying internal chalky structures; and second, that class-specific density is essential for accurate weight estimation from 2D images.

While the system is highly effective, current limitations include a reliance on fixed camera geometry and the requirement that kernels be relatively spread out to avoid overlaps. Future work will focus on improving segmentation algorithms to handle clumped kernels and expanding the dataset to include a wider variety of rice cultivars. Overall, this multi-stage vision system provides a precise, objective, and efficient tool for the global rice industry.

Summary updated

Abstract

Rice is one of the main staple food in many areas of the world. The quality estimation of rice kernels are crucial in terms of both food safety and socio-economic impact. This was usually carried out by quality inspectors in the past, which may result in both objective and subjective inaccuracies. In this paper, we present an automatic visual quality estimation system of rice kernels, to classify the sampled rice kernels according to their types of flaws, and evaluate their quality via the weight ratios of the perspective kernel types. To compensate for the imbalance of different kernel numbers and classify kernels with multiple flaws accurately, we propose a multi-stage workflow which is able to locate the kernels in the captured image and classify their properties. We define a novel metric to measure the relative weight of each kernel in the image from its area, such that the relative weight of each type of kernels with regard to the all samples can be computed and used as the basis for rice quality estimation. Various experiments are carried out to show that our system is able to output precise results in a contactless way and replace tedious and error-prone manual works.
BibTeX
@article{wang2022vision,
  author = {Xiang Wang and Kai Wang and Xiaohong Li and Shiguo Lian},
  title = {{Vision-Based Defect Classification and Weight Estimation of Rice Kernels}},
  journal = {IEEE Access},
  year = {2022},
  doi = {10.1109/access.2022.3223137},
}
Figure