An Efficient Quality Inspection of Food Products Using Neural Network Classification

Abstract Currently, there is a necessity for the expansion of precise, rapid, and intentional quality assurance with respect to the character of food and horticultural food items, because it is difficult to maintain and organize food products in an elevated quality and secure manner for the increasing population. In this article, we propose a procedure to resolve difficulties and to categorize food as either a broken or quality product. Therefore, the proposed process encompasses four segments, such as preprocessing, segmentation of broken division, feature extraction, and classification. At the first stage, the preprocessing method is used to remove all unnecessary noises. After that, modified region expansion-related segmentation is undertaken to segment the broken division of the food product. Then, feature extraction is used to remove the distinctive attributes of each food product to categorize their evaluation. Finally, the neural network classification procedure is used to examine the food quality. The proposed method is executed in the operational platform of MATLAB, and the consequences are examined by using obtainable methods.


Introduction
Quality is important for the satisfaction of the customer, more than providing supplementary products of an identical kind. The customer is one of the significant parts of product quality decision [8]. Also, quality can be distinguished as the summation of the entire attributes in the manufacture of products that are satisfactory to the customer [14]. Recently, importing countries are gradually increasing the quality of some products. It involves not only securing the domestic seafood market but also protecting the quality of food from other countries [15]. Exterior quality mainly indicates the direct sensory quality of agricultural products. Generally, the exterior quality of fruits and vegetables are estimated based on their color, texture, size, shape, and visual faults [2]. In food manufacturing companies, the supervisors are not only concerned about the amount of production and profits but are also subjectively aware of the eminence of their product, the exterior social surroundings, and the difficulties that farmers face in their agricultural tasks [16].
Food industries possess computerized visual examination systems to diminish function expenditure and augment product eminence control [5]. The augmented knowledge and complexity of customers produce enhanced eminence in consumer food products [9]. The proposed method in this study consists of image acquisition, image preprocessing, and image interpretation for image investigation, which directs to quantification and categorization of images [7,11]. To meet the requirement of an increasing populace, technical expansion is progressively needed in the areas of agriculture and food [14]. In food product manufacture, color machine vision systems are used to evaluate the actual color of palm oil, fresh fruits, or beef; to recognize melanin spots in Atlantic salmon fillets; to evaluate the red color of grapefruit juice; to recognize the precise color attributes in food processing; and others [10]. Some of the conventions in the assessment of imported foods and related products are established by the Bureau of Standards, Metrology, and Inspection and the Taiwan Food and Drug Administration [4].
Hyperspectral and multispectral computer vision systems are equipped with dominant tools to identify faults that are unfeasible or complicated to identify using the conventional computer vision systems by reason of the dominance of spectral images. Nevertheless, there are numerous challenges to overcome to perform the fault recognition more quickly and precisely in sequence. Some of the challenges are stem-calyx identification, the irregular allocation of precision on a curvature surface, entire surface assessment, the time-consuming process of attainment and processing of the spectral image, competent wavelength choice for dissimilar function, dissimilar fault discrimination, and others.
The requirements of precise, quick, and intentional quality control of food products are expanding by means of augmented potential in food products and protection principles. Generally, computer vision offers a computerized, non-destructive, and expenditure-effectual procedure to meet these necessities. A computer vision system is a systematic device developed for industrial and agricultural use for enhanced production, constant enhancement in expenditure, accessibility, and algorithmic sturdiness. The conventional computer vision system is a dominant tool for the examination of color, texture, size, shape, and comparatively noticeable faults; however, it has less effectiveness in identifying faults. Therefore, the requirement for explaining such disadvantages prompted the authors to accomplish this work.
The contributions of this paper are as follows: -A modified region growing (MRG) segmentation module is proposed to segment the broken division of food products. -A feature extraction module is used to remove the distinctive attributes of each food product.
-The proposed artificial neural network (ANN) classifier is used for ranking the food products.
-The proposed approach is implemented in the platform of MATLAB.
-The performance of the proposed approach is improved in terms of sensitivity, specificity, and accuracy.
-The remaining parts of this paper are organized as follows. Section 2 illustrates the related works where our proposed method was based. Section 3 offers the obtainable difficulty and the explanation about using our proposed method. Section 4 gives the simulation results with the performance metrics based on the proposed and existing methods. Finally, Section 5 summarizes the conclusion of our proposed method.

Related Works
Calvo et al. [3] have presented a framework that uses computer vision and inductive characterization with a reduced set of features, along with three cases where this framework has been successfully applied to improve the quality inspection process. Three different basic food products were studied, namely Hass avocado, Manila mango, and corn tortillas. These products were very important in economical terms for the sheer volume of their production and marketing. Each product has particular characteristics that involve different ways of handling the quality inspection process, but the presented framework allows addressing common key points that allow automating this process. Wang et al. [13] have developed an improved food traceability system that could not only achieve forward tracking and diverse tracing like other systems do, but also evaluate food quality timely along the supply chain and provide consumers with the evaluation information, to mainly enhance the consumer experience and help firms gain the trust of consumers. For the food quality evaluation, the method of fuzzy classification was used to evaluate the food quality at each stage of the supply chain, while ANN was adopted for the final determination of the grade of food quality according to all stages of quality evaluation. Narendra and Hareesh [12] have offered the current expansion and function of image investigation and computer vision system in the quality assessment of products in the areas of agriculture and food. It is necessary for the fundamental perception and equipment related to the computer vision system because this device is employed for image investigation and computerized categorization and ranking. The effectiveness and the appropriate evaluation progression are significant to augment the efficiency in the agricultural industry. The agriculture industry is enhanced greatly, mainly in expressions of fruit ranking. The evaluation of the fruit is used to develop the eminence of fruits, because high-quality fruits are exported to other countries and engender a large profit.
Dubey and Jalal [6] have introduced and validated an image processing-based apple fruit disease classification approach. The presented approach comprised four steps. The K-means clustering-based defect segmentation method was used in the first step for region of interest extraction. In the second step, stateof-the-art color-, texture-, and shape-based features were drawn from the segmented apple diseases. The different types of features were combined to form the more distinctive feature in the third step. In the last step, the training and classification were done using a multiclass support vector machine.
Al-Marakeby et al. [1] proposed a vision-related categorization system to augment the eminence of food products. The categorization progression relies on detaining the image of the fruit or product and examining this image to remove the faulty products. Signals send computer-interfacing cards to organize the categorization gates. Four dissimilar systems for dissimilar food products are enhanced, like apples, tomatoes, eggs, and lemons.

Proposed Food Quality Grading Method
The quality of food product is very significant to human health. The preferred quality is diminished because of the large populace and the augmented necessities of food products. In the manual method, organizing tons of fruits and vegetables is slow, expensive, and inaccurate; however, computer vision is fast, profitable, and constant where an intention analysis procedure is applied to numerous diverse industries. Due to the expansion of complete computerized progression, the speed and exactness meet the manufacture and quality requirements. Automation is an action that is used to manage a progression at the best effectiveness. Moreover, it handles the system with an instruction that is programmed into it. The automated grading system accelerates the time of progression and also diminishes the faults of the system. Therefore, this food quality examination process is derived from image analysis that carries out diverse functions in the food industry.
The overall architecture of the proposed food quality grading technique is given in Figure 1.

Outline of the Proposed Method
The steps involved in the proposed method are given as follows: Feature extraction -Color histogram features -Gray-level co-occurrence matrix (GLCM) features (iv) ANN Each stage in the proposed method is detailed in the following sections.

Preprocessing
In the beginning, the preprocessing method is used to reduce the unnecessary noise elements that complicate the computation. The preprocessing method is conducted by way of RGB (red, green, blue) to gray level image renovation method with the histogram equalization method, where the contrast of the image is augmented.

a. Histogram Equalization
In this segment, the histogram equalization procedure augments the image contrast. The histogram equalization process distributes the intensity values with the overall series of values to accomplish advanced contrast. An image is signified by means of closely contrasting values, like the background and foreground is bright or dark at the identical time, and this process is helpful. Histogram equalization is the conversion of gray level s to gray level t, where the circulation of gray level t is identical. In this conversion, the method enlarges the series of gray levels for the histogram maxima. The conversion also enhances the detectability of numerous image attributes because the contrast is extended for several image pixels.
The probability density function of a pixel intensity level Q m can be given by where 0 ≤ Q m ≤ 1, m = 0, 1, . . . , 255; p m is the number of pixels at intensity level Q m ; and pdenotes the total number of pixels. Now, the histogram can be derived by plotting pdf Q (Q m ) against Q m . At this time, a new intensity level r m is produced and defined as The consequence of contrast is altering the strength of each pixel based on its local region. The image encompasses a great dissimilarity of strength among the maximum and minimum strength levels, and then the image contains high contrast. Therefore, the region of local contrast obtains a superior contrast that does not disturb the universal contrast in the histogram equalization image. Then, images are provided for attribute removal progression to augment the image contrast.

MRG Segmentation
The region growing segmentation is generally placed at a starting position, which is developed in the order of the starting position from the adjacent pixels through the intensity limitations. A threshold value is predefined for this intention. Additionally, the development of the region fulfills the threshold. However, the standard region development method has some drawbacks.
a. Drawbacks of Region Growing -It is based on noise addition or alteration of intensity values, which may provide holes or oversegmentation. -Moreover, the dimness of actual images is complicated to discriminate. -The calculation overrides the time or power.
The flowchart of the MRG technique is given in Figure 2.
In the region growing algorithm, the choice of a starting position is a fundamental process that concerns the segmentation consequences. In the fully mechanical method, the region growing algorithm chooses a starting position by using the information of a histogram. In our proposed process, customized region growing is established to conquer the disadvantage of the standard region growing process. Thus, the customized region growing process is identical to the standard region growing process. However, the block alteration and the choice of starting position discriminate the conventional region growing algorithm. At this point, the choice of starting position is determined by the greatest intensity value that is acquired from the histogram of images.

b. Steps Involved in the MRG Segmentation Method
The process of the proposed MRG segmentation technique is specified below.

i. Image Block Conversion
In the initial process, image blocking is used to separate the food images as identical blocks for progression. The blocks are produced to create precise dimensions. The quantity of blocks is derived from the necessity. The grids contain 4, 18, and 24 blocks. At this point, the 4 × 4 blocks are prepared for investigation and each block is generated in a discrete manner. Therefore, a 4096 quantity of 256 × 256 blocks is generated for the input image.

ii. Plot Histogram
The histogram H is obtained for each pixel position in each 4 × 4 block.

iii. Initialize Seed Points
The greatest intensity pixel is established from the histogram for each block. The greatest intensity pixel is the starting position S.

iv. Set Threshold (T)
The threshold value is predetermined and region growing is prepared by fulfilling the thresholds in adjacent pixels.

v. Euclidean Distance Calculation
Afterward, the progression of region growing is carried out by developing the cluster that obtains the adjacent pixels in the order of the preferred starting position. In the block, the detachment among pixels is calculated by using the starting position. The Euclidean detachment measure is exploited for the detachment assessment. In this computation, development of the region is made in the region of the starting position when the value of detachment gratifies the threshold. The Euclidean detachment among the starting position pixels and its adjacent pixel are estimated in the following equation: where (sm , s p) and (nm , n p) are the pixel coordinates of seed point and its neighborhood pixel.

vi. Region Growing Constraint
The limitation (Dist mp ≥ T) checks the adjacent pixels for the period of regional development in the order of the starting position. The detachment value is better than or identical to the threshold, and the region is created in the order of the starting position.

vii. Iterative Step
Reiterating the above step (ii) to step (vi) for the entire blocks, up to 4096 segments are created.

viii. Image Pruning
When the progression of segmentation is finished, we obtain a number of segmented output images of (4 × 4) dimensions (i.e. 4096 segments). In these segments, the blocks that include no helpful information are eliminated. Only 10-15 blocks will be selected for each food image from this consequence. At last, the color values are loaded at every block.

ix. Termination
This is the final step, which concludes the progression. The segmented images are provided for categorization for detecting the faulty product. Some typical attributes are removed for the exclusive class of images.

Feature Extraction
Subsequently, the definite texture-related and color-related attributes are removed from image segmentation, which is used for the image classification. The segment of a food product is established as faulty in classification, then the complete product is indicated as a faulty product. The texture attributes are removed through the exploitation of GLCM. Similarly, the color histogram attributes are acquired for the entire image segmentation regions.
By the GLCM matrices, 22 attributes are predetermined. Therefore, we take out 22 attributes for every color element of the RGB color images, which provide 66 attributes for each image. Moreover, the mean of color histogram attributes provides one attribute value. As a result, a total of 67 attributes are removed for each block.
a. GLCM Features GLCM is established by means of Haralick. It illustrates the texture through arithmetical illustration of how definite gray levels take place in association with further gray levels. The GLCM is a computation of a combined probability density function of gray level couples in an image.
Thus, the GLCM can be expressed as glcm (x, y); (x, y = 0, 1, 2, . . . , Z − 1), where Z is the number of pixels in the color image. The GLCM-related attributes contain autocorrelation, contrast, correlation, cluster prominence, cluster shade, dissimilarity, energy, entropy, homogeneity, maximum probability, sum of squares: variance, sum average, sum variance, sum entropy, difference variance, difference entropy, information measure of correlation, inverse difference, inverse difference normalized, inverse difference moment normalized, and others. Some of the definitions and equations of the most commonly used features are given below.

(i) Correlation
Correlation is used to estimate the linear addition of gray levels of adjacent pixels. Digital image correlation is a visual procedure that exploits the image alteration. Generally, it is utilized to estimate the deformation, displacement, strain, and optical flow, and is a typical function for evaluating the movement of an optical mouse. It is described in the subsequent equation: where mean (1) , mean (1) , and SD 2 1 , SD 2 2 are the mean and variance of x, y, given as glcm(x, y), glcm(x, y).

(ii) Contrast
Contrast is the conflict of gray level, which is the disparity among the greatest and the least values of a group of pixels. The GLCM contrast is consistently related by way of spatial frequencies. It is given by Eq. (6).

(iii) Energy or Angular Second Moment
The angular second moment is otherwise called homogeneity or energy. It represents the sum of squares of entries in the GLCM. It evaluates the image homogeneity and is found to be high when the image possesses excellent homogeneity or when the pixels are very identical.

(iv) Entropy
Entropy is the quantity of image information that is used to assist image compression (i.e. the failure of image information). Entropy also deals with arithmetical uncertainty. The image does not textually match numerous GLCM fundamentals; rather, it acquires irrelevant values, which specify that the entropy is remarkably great. Entropy is represented in Eq. (8):

(v) Homogeneity
Homogeneity is used to distinguish the circulation of the values on the transverse GLCM to the circulation of the values in the GLCM. Homogeneity is specified as With the GLCM attributes removed for the entire three color elements of the RGB color image, the color histogram attributes are also estimated.

b. Color Histogram Features
Color histogram feature is usually employed in the image processing procedure. In a color histogram, it is computationally very insignificant to estimate, because slight alterations do not concern the histogram in camera. In computer vision and image processing, numerous researchers are illustrating that color histogram is invariant to convert, revolving the image on the observation axis, tiny off-axis alteration, scale alteration, and incomplete occlusion. A color histogram is also incapable of altering the image and histogram resolution.

Input: RGB color image
Output: Feature vector Bin j (R, G, B) = [fR0, f R1 , . . . , f R7 , f G0 , f G1 , . . . , f G7 , f B0 , f B1 , . . . , f B7] and its mean Color plane separation: Decompose the RGB color image into its three color components, i.e. red (R), green (G), and blue (B). Plot the histograms from the color components R, G, and B. For each color component, compute the probability histogram as follows: where S(x j ) denotes the probability of (x j ) th intensity value of the range [0, I − 1]. Divide the probability histogram into y (<<I) number of non-uniform bins where the (j) th bin is computed by Here, the size of bin is set as (j = 8 Color Hist Feature (mean) = 1 24 For all the food products, the color histogram features are extracted using the above steps.

ANN
ANN is an information and computing process that is inspired by genetic neurons. ANN is broadly implemented in diverse areas of science and technology, and includes time sequence, model identification, and progression control. At this point, ANN categorization is used to examine the food eminence (as a damaged or quality food product), which is derived from the color histogram and GLCM attributes. Generally, ANN contains three layers, such as an input layer, hidden layer, and output layer. The input layer encompasses the current information of the network (i.e. the GLCM-related attributes and color histogram attributes of the broken and quality food product images). Moreover, the output layer provides the reaction of the specified input (i.e. the quality grades of the food products). The arrangement of an ANN is specified in Figure 3. The recent vast research activities in classification have established that the neural network is a promising alternative to various conventional classification methods. The objective of the neural network is to convert the inputs into significant outputs. The neural network was trained by using the back-propagation algorithm. The different combinations of functions and the effect of using ANN as a classifier is studied, and the correctness of these functions are analyzed for various kinds of datasets. The back-propagation neural network (BPNN) can be used as a highly successful tool for dataset classification with a suitable combination of training, learning, and transfer functions. When the maximum likelihood method was compared with the BPNN method, the BPNN was more accurate than the maximum likelihood method.

a. Back-propagation Algorithm
The back-propagation algorithm is established through the assessment of the output model to the intention model. The fault values are predetermined from the output components. The alteration of incoming weight is established by the input layer and crosses the hidden layer. The benefit of the algorithm is that it obtains accurate network weights and lessens the preparation faults of the categorization process.
Step 1 Consider that the primary value is a diminutive random value for each interconnection weight among the input to hidden and the hidden to output layers.
Step 2 Introduce the knowledge model combination (i.e. the input attributes of the preparation models and its result and intention through eminence and faulty label) and activate steps 3 to 5 by way of model combination. The preparation model is specified below: . .
where g 1 1 , g 1 2 , . . . , g 1 67 represents the set of features for the first training sample.
Step 3 Compute the output (i.e. quality and defective food image segments) of each network layer in the image, which is derived from the equation below: where From Eq. (14), o z is the productivity of the network from z th output node. bias z is the predisposition of output node z. w uz is the association weight among hidden and output nodes, and q u is the reaction of the hidden layer.
Moreover, w ru is the association weight among input and hidden nodes. bias u is the predisposition of hidden node u. g r is the input FFT-related attribute position.
Step 4 Calculate training error (δ) using the following equation: where o desired z is the target label and o output z is the network output label.
Step 5 The accurate weights of subsequent iteration [w(c + 1)] are derived from the back-propagation fault (δ), and the weight of the existing iteration is [w(c)].
From Eq. (17), ∆w(c + 1) is the rectification expression whose value is derived from the fault attained for the period of the existing iteration.
Step 6 Verify whether the productivity meets the exactness requirement of the preparation models and conclude the preparation progression.
The preparation progression is accomplished, and then the network is qualified to identify the faulty food images that are derived from its attributes. At this point, every dissimilar division of the food product is verified and ranked. The proposed food quality ranking process ranks the food product as an eminence product if all divisions of the image are not faulty.

Results and Discussion
This section provides the results and discussion about an efficient quality inspection of food products using MRG-based segmentation and ANN-based classification approaches. The proposed algorithm is executed using MATLAB software, and the experimentation is carried out using a system with 4 GB RAM and a 2.10-GHz Intel i-3 processor.
For analysis, the food images are collected from databases. These acquired data were preprocessed, analyzed, classified, and segmented for defect detection. In this experiment, the defective part of the image is identified with the help of MRG-based segmentation and ANN-based classification approaches. Therefore, the structure obtained for the existing method is illustrated in Figure 4. The input food images in the database are demonstrated in Figure 5.  In the database, the input images are preprocessed by means of RGB to gray level conversion and then the histogram equalization technique. The preprocessed output is shown in Figure 6.
The preprocessed image is segmented by means of MRG segmentation. Then, the image is divided into uniform blocks for processing and the seed point is grown from that point. Afterward, the similar segments are removed. The segmented portion of the food image is given in Figure 7.
The regions have grown from the segmented image, which is illustrated in Figure 8.

Evaluation Metrics
The assessment metrics are sensitivity, specificity, accuracy, precision, false-positive rate (FPR), and falsenegative rate (FNR). The standard count values are true positive (TP), true negative (TN), false positive (FP), and false negative (FN), which are depicted below.

Sensitivity
The ratio of a number of TP to the sum of TP and FN is called sensitivity:

Specificity
Specificity is the ratio of a number of TN to the sum of TN and FP:

Accuracy
Accuracy is calculated using the measures of sensitivity and specificity. It is denoted as follows:

FPR
The FPR is calculated as the number of incorrect positive predictions divided by the total number of negatives. It can also be calculated as 1 − specificity:

FNR
The FNR is calculated as the number of incorrect negative predictions divided by the total number of negatives:

Performance Analysis
In this section, the performance assessment of the proposed MRG-based ANN image classification method is illustrated. The sensitivity, specificity, accuracy, FPR, and FNR values of the proposed and existing methods for database images for segmentation result are summarized in Table 1. The sensitivity, specificity, accuracy, FPR, and FNR values of proposed and existing methods for classification result are summarized in Table 2.
By analyzing the tables, it is clear that the proposed method is more accurate than any other existing technique. From Table 1, the sensitivity, specificity, and accuracy values for the food type orange_1 is 97%,  79%, and 82%, respectively. Likewise, the sensitivity, specificity, and accuracy values for other food types like potato_9 and potato_15 are tabulated. While analyzing classification accuracy values, the proposed MRG-ANN technique obtained 80% accuracy when compared with other existing approaches like the K-nearest neighbor and naive Bayes algorithms. Moreover, the sensitivity and specificity values are more reliable for the proposed MRG-ANN technique when compared with an existing technique. Likewise, both FPR and FNR values attain good results for the proposed and existing methods for different food products.
Finally, the segmentation and classification comparison plots for the proposed and existing techniques for food images are provided in Figures 9 and 10.
The comparison results show that the segmentation and classification results of the proposed MRG-based segmentation and ANN-based classification are more reliable.

Conclusion
In this article, we established a competent food eminence ranking process, which is derived from MRG-related segmentation and ANN-related categorization methods. Initially, the input images are preprocessed by means of the histogram equalization procedure. Afterward, MRG-related segmentation is used to separate the definite appropriate attributes like GLCM-related and color histogram attributes. After that, the ANN classifier ranks the food products. The presentation of the proposed procedure is estimated and contrasted by means of an obtainable process. The results of the proposed method illustrate an effectual method of food eminence ranking in comparison with other methods.