1. Introduction
India is the leading exporter of the basmati rice (
Oryza sativa) to the global market. The annual export of basmati rice was ∼4.05 million MT to the global market during the year 2015–2016 [
1]. Basmati rice is a protracted slender grain variety of aromatic rice grown in the Indian sub-continent. It has a high product value due to its flavour, delicate texture, delightful fragrance, and softness. The length of basmati rice grain is longer than the width, and it grows even longer during cooking [
2].
The high-value basmati rice grain has to go through several operations (such as threshing, handling, de-husking, milling and whitening of grains) starting from harvesting of paddy to final production of rice grains by means of several mechanical systems [
3]. Thereby, the grade of the produced grain exclusively depends on the adjustment of the equipment used in the various mentioned operations. In general, in a rice milling facility, the quality grade of product is being monitored by visual inspection by experienced quality control personnel at 2–3 h intervals, rather utilizing a continuous operational measurement method. This means that the operator, based on his experience and proficiency with the processing machinery, assesses the quality grade of the product by mere visual inspection of rice grain appearance and making the required adjustments which are time-consuming and subjective.
Alternatively, image-based grading approaches are nondestructive and rapid. With suitable statistical or machine learning techniques, the image-based approaches are proven to be an efficient way to achieve automatic inspection and grade evaluation efficiently [
4,
5]. During last decade, researchers have investigated several techniques based on machine vision and digital image processing for quality assessment of rice kernels which are fast, non-destructive, accurate, and cost-effective as compared to traditional methods [
6,
7]. Image-based approaches have been applied for characterizing rice grains using either one of the morphological, colour, and textural features, or a combination. However, in order to find suitable rice grain descriptor and to improve the classification accuracy, it is imperative that some key features should be selected to describe grain feature exactly.
The marketing value of rice depends on its physical qualities after processing. Major axis/minor axis ratio of the rice kernel is reported as a key feature of basmati rice which might identify the adulteration of basmati rice with other rice varieties [
8]. Vaingankar and Kulkarni [
8] reported the major axis/minor axis ratio of 3.92–4.09 as an indicator of pure Basmati-370 variety. In the context of grading of rice, the percentage of the head or whole grain and broken grain is a most important factor which determines the milling efficiency. Till date, several studies reported improvement in classification accuracy of rice grain using machine vision and image processing techniques [
9,
10,
11,
12].
Pazoki et al. [
13] illustrated that determining grain variety using a simple mathematical function is difficult because the grain has various morphologies, colours, and textures. Alternatively, artificial neural network (ANNs) techniques have been applied for grain quality control and discrimination of grain variety. Chen et al. [
14] proposed a methodology to identify five corn varieties with the accuracy of more than 90% using pattern recognition techniques and neural networks. In a comparative analysis in [
11] of artificial neural networks, support vector machines, decision trees and Bayesian Networks to classify milled rice samples, it has produced highest classification accuracy with ANN. Despite promising results, there are several problems might arise with ANN’s training and designing [
15,
16,
17,
18]. The assignment of the weights in ANN structure is one of the most important problems [
19] which has a direct effect on its performance. Moreover, the uncertainties in ANN output is proven to be a challenging issue [
20].
ANN optimization is limited in practice by a finite training sample and is accomplished through a stochastic training process which gives ANN the ability to avoid being trapped at local minima. On the contrary, this stochastic process makes ANN optimization empirical and subject to strong influence from statistical variations [
20]. To overcome these issues with ANN, a hybrid approach with the fuzzy system has introduced. Fuzzy systems are quite good at handling uncertainties and can interpret the relationship between input and output by producing rules. Therefore, to increase the capability of Fuzzy and ANN, hybridization of ANN and fuzzy is usually implemented. Sabanci et al. [
21] used ANFIS for wheat grain classification with 99.46% of classification accuracy. Zareiforoush et al. [
22] coupled a fuzzy inference system (FIS) with image processing technique for a decision-support system for qualitative grading of milled rice. The results are reported with 89.8% agreement between the grading results obtained from the FIS system and those determined by the experts.
In the context of rice grading, some head grains are easily misclassified with broken grain due to the resemblance in single feature (e.g., eccentricity) extracted from digital images and are not deterministically separable. In such cases, fuzzy approach [
23] is more convenient for discrimination of head and broken rice grains [
24]. Shiddiq et al. [
25] investigated the rice milling degree using colour features (RGB) with an adaptive network-based fuzzy inference model. It was reported an error of 3.55–5.62% in milling degree using this process. However, the morphological features can improve the efficiency in terms of classification. In this context, a grading system based on fuzzy rules can simulate the behaviour of an expert in the evaluation and classification of physical properties of rice grains for grading. In this present work, the predictive capacity of ANFIS is assessed for quality testing and identification of basmati rice based on morphological features. This has been motivated by the fact that well-documented knowledge regarding rice kernels are usually available [
26,
27]. This knowledge has been incorporated in forming the rules of the fuzzy inference system used to determine head and broken rice kernels. Moreover, the proposed ANFIS based classification method provides a rationale behind the knowledge of morphological features and their underlying dependencies with rice grains. Subsequently, the milling efficiency is estimated with broken grain and head grain ratio for test images. Furthermore, the proposed classification method is compared with standard data-driven machine learning techniques viz., support vector machine (SVM) and k-nearest neighbour (KNN) classifier.
The rest of the manuscript is organized as follows:
Section 2 briefly describes the materials and methods.
Section 3 explain in detail the results and finally the work is succinctly summarized and concluded in
Section 4.
2. Materials and Methods
The schematic workflow of the proposed ANFIS based grading of basmati rice grains is given in this section. Subsequently, the steps involved in the technique are detailed in the following subsections.
2.1. Sample Preparation
Basmati rice grains of different grades (Pusa basmati 1121), were used in this study. This variety of basmati rice possesses extra-long slender milled grains (∼9.0 mm), pleasant aroma, and an exceptionally high cooked kernel elongation ratio of ∼2.5 [
28]. It is the most common Basmati rice variety in rice grain quality research for developing standard Basmati quality traits. The grades of the rice sample are based on the percentage of broken rice content (e.g., 5% broken rice).
The rice grain samples can be taken as heaped together or in a scattered arrangement for imaging. These arrangements are important which is likely due to the fact that the grain characterization method employs the visual attributes of grains obtained from image-processing techniques. Thus, the heaped grain images might attain certain disadvantages e.g., boundaries of grains not completely visible and distinguishable and noise appearing more prominent than the boundaries if grains are overlapping with each other [
21]. Thereby, it is desirable to take samples in a scattered arrangement with a black background (it can improve the contrast of the image in the scattered configuration). Furthermore, it should be ensured that not too many rice grains are clustering in scattered configuration.
2.2. Imaging System and Image Acquisition
A schematic diagram of the image acquisition system is shown in
Figure 1. Typically, a vision system consists of the illumination component to illuminate the sample under test; the camera to acquire an image; personal computer or microprocessor system to provide disk storage of images and computational capability.
In an image acquisition system, choosing the right lighting strategy remains a difficult problem because there is no specific guideline for integrating lighting and machine vision application. Despite this, some rules of thumb exist [
29] which suggest that fluorescent bulbs are inherently more efficient and produce more intense illumination at specific wavelengths. Moreover, the fluorescent light provides a more even, uniform dispersion of light from the emitting surface [
30]. A 25–40 kHz ring-shaped compact fluorescent light is used for illumination in this setup. Apart from the illuminant, the surface geometry is also important in the illumination design. In this present work, a diffuse illuminator is used to produce uniform lighting as shown in
Figure 1. Such a setup is extremely useful for visual inspection of grains and oilseed with a success rate almost reaching 100% [
31].
The system was enclosed in a dark chamber to prevent exposure to stray light. The digital camera (Canon EOS 1300D) was set in the manual mode for image acquisition with an ISO of 400 and a shutter of 1/30 s. The images were taken with a black background for basmati rice sample with different orientation and quality in a scattered arrangement for training and testing. Camera aperture and focus were adjusted to make individual grain boundaries distinguishable in the picture. A total of 40 images were acquired and saved in raw format, in which no adjustment (e.g., white balance) was applied.
2.3. Image Processing
The image processing was carried out with MATLAB to acquire the feature data. At first, the acquired RGB image was separated in single R, G and B channel in grayscale mode. Subsequently, each channel grey image was converted to a binary image using Otsu’s method [
32]. This method converts the grayscale image to a binary image based on image clustering in accordance with a threshold value. This threshold value is optimally determined between 0 and 1 by Otsu’s method. The grey level is normalized from 0–255 to 0–1. The method then splits the normalized image into two classes having lower or higher grey level than the threshold value. Each pixel is set to white (1) if the grey level is higher than the threshold value, otherwise, it is set to black (0). Thus, the image segmentation considers the identification of objects within an image using an edge detection algorithm which identifies the boundaries of individual object and labels the centre of each object for further processing. Eventually, each grain’s position is fixed and it is tagged according to its position through a segmentation process.
The noise of each image is then eliminated using a morphological process. It is followed by morphological opening operation [
33] were applied with ‘disk’ type structuring element using ‘imopen’ function followed by hole filling and clear borders. Morphological opening operations generally smooth the objects of the image. Opening operation eliminates thin protrusions of the objects. Opening operation eliminates the objects which cannot accommodate the structuring element completely. Thus it removes the noise from the image. Then, each object was labelled followed by counting the objects.
Feature extraction involves the retrieval of quantitative information from the segmented images. Here, extraction of parameters e.g., eccentricity, equivalent diameter, area, perimeter, major axis length and minor axis length have been carried out further with ‘regionprops’ function for differentiating head grain from broken grain. Aspect ratio i.e., major axis length/minor axis length was estimated from object feature set. The schematic processing chain is shown in
Figure 2. The similar operation was conducted for other training images of basmati rice sample and for the test image too. Feature dataset for training as well as testing was created from the object properties and object class (Whole grain = 1 or broken grain = 0).
2.4. Features of Basmati Rice
To physical properties of the rice kernel is characterised using the morphological features. Rice grains are generally considered as an ellipse as shown in
Figure 3. Based on this assumption of the object, the following morphological features as reported by Shantaiya and Ansari [
34] are considered for the present study. The devised features are also reported to be promising in [
35] as optimal morphological features for rice kernel identification using standard sequential forward (SFS) algorithm. These features are:
Major axis length: It is the total number of pixels between the extreme points along the major axis of the rice kernel.
Minor axis length: It measures the number of pixels between the extreme points of the along the minor axis of the rice kernel.
Perimeter: It is the total number of pixels along the boundary of rice grain.
Area: It is the total number of pixels in rice grain object.
Aspect ratio (): It is the ratio of major axis length and minor axis length of the rice grain.
Eccentricity: The eccentricity is calculated by a fraction of the number of pixels between the major axis length and foci of the ellipse containing the grain. The value of eccentricity ranges in between 0 to 1.
Equivalent diameter: Equivalent diameter of rice grains is calculated as,
These parameters were extracted with image processing techniques as discussed in
Section 2.3.
2.5. Fuzzy Inference System
A Fuzzy Inference System (FIS) incorporates the knowledge of an expert, during design a model in between input and output parameters. In FIS, the input-output relations are defined by a set of fuzzy rules, e.g., IF-THEN rules [
36]. Fuzzy logic-reasoning involves the assignment of membership function to the input and output parameters; and the rule base which processes the fuzzy values of the inputs to fuzzy values of the outputs. The accurate selection of these membership function and the rules is one of the most critical stages in the FIS which needs expert knowledge. FIS consists of three segments viz. fuzzification, inference engine and defuzzifier. Fuzzification converts the numeric value of the input to a linguistic variable with the help of the membership functions e.g., triangular, trapezoidal, Gaussian, etc. The inference engine evaluates the degree of the membership function of the input variables (premise) to the fuzzy consequent part using the fuzzy IF-THEN rules. The conditional statement contains a premise, the if-part, and a conclusion, the then-part [
37]. The knowledge involved in a fuzzy inference system contains a group of several rules [
38]. At last, the defuzzifier converts the fuzzy output into a crisp value. The fuzzy inference engine is the core of FIS which can represent the human decision-making process [
36].
The Takagi-Sugeno (T-S) FIS has fuzzy inputs and a crisp output which is a linear combination of the inputs or constant. This method is computationally efficient and suitable to work with optimization and adaptive techniques [
39]. The T-S method involves a systematic approach to generating fuzzy rules from a given input-output data set (
Figure 4). It uses a membership function of the input variables for producing the consequent (then part). It uses the fuzzy rule:
IF x is A y is B THEN z is where
, and
z are linguistic variables,
A and
B are fuzzy sets and
is a mathematical function [
39]. T-S FIS uses a weighted average to generate the crisp output.
In this present work, zero order T-S was adopted for grading of basmati rice. The membership functions were taken as ‘gbellmf’ [
40] for all inputs viz. eccentricity, equivalent diameter, perimeter and the major axis length/minor axis length (
); the outputs were taken as constant (for whole grain, output = 1 and broken grain output = 0). An example of fuzzy membership function is shown in
Figure 5. The rules of the T-S method were taken as follows:
Rule 1: If (eccentricity is high) and (equivalent diameter is high) and (perimeter is high) and ( is high) then (output is Whole grain).
Rule 2: If (eccentricity is low) and (equivalent diameter is low) and (perimeter is low) and ( is low) then (output is broken grain).
2.6. Adaptive Neuro-Fuzzy Inference System (ANFIS)
The adaptive neural network based fuzzy inference system (ANFIS) is a hybrid system. It includes both the advantages of the self-adaptability and learning competence of the neural network and the ability of the fuzzy system to take into account the prevailing uncertainty and imprecision of real systems. The neuro-fuzzy modeling approach is concerned with model extraction from numerical data which represents the dynamic behaviour of the scheme. With ANFIS method, an initial fuzzy model is generated with the help of the rules extracted from the input-output data. Next, the neural network is used to tune the rules of the initial fuzzy model to produce the final ANFIS model. The formulations and discussion of ANFIS architecture can be found in [
41,
42]. Unlike ANN, it has a higher capability in the learning process to adapt to its environment. Therefore, it can be used to automatically adjust the membership function’s parameters and reduce the rate of errors in the determination of rules in fuzzy logic.
The ANFIS architecture shown in
Figure 6 is an adaptive network that uses supervised learning algorithm and has a function similar to the model of Takagi-Sugeno fuzzy inference system as discussed in
Section 2.5. Let’s assume that there are two inputs
x and
y, and one output
f of the architecture. Two rules are used in the method of “If-Then” for Takagi–Sugeno model, as follows:
where , and , are the membership functions of each input x and y (premises), while , , and , , are linear parameters in the consequent part of Takagi–Sugeno fuzzy inference model. ANFIS architecture has five layers. The first and fourth layers contain an adaptive node, while the other layers are fixed nodes.
Layer 1: Each node adapts to a function parameter. The output from each node is a degree of membership value that is given by the input of the membership functions. For example, the membership function used in this study is a generalized bell membership function (c.f.
Section 2.5).
where
is the degree of membership functions for the fuzzy set
, and
are the parameters of a membership function which can change the shape of the membership function as shown in
Figure 5.
Layer 2: Each node in this layer is fixed or non-adaptive and represented with a product operator . Each node in this layer represents the firing strength for each rule.
Layer 3: Each node in this layer is fixed or non-adaptive and labeled as N. It is normalizing the firing strength as .
Layer 4: Each node in this layer is an adaptive node with a node function defined as . The parameters in this layer are referred to as consequent parameters.
Layer 5: The single node in this layer is a fixed or non-adaptive node that computes the overall output as the summation of all incoming signals from previous nodes as .
In the ANFIS architecture, the first layer and the fourth layer contain the parameters which are tuned during the training phase. The number of training epochs, the membership functions and the number of fuzzy rules should be selected accurately while designing of ANFIS model [
41], as it may lead system to overfit the data. This tuning is obtained with a hybrid algorithm combining the least-squares method and the gradient descent method with a mean square error method [
44]. The training error, as well as test error, are also assessed using the rice grain sample data. A threshold was applied to the output of ANFIS to get a binary class of whole grain or broken grain.
2.7. Design of Experiment
The features (c.f.
Section 2.4) were obtained form all the basmati rice sample images (in total 40 images) as discussed in aforementioned Sections. Among them, features obtained from 30 images were used to train the ANFIS and features derived from the remaining 10 images were used for testing. Subsequently, the classification accuracy was estimated with actual class of test data and ANFIS output results. Furthermore, the performance of ANFIS was compared with standard classification techniques of support vector machines (SVM) and K-nearest neighbours (KNN). The optimal margin and kernel parameters (radial basis function) for the Soft-margin SVM classifiers were determined using grid search and 10-fold cross-validation. Each image contains ∼15 rice kernels (objects). However, for representation we have kept only 1 image and have shown all image processing steps involved in result section (c.f.
Section 3).
Furthermore, the effectiveness of morphological features was analyzed for a segmented test image (for each object). The histograms of individual feature can provide a rationale by relating the features to the physical properties derived from an image based technique associated with the grain class. In addition to the classification accuracy assessment, the milling efficiency (the ratio of broken grain and whole grain) was assessed using the broken grain and whole grain objects derived from a test image.
4. Summary and Conclusions
Standard classification technique seldom incorporates domain knowledge associated with the physical properties of rice grain. Hence, a knowledge-based neuro-fuzzy classification technique was proposed in this study for grading of basmati rice grains. This technique takes into account the physical properties of grain devised from an image-based method to classify whole and broken grain.
A novel image processing technique was adopted for morphological feature extraction followed by ANFIS model building for discrimination of grains. The classification accuracy for the test images were >98.6%, which comparatively better than standard SVM and KNN classifier (<95%). Moreover, the proposed ANFIS classification results seem to be more reliable than the results obtained from SVM and KNN, since it deals with uncertainty in output. It is important to note that the standard technique does not take into account any domain knowledge associated with grain physical properties. In fact, the physical properties are essential for grain grading and characterization as analyzed in this study.
The milling efficiency was estimated in terms of percentage of whole grain or head grain and it was 77.27% for the test sample. However, the colour and texture based quality and grading was not considered during feature selection. The overall results of the adopted methodology were promising in terms of classification accuracy and efficiency. This work can be extended to discrimination of different rice varieties for determining the degree adulteration. Furthermore, the real-time image processing based grading can be addressed equally. This can be extended for optimization of milling machine parts characteristics during milling operation (roller parameter-speed, the gap between rollers) for process automation using micro-controller units.