Efficient Paddy Grain Quality Assessment Approach Utilizing Affordable Sensors

: Paddy ( Oryza sativa ) is one of the most consumed food grains in the world. The process from its sowing to consumption via harvesting, processing, storage and management require much effort and expertise. The grain quality of the product is heavily affected by the weather conditions, irrigation frequency, and many other factors. However, quality control is of immense importance, and thus, the evaluation of grain quality is necessary. Since it is necessary and arduous, we try to overcome the limitations and shortcomings of grain quality evaluation using image processing and machine learning (ML) techniques. Most existing methods are designed for rice grain quality assessment, noting that the key characteristics of paddy and rice are different. In addition, they have complex and expensive setups and utilize black-box ML models. To handle these issues, in this paper, we propose a reliable ML-based IoT paddy grain quality assessment system utilizing affordable sensors. It involves a specific data collection procedure followed by image processing with an ML-based model to predict the quality. Different explainable features are used for classifying the grain quality of paddy grain, like the shape, size, moisture, and maturity of the grain. The precision of the system was tested in real-world scenarios. To our knowledge, it is the first automated system to precisely provide an overall quality metric. The main feature of our system is its explainability in terms of utilized features and fuzzy rules, which increases the confidence and trustworthiness of the public toward its use. The grain variety used for experiments majorly belonged to the Indian Subcontinent, but it covered a significant variation in the shape and size of the grain.


Introduction
Agriculture is a necessity for any human cycle to fulfill the basic needs of life.Rice (a product of paddy) is consumed as a primary food or supporting food in many countries.The rice production process involves a lot of effort from its sowing to final preparation, and it is often affected by various climate conditions [1].After extracting paddy, farmers have three options depending on the quality of the grain: it can be stored as seed for the next crop, it can be stored for further consumption, or it has to be consumed instantly.These options are decided based on the moisture content (0-10%, 10-27% or more than that) of the grain.Other quality measures like adulteration, broken grain, and immature grain are also indicators used to predict the strength of the grain and its demand in the market.These parameters all have to be calculated to better postprocess the grain.Paddy has such wide varieties, and it varies in the form of changes in length, width, color, and gelatinization temperature [2,3].To evaluate all of these parameters, there is a demand [4] for an integrated system connected through the internet that can detect the variation in the quality of different grain lots and update information automatically to a common server.Such an IoT systems would help in integrating all the procurement centers through a common server for centralized monitoring.
In India, a huge variety of paddy grains are available.In Figure 1, different variations for paddy grain are shown.All varieties belong to the Indian Subcontinent, and the names used are in the local Indian language.Of these varieties, Radha is the thickest grain, and Zeera is the thinnest grain.In contrast, Ranjit is the longest grain, and Kanxi is the shortest grain, and the other two varieties (Sona and Zaya) have in-between variations in color and size.Similarly, other paddy crop breeds also vary in shape, size, color, and moisture content.Grading paddy grains is a must-solve requirement for their fair pricing and exchange.It affects [5] exports, imports, procurement, and other economic activities.In our work, we solved a problem related to the procurement of paddy grain in the government procurement centers of India, where grain is procured by the government at an MSP (minimum support price) value and further used in PDSs (Public Distribution Schemes) and Food Security Schemes.The quality of grain for every lot is decided manually (visual observation) by the local representatives at every procurement center.However, the main drawback of the existing paddy grain evaluation scheme is that some middlemen usually create hindrance for the innocent farmers while procuring agricultural produce by falsely claiming the quality of the produce [6].They either falsely claim the quality, or they manipulate the local representative by some means, which creates a vacuum for the growth of corruption [7] in the system.This corruption works vice versa; a lot with bad quality can be claimed to have good quality.The quality decision process takes place at the procurement center, so to that extent, the farmer has already paid a lot of money in transporting the produce from his home to the center.This problem affects farmers' economic conditions [8] in significant parts of India because they have to sell the produce at low prices in nearby shops to the procurement center to cover the transportation costs.The main reason for this issue is the unavailability of an automated quantitative grading system for such products.This problem is raised by the State Government of Jharkhand (India).It is worth noting that in Jharkhand, more than 125,000 farmers [9] depends on the paddy crop, and its cultivation is conducted across 90,000 acres of field.These numbers show that most farmers own a field of less than 1 acre, so any amount of corruption will significantly impact their lives.The confidence of farmers in the system is decreasing, and the adaptation of any new machinery for evaluation needs the trust [10] of the farmers in terms of its methodology.
This problem needs a robust, explainable, fair evaluation system with minor human intervention.Using an Internet of Things (IoT)-based [11] paddy grain grading system would improve the fairness of the process for farmers and their reliance on the procurement process at government centers by removing the human intervention in this process.This paper proposes a reliable, fully automatic, and explainable paddy grain quality assessment system based on affordable sensors and machine learning (ML) techniques.

Related Work
Although there are some existing methods for identifying the grain quality of paddy, they have a limited scope of applications.They are costly due to the use of an expensive setup (ranges between USD 1000 and 1500) and the requirement of manual expertise (laboratory testing).This cost can be reduced using a minimized setup, as proposed, which costs around USD 150 only.This setup can be employed at major procurement centers.Most studies in the literature are related to the evaluation of rice, and very few works are available for paddy grain assessments [12][13][14][15].Existing methods can be broadly categorized as vision-based methods for appearance-related measurements and other sensory-based methods for moisture measurements.In vision-based methods, the grain image is captured using a camera setup.Then, feature extraction methods are applied, followed by machine learning algorithms to classify the quality into different classes.
In [16], many machine vision-based [17] methods for food grain quality measurements were compared.The study discussed using artificial intelligence (AI) in grading and identifying foreign matter, insect infestation, microbial infection, and discolored grains.In [18], rice grains' morphological features and color features were extracted and combined to train an artificial neural network (ANN) classifier to identify the rice category.The major limitation of this method is increasing the number of features.The accuracy drops by a considerable amount.In paper [19], the authors evaluated two approaches for the classification of 14 categories of rice grain according to their morphological structures: (1) a deep convolutional neural network (CNN) [20] and (2) handcrafted features with a support vector machine (SVM) algorithm.The CNN achieved a 94% accuracy, while the SVM achieved results that were 86% accurate.In [21], a contour detection method followed by an SVM was used to identify adulteration in rice grains.Acceptable results were obtained on a custom dataset.Ref. [22] employed a CNN with morphological measurements for predicting the quality of rice grain, obtaining a 90.20% precision.This method is limited to the length and width measurement of rice grains.
It should be noted that the evaluation of paddy is different from that of rice, where the critical parameters for paddy are moisture and the morphological structure.Ref. [23] presented a principal component analysis (PCA)-based method to recognize the adulteration level in the bulk of paddy grain.It obtained an accuracy of 93% for adulteration recognition.Ref. [24] used T-20 HOG (Top-20 Histogram of Oriented Gradient) features and Haralick features for the identification of paddy varieties and achieved a precision of 99% on the BDRICE (private) dataset.Ref. [25] employed an SVM algorithm and image processing techniques to inspect paddy grain varieties.It obtained an accuracy of 94%.In [26], R-CNN deep learning models were used for categorizing the leaves of a paddy plant.In [27], an image processing-based method was proposed for breakage and adulteration measurements in paddy grains.This method detects the broken grain with 84% accuracy.
The main limitations of the above-mentioned methods are as follows: (1) they only work for the assessment of specific and limited types of grain quality and do not conduct an overall evaluation, and (2) deep learning-based methods are a black box and lack explainability.Also, these methods do not consider the moisture present in the grain.
Other studies have been presented for measuring moisture [28,29].For instance, ref. [28] proposed a fluidized bed-based method and monitored the airflow parameters used for drying the paddy.These parameters were then used to train an ANN network for moisture prediction.In [30], a machine vision-based monitoring method was integrated with the bed-based solution for measuring the moisture.The processes involved in moisture measurement are usually used in the drying process, and this includes dedicated moisture sensors, which limit the evaluation for moisture only.Some commercial systems like AmviCube [31], RIPMAPP [32,33] are also available for estimating the quality of paddy and rice, and deep learning has been widely used in different domains [34][35][36][37][38][39][40][41][42].However, these systems are based on sophisticated and expensive setups, and skilled labor is needed to use these products.They use a measuring tray for reference in analyzing the quality of rice.For moisture, they use a separate machine that requires human involvement and expertise for the analysis.The major issue with these quality assessment systems is their high cost, which hinders their use for mass.
In the literature, IoT technologies have been used in grain procurement [4,43] and grain distribution [44] in public centers.Ref. [43] analyzed India's challenges in grain procurement and its solutions based on IoT.Ref. [4] discussed the use of mobile technology in food collection and storage.In [44], a public distribution system was designed in an automated way using different sensors, which provide an ease to the flow of information.Our paper proposes an IoT system for paddy grain quality assessment.We used internetconnected affordable sensors and a Raspberry Pi computation unit hosting ML-based grain quality assessment and adulteration detection models.The proposed quality assessment system aims to support the system's independence from middlemen and any manipulation.

Contribution and Paper Organization
As discussed above, most existing methods have been designed for rice grain quality assessments, noting that the key characteristics of paddy and rice are different.In addition, they have complex and expensive setups and utilize black-box AI models.To handle these issues, in this paper, we propose a reliable ML-based IoT paddy grain quality assessment system utilizing affordable sensors.This method uses a neuro-fuzzy [45] method to learn a mapping between grain features and its class.This fuzzy-based method helps us to understand the relationships of the paddy quality in terms of crisper commands.Image processing tools were used to calculate the grain parameters, and the ANFIS tool was then used to map those parameters to the end label.The ANFIS tool was designed in such a way that the resultant fuzzy rules are clearly visible for human understanding.
This paper includes the following main contributions: • Proposing a reliable, fully automatic, and explainable IoT paddy grain quality assessment system based on affordable sensors and ML techniques.

•
Proposing a novel method for moisture calculation based on paddy grain weight versus volume estimation.

•
Providing an extensive evaluation of the proposed method on a paddy grain dataset collected from distant locations in India.
The remaining parts of this paper include three sections.Section 2 presents the problem definition, dataset collection setup, and proposed paddy grain assessment method.Section 3 discusses the experiments and results of the proposed method, and Section 4 provides comparisons with other ML methods.Section 5 concludes the paper and discusses the future scope of the target problem.

Methodology
This section discusses the proposed neuro-fuzzy method for classifying grain versus non-grain.It discusses a detailed dataset collection process.It describes the feature extraction using image processing methods and methods for measuring adulteration using image processing operations.It finally describes the neuro-fuzzy method for determining the grain quality.

Hardware Setup for Paddy Grain Dataset Collection
The paddy was to be procured, stored, and then used required in the future.To evaluate the quality of paddy grains, we needed to check for the strength in terms of internal and external qualities.Hence, the evaluation criteria include the moisture present in the grain, adulteration percentage, and broken grain percentage; these three metrics are based on an outer morphological analysis and inner quality evaluation.The major problem in paddy or any grain quality analysis is the lack of a standard dataset.No particular data-based analysis is available for evaluating paddy grains' moisture content.
The dataset collection is of significant importance in the whole process.This study collected a paddy grain dataset considering different aspects such as the grain color, size, and weight retained by the grain for different moisture levels.As shown in Figure 1, the dataset was collected from six different mills and government procurement centers in India and Nepal.
We selected different centers for collecting the dataset.These centers were either procurement centers or rice mills.As shown in Figure 2, the locations of all centers varied from the plains of the Ganges in Jharkhand to the Himalayan valley areas in Nepal.This geographic difference [46] created a considerable variation in terms of grain quality.These centers were equipped with different types of paddy, and some experts have been working in the field of procurement for a long time.The grains had variations in terms of moisture, size, and shape, enhancing the variance in the dataset.
Figure 3 presents the setup we used to capture images for each type of paddy grain with different quality conditions.The setup included an overhead camera to capture pictures.This setup facilitates uniformity in the dataset of images.These images were used for grain size and color analyses.For each paddy grain image, the corresponding moisture values were recorded.This study considered six wide paddy grain varieties, as shown in Figure 1.It should be mentioned that the same set of paddy types with different moisture and size values was tested for moisture, weight, size/shape, and color.
The LDS-1G [47] moisture meter was used to measure the moisture of different paddy grains.The functioning of this device is based on a capacitance and temperature detection circuit.With the help of these circuits, it will set the detected signal to the signal-chip microcomputer.
The LDS-1G moisture meter has different settings from L 1 to L 20 , which measures the moisture of objects like cereal, corn, paddy and other types of grains; it has a test loss less than ±0.5%, and it has a repeat loss less than 0.2%.The sensitivity of the device ranges from 3 to 35%.Usually, it takes less than 10 s to measure the moisture content.It can sustain temperatures of 0-40 • C. In this study, we used two settings, namely, L 1 and L 7 , which are prescribed for paddy grains.
All varieties of paddy have different appearances and characteristics.Some are light in color, some are small, and some are thick.We intend to find how the weights of different shapes and sizes of paddy would vary per moisture content.Thus, we took the following readings for all types of paddy.The setting value shows the set scale of the moisture meter and varied between L 1 and L 7 .The paddy grain images and the corresponding moisture information were arranged in a dataset.Each sample was categorized based on four factors: paddy type, morphological details, moisture meter settings, and moisture content, as shown in Table 1.It should be mentioned that each dataset sample contains an image and weight value for a fixed volume of 1 L.

Proposed System
We propose a fuzzy inference-based machine learning [48] model, which takes morphological features from image input and the weight from a weight sensor as input and  outputs the form of the quality of the grain.In Figure 4, the overall setup is shown.It contains a raspberry pi computer to control the vision and weight sensors.The information extracted from these sensors is input into an ANFIS.The result from the grain analysis is used in the database, and it can be used as a reference in the future.The acronym ANFIS refers to the Adaptive Neuro-Fuzzy Inference System.This model integrates a neural network framework based on the Sugeno method, a well-known technique in fuzzy logic.The ANFIS combines the learning capabilities of neural networks with the fuzzy logic principle of dealing with uncertainties, thereby enhancing its applicability in complex systems.The process involves not only the typical weight adjustments found in neural networks but also includes the fuzzification and defuzzification of crisp values.Fuzzification converts precise input values into fuzzy values, which are then processed and turned back into crisp outputs through defuzzification, thus enabling the system to handle a wider range of data scenarios effectively.
This process includes various steps like feature extraction from images (visual inspection), moisture prediction using the weight (weight inspection), and the usage of the ANFIS system, database, and connections.

Image Preprocessing
The proposed methodology takes an image of a random sample from each test case as input.The image contains grains scattered on a white plate.The image-based analysis is first used to check adulteration in the sample, and then the size and color features are used as input in our fuzzy inference system.The features of interest are the morphological structure of the grains and the color of their cover.
The images can have noise and disturbances in rice samples.The quality of the results can vary depending on the quality of the images.Hence, the images require preprocessing.Every image sample is converted to a size of 240 × 240.To remove the noise, a median filter is used.It uses a 3 × 3 kernel and replaces the kernel's center value with the median of all values in that filter.
After noise removal, four specific processes using image processing techniques are used, as shown in Figure 5.The main motivation of image processing is to find the region of interest and the difference in the color of the grains.For finding the region of interest, contouring is used along with grayscale conversion, flood filling, and inversion; for the color analysis, a grayscale image is taken as input.These processes are the standard processes defined in the opencv library.
A color image is changed into a gray image to make the analysis easy.We used NTSC formulae, which can be expressed as follows: It should be noted that the background of every image is white, so grains are easily distinguishable in some shades of gray.The flood fill algorithm is used to fill a connected segment with a particular color (in our case, gray).The proposed algorithm is used to distinguish the background from grains.It uses a threshold to define the level of connectivity while considering neighboring pixels, which range between 0 and 100.In our case, we selected it as '25'.The value '25' was defined empirically by noticing the separation of grain and non-grain pixels.It was determined using the OpenCV library for flood filling.As shown in Figure 5, the flood fill algorithm converts the background into gray space and grains into white spaces.This image is inverted to the opposite color.
The inverted image contains paddy grain images in a segmented form.A contour method is used to detect the number of contours in the form of paddy.The cv.CHAIN_APPRO X_SIMPLE method is used for contouring.It compresses vertical, horizontal, and diagonal segments and creates the form of a four-point rectangle.It outputs a list of all the contours in the image, and each contour is a NumPy array of coordinates (x, y) of the boundary points of the objects.As shown in Figure 5, some grains are not detected as contours.After analysis, we concluded that contour detection sometimes fails for grain and non-grain samples, which does not have much of an effect on the process.The image preprocessing module results in a grayscale image and contour information in the form of a list of coordinates.We use the contour coordinates to calculate the length (L), width (W), and diameter (D) features.L and W are parameters related to the predicted contour, and D is the width covered by the grain inside the contour box.It should be noted that the L and W features are used for adulteration detection, while D is used as a size reference for the paddy grain quality assessment classifier.

Adulteration Detection Method
Algorithm 1 presents the steps of adulteration detection, which classifies the grains as paddy grains or non-paddy grains.The adulteration detection algorithm uses the grain color from a grayscale image (intensity of the center point of the contour, I mid ).If the grain color is darker than an intensity threshold (T intensity ), then it is considered a low-quality grain; otherwise, it is considered a high-quality grain.A value of '1.3' is used for comparing the ratio (R) of L and W.This value is defined empirically by observing different grain structures.The 'R' term is the ratio counted in the form of a structural representation because every grain in a paddy should have a difference in length and width.If the ratio goes beyond the value of R, then adulteration is considered in the grain and the contour is not used for analysis purposes.

Algorithm 1 Implementation of the Adulteration Detection Method
Inputs: Length (L), Width (W), and mid-point intensity (I mid ) Output: Paddy Grain or Foreign Element 'Foreign Element' Else-If I mid < T intensity : 'Foreign Element' Else: 'Paddy Grain' Step:3 Repeat the process for each contour If a grain sample fails to qualify the adulteration criterion, then the sample is not used for further processing.If it qualifies, the mean value of the diameter is used as a reference for the size and mean grain pixel intensity as a reference for the color.In a sample of 'n' grains, the mean diameter (D mean ) and mean intensity (I mean ) are taken as references.The use of diameter overcomes the use of length and width as separate parameters, reflecting the grain size.D mean is treated as the average representation for all grains.In the same way, the mean pixel intensity (I mean ) reflects the color value of the grains.

Moisture Prediction Method
This study proposes a novel method to calculate the moisture based on paddy grain weight.This method compares the weight of two different sets of grain for a fixed amount of volume as follows: More weight indicates a higher presence of moisture in the sample.This fact is also validated during the dataset collection.

Constructing a Quality Assessment Model Based on ANFIS
The focus of our work was to make our process more explainable, which results in the form of the belief of a layman.We selected fuzzy Logic to handle this problem.A neuro-fuzzy model was trained to find the best weights of the fuzzy rules and membership functions for grain classification.As shown in Figure 6, it uses three inputs-size, weight, and color-and outputs the class of the grain as good or bad.The color value is taken as the normalized value of the intensity of the center pixel of the grains; the size value is derived using the size of contour, and it varies in the range of 3-9 mm for our case.The weight value corresponds to a 1 litre volume of grain.
The proposed adaptive neuro-fuzzy inference system (ANFIS) uses a rule base to predict the quality of grain using three inputs.The structure of the fuzzy inference system is shown in Figure 6 and can be explained as follows: This can result in the form of many combinations using a rule base and a membership function.The rule base is trained using network training.
The ANFIS model consists of five layers, as shown in Figure 6.These layers serve different purposes, which are as follows: • Layer 1: This layer serves the purpose of fuzzification.It uses input membership functions (MFs) for input variables and converts them into the input for the next layer.Every node 'i' with a corresponding membership function µ i outputs the following: • Layer 2: This layer acts as the rule base.It takes membership values as input.Each node multiplies the input and outputs the value according to the rule.The output of this layer is • Layer 3: This layer is used to normalize the range of firing by the neurons.The ratio of every node strength (W i ) to the sum of strengths of all node strengths is used to denote it: where W i is the firing strength of the i neuron.• Layer 4: This layer is also called the defuzzification layer.It calculates the parameter functions for the previous layer's outputs.The output of this layer is the summation of all incoming outputs from previous cells: where (p i size + q i weight + r i colour + s i ) is the parameter set.• Layer 5: This is the output layer.The output node calculates the whole output as the sum of all input signals.It is stated as As shown in Figure 6, all three inputs are converted to their respective fuzzy values.The first input is color since the quality of paddy moves from bad to good with a change in color from brown to yellow.We used the ZMF (Z-shaped membership function) membership function to gauge the brown color from 0 to 0.7 and the yellow color from 0.7 to 1. Using these two membership values, we can more accurately describe the color of the paddy grain: the amount of yellow and brown noticed in a paddy grain.The membership function is defined as where 'a' and 'b' are the maximum and minimum ranges of the input parameter.The second input is size.We used the scaled grain's diameter (D) parameter as a size metric.As there is a minimum of a 3 mm diameter for the paddy grains, we considered a range of 3-9 mm for the paddy grains.We again used a ZMF for converting the size metrics.The third input is weight.It was noticed that 1 L of paddy grain usually has 1002 g fora 10% moisture content and 1005 g for an 18-22% moisture content.In the same way, the weight value is converted to the respective fuzzy value using the ZMF.
The training of the ANFIS model was performed using a hybrid method: a combination of the steepest descent algorithm and least square method using backpropagation as shown in Figure 7.The convergence of the error is easily achieved in hybrid models.In Figure 7, it is clearly shown that the error convergence is smooth in hybrid mode but backpropagation is abrupt in nature.
The ANFIS uses two different criteria for tuning.It uses first-layer tuning and consequent parameters in the fourth layer.These parameters are untouched during training until the required response is being achieved.This can be written as where W 1 and W 2 are the respective firing weight parameters for both training criteria.

Database and Connections
The proposed system includes two databases for farmers; one is at the procurement center level, and the other is at the global agriculture database.The local database stores identity information about the farmer and quality information about the grain.This information is being used to update the information in a global database, which is used to arrange equivalent remuneration for the procured grain.
The procurement center unit and the raspberry pi-based system are connected on a local network and provide a quick response to the system even in remote areas.The connection between the local and global server is achieved using the internet, which is not desired every time.The local system connects to the global system to update the information for every season.

Analyzing the Changes in the Moisture and Weight of Paddy Grain
Table 2 shows the changes in moisture and weight in 1 liter of all paddy grain.After all the readings were collected, we observed that the paddy weight does not increase with a 6-7% increase in moisture.After a certain limit, if the paddy has a moisture content above 25%, then a significant increase in weight is observed.Figure 8 compares the change in weight with the increase in moisture content for Ranjit paddy grains.We utilized the property of a sudden increase in weight after about 25% moisture content to distinguish between low-moisture and high-moisture grain.

Performance of ANFIS-Based Paddy Grain Quality Assessment Model
The neuro-fuzzy model was trained on a paddy grain image dataset [49].We used a custom dataset consisting of 140 samples.We used 126 samples for training and 14 samples for testing the model.The prediction ability was tested on the neuro-fuzzy model using 'backpropagation' and 'hybrid' approaches.The model was trained for 100 epochs for each method, and two membership values were used for each input.The evaluation was performed using the model's average testing error and classification accuracy.The mean squared error criterion was used for the error computation: Accuracy was calculated as the ratio of correct predictions and total predictions: where TP denotes the proportion of HQ paddy grains that were correctly identified as HQ; TN, the proportion of LQ paddy grains that were correctly identified as LQ; FP, the proportion of LQ paddy grains that were incorrectly identified as HQ; and FN, the proportion of HQ paddy grains that were incorrectly identified as LQ.
In Figure 9, it is visible that the hybrid approach could successfully classify grain versus non-grain on all 14 test samples.The average testing error is 0.0007, which is far less than that of the backpropagation algorithm.We also tested classifying some random samples for real-time testing.The performance of the system also proved good for real time.Table 3 shows the performance results for the neuro-fuzzy model with hybrid learning.

Rule Base Extraction
The fuzzy inference model was trained using a combination of the hybrid and backpropagation methods, with the hybrid approach proving to be more precise in classifying grain quality.To gain insights into the model's behavior with changes in input variables, we conducted fuzzy rule extraction.This process enabled us to comprehend how the model makes decisions based on varying inputs.The extracted rules, as presented in Table 4, reveal that all three input variables influence the output in different combinations.Notably, our observations indicate that the weight factor plays a crucial role in predicting grain quality.Specifically, smaller-sized grains tend to exhibit higher moisture content compared to larger grains, while grains with a peach coloration are generally preferred.This understanding enhances our ability to interpret and refine the model, ultimately improving its accuracy and utility in real-world applications.

Assessing the Performances of Other ML Classifiers
The fuzzy-inference system proved good for classifying the quality of paddy grains.We tested other machine learning techniques such as an SVM (support vector machine), Naive base, logistic regression, and K-NN.We found three variants of the SVM that were most suitable for our application: SVM 1 with a soft margin (c = 50, α = 0.3, kernel = RBF), SVM 2 with a soft margin (c = 30, α = 0.3, kernel = RBF), and SVM 3 with a hard margin (α = 1, kernel = Sigmoid).In the same way, LR (logistic regression), MNB (multinomial Naive Bayes), BNB (Bernoulli Naive Bayes), GNB (Gaussian Naive Bayes), and KNN (Knearest neighbor) with k = 3 were tested.These methods were tested for different train test ratios as needed.A quantitative comparison is shown in Table 5 for all the techniques.Different combinations of the SVM, logistic regression and KNN achieved a good accuracy in classification.Still, our proposed solution using neuro-fuzzy logic achieves a better accuracy, and this model is explainable also.The explainability of the model in terms of extracted rules makes it a reliable solution for a layman or a farmer.
Furthermore, we tested the skill score for each method.It can be expressed as follows: where P M is the accuracy of the tested classifier, and P r is the accuracy of the persistence classifier (Naive Bayes).In Figure 10, the skill score for each model is compared.Figure 10 presents the skill scores of the proposed paddy grain quality grading method based on the ANFIS and other ML techniques.Our proposed method using thhe ANFIS has the best skill score compared to that of the persistence classifier.The variants of the SVM have a comparable result, but they suffer in terms of explanation.

Real-Time Performance
This system was tested at ARM-mill, Nepal, for the evaluation of some samples of paddy grain.The testing was conducted in the presence of mill experts.The overall evaluation time consisted of several processes, from sample uploading to the unloading of the machine.The processes of weighing and image processing were controlled through a Raspberry Pi [50] Computer with 1 GB of ram.The processing time for the weight and image information was less than a second, which supports the selection of the device.It was not easy to calculate many systems' performance parameters due to the system's complexity, but per expert reviews, it is a good solution for real-time paddy analysis.

Conclusions and Future Work
This paper introduced an integrated system for the real-time monitoring and quality assessment of paddy grain, leveraging low-cost IoT sensors such as a camera strain bar for weighing and a Raspberry Pi sensor for system governance.Beyond its immediate application, the broader implications of utilizing IoT devices include considerations such as connectivity limitations, device reliability, and protocols, which impact system scalability and robustness.Additionally, while the proposed machine learning-based classification algorithm demonstrates high accuracy (98.58% on test data), ensuring the explainability of more advanced AI approaches is crucial for building trust and facilitating wider adoption.Potential barriers to scaling up this approach include data collection challenges, interoperability issues, and the need for standardized protocols.Moreover, increasing the sample size may potentially alter the results, necessitating careful consideration in future implementations.Moving forward, this solution holds promise for widespread use in both public and private procurement centers, with future directions focusing on extending its applicability to other grains and integrating automation for enhanced process efficiency.

Figure 1 .
Figure 1.Examples of paddy grains are from the states of Jharkhand, Bihar, India, and Nepal.These paddy varieties have different morphological structures in terms of length and width.

Figure 2 .
Figure 2. Centres for dataset collection.The dataset was collected at two centers in Jharkhand state (1 and 2), one center (mill) in Bihar state (3), and two centers in the country of Nepal (4 and 5).These centers were either procurement centers or rice mills.

Figure 3 .
Figure 3.This setup was used for the image capturing of scattered paddy grain.It consists of a rigid frame with an overhead position for mounting the camera.It consists of a horizontal white tray for scattering grains.

Figure 4 .
Figure 4. Schematic of the flow of the process in the proposed system.The produce from the farmer is collected at the procurement center.It is separated into two portions.One portion is used for weighing (moisture analysis), and another for image processing based on a feature extraction and adulteration check.Features extracted from both portions are then used in a fuzzy inference system to classify the grain quality.All the sensors are controlled through a Raspberry Pi device, which is connected to the server of the procurement center.The quality information for the grain is added to the farmer database and updated on the global server for further actions.

Figure 5 .
Figure 5. Processes involved in image processing.It converts the color image to grayscale, and the flood fill process fills the background area with color and leaves the region of interest.The flood-filled image is then inverted to identify the presence of grain particles.The contouring process counts and locates the grains in the image.

Figure 6 .
Figure 6.Neuro-fuzzy network.Input-size value, color value, and weight value.Output-highquality grain or low-quality grain.It converts each input into two fuzzy values used for decision making using a rule base.The whole network is trained using the hybrid method of training.In our dataset, all three inputs have a different range of values, which are as follows: • Color: 0-1; • Size: 3-9 mm; • Weight: 1000-1010 g.
Size is Large or Small and Colour is Peach or Brown and Weight is High or Low, then Grain is Good or Bad (3)

Figure 7 .
Figure 7. Training of the ANFIS.Two methods are used for training and updating the weight of the network: (right) hybrid and (left) backpropagation.

Figure 8 .
Figure 8. Moisture versus weight variation for Ranjit grain.Initially, the grain weight increases slowly with the change in moisture content, but after a threshold (∼20%), it increases rapidly.

Figure 9 .
Figure 9. Classification result on the test set: (left) hybrid and (right) backpropagation tested on test samples.Red points are predictions, and blue points are target values.

Figure 10 .
Figure 10.Skill scores of the proposed paddy grain quality grading method based on the ANFIS and other ML techniques.

Table 1 .
Specification of each grain sample in the dataset.

Table 2 .
Variations in weight of all grains with the change in moisture content.

Table 3 .
Performance evaluation of the proposed method (neuro-fuzzy with hybrid learning).

Table 4 .
Extracted rules of the proposed approach.P, B, SS, LS, L, H, LQ, and HQ stand for peach, brown, small size, large size, low, high, low quality, and high quality, respectively.

Table 5 .
Comparing the proposed ANFIS-based paddy grain quality assessment approach with other methods.