Keywords

1 Introduction

Fruit detection and quality grading always endure a hot topic in the agriculture research field. Traditionally, detection and grading are done by labor manually [1]. This will lead to scarcity of consistency and due to shortage of labor results in research for solutions automatically. One of the most difficult processes is to detect and grade fruits visually [2]. Computer vision and image processing are some of the most important techniques used for the identification of features in many agricultural products [3, 4]. Different algorithms have been tested and developed to detect and grade fruits automatically [5]. Moradi et al. [6] present the detection of defects in apples using a fuzzy c-means algorithm and achieves 91.00% accuracy. Razak et al. [7] proposed digital fuzzy image processing, content predicted analysis, and statistical analysis to grade mango and achieves 80.00% accuracy. Ashok and Vinod [8] presented quality grading of apples with 83.33% accuracy for probabilistic neural networks. Nandi et al. [9] propose mango grading using a multi-attribute decision theory with a prediction accuracy of 96.00% accuracy. Nandi et al. [10] presented the maturity and quality detection of mangoes using fuzzy and achieve an 87.00% recognition rate. Sahu and Potdar [11] identify defect a maturity of mango fruit using Image Processing Toolbox. Jawale and Deshmukh [12] proposed real-time rotten apple detection using ANN. Naik and Patel [13] presented a fuzzy classifier to grade mango (L * a * b * color space) that achieves 89.00% accuracy. Khan et al. [14] classify apple disease using a genetic algorithm and achieve a 98.10% recognition rate. Nosseir [15] presented the classification and identification of multiple rotten fruits using linear SVM and achieves 96.00% accuracy. Singh and Singh [16] presented a classification of good and rotten apples using texture features with a 98.90% recognition rate. Bhargava and Bansal [17, 18] proposed a quality grading and detection of multiple fruits by machine learning.

This study aims to analyze an algorithm for the detection and grading of fruit and also to identify the performance of fruit algorithms. Furthermore, this study aims to ease meaningful and reliable conclusions. To that end, the proposed method aims to develop an algorithm that detects fruit variety among apple and mangoes and grades under two categories: fresh and rotten. This algorithm is based on a combination of features to attain a successful recognition rate. This work is the first to present a method to detect a variety of fruits in the vision system of agriculture.

2 Proposed Methodology

The purpose of this presented approach is to build a system that detects the fruit then classifies the variety of apples and mangoes among multiple varieties and assesses the sorting into two groups, i.e., fresh and rotten. Figure 1 presents an outline of the proposed method for the detection and categorization of fruits. These steps are explained in the following section.

Fig. 1
figure 1

Basic process for detection and grading of a variety of apples

2.1 Image Acquisition

The algorithm proposed uses two distinct varieties of fruits: apple and mango with five varieties of each fruit. Each set consists of fresh and rotten fruits. The characteristics of the dataset used are shown in Table 1. Figure 2 shows different varieties of fruits used.

Table 1 Dataset attributes
Fig. 2
figure 2

Sample of a fresh and rotten database used a Golden delicious apple, b Kesar mango

Fig. 3
figure 3

Fruit detection and grading accuracy

2.2 Preprocessing

Image preprocessing is carried out before the actual analysis [22] to extract particular information. Preprocessing refers to data enhancement for the reduction of distortion and noise illumination for the correction of degraded data. It also includes binarization, grayscale conversion, and filtering, smoothing, detection of edges, etc., used for the enhancement of the image.

In this paper, histogram equalization is done using grayscale imaging which results in the whitening of the image. Mathematically, the histogram equation is expressed as:

$$h\left(v\right)=\left(\frac{{\text{CDF}}\left(v\right)-{{\text{CDF}}}_{\text{min}}}{\left(A \times B\right)-{{\text{CDF}}}_{\text{min}}} X (L-1)\right)$$
(1)

where \({{\text{CDF}}}_{\text{min}}\) is cumulative distribution function minimum value, A × B is some pixels in an image, L is the gray level of the image.

2.3 Segmentation

Image segmentation separates a particular set of pixels into multiple segments from the digital image. The object evaluation is done by separating the background area from the foreground image. Various segmentation methods are utilized such as Otsu segmentation, k-means clustering, fuzzy c-means clustering, and color segmentation. Among all segmentation methods, the important segmentation technique is color segmentation due to which the spot of every disease has a different color.

In this paper, fuzzy clustering is done because it is effective for segmenting images in a controlled environment. In this technique, data points are partitioned into a specific number of clusters. It minimizes the objective function fork cluster centroids and given partitioned fuzzy data, n [23].

Mathematically, the membership function,

$$F={\mu }_{cd}=1;\text{c belongs to d}$$
$$F={\mu }_{cd}=0;\text{c does not belong to d}$$

The condition to insure that set is exclusive and exhaustive:

$$\sum_{d=1}^{k}{\mu }_{cd}=1,\quad 1\le c\le n$$
(2)
$$\sum_{c=1}^{n}{\mu }_{cd}>0, \quad1\le c\le k$$
(3)
$${\mu }_{cd}\,\epsilon \,\left\{\text{0,1}\right\}, \quad1\le c\le n;\quad1\le c\le k$$
(4)

The generalize objective function is given as

$$J\left(F,Z\right)=\sum_{c=1}^{n}\sum_{d=1}^{k}{\mu }_{cd}^{\varphi }{d}_{cd}^{2}$$
(5)

where

k is number of clusters

n is data point number.

2.4 Feature Extraction

Segmentation develops separated pixels shapes with distinct sizes. The determination of the fruit category depends upon the pixels taken together or independently. Our experiment shows that 13 statistical (mean, RMS, variance, standard deviation, smoothness, skewness, inverse difference moment, kurtosis) and textural (contrast, correlation, energy, homogeneity, and entropy), 14 geometric features (area, eccentricity, major axis length, minor axis length, centroid, bounding box, eccentricity, orientation, convex hull, convex area, solidity, extrema, diameter, extent) [24] are used for best performance in the grading system.

2.5 Classification

The extracted features from training images are the input to the classifier. The different characteristics of multiple varieties of apple and mango fruit are learned by the classifier. In this experiment, we use a statistical classifier known as SVM. It is a type of learning system which uses hypothesis space in higher dimensional space of linear function which implements statistical learning theory. It consists of two parts: linearly separable and nonlinear separable. “SVM is a supervised learning method that is based on the minimization procedure of structural risk” [25].

3 Results

The standards of commission European [26] for fruits describes one dismiss and three acceptable conditions. However, ample literature abides of fresh/rotten categorization because of the adversity of the compilation of database and sorting processes. A number of training and testing images used for detection and grading are 1780 and 1216, respectively, in SVM classifier. In the pursuit of detection and grading of apple and mango two category sorting, we have inspected 27 features while SVM is used for classification. The ten datasets of apples as mentioned in Table 1 have been trained with all features. Finally, the grading is done by SVM as shown in Table 2 and Fig. 3.

Table 2 Detection and grading accuracy using SVM

4 Conclusion and Future Work

In this research, a computer vision-based fruit detection and grading are introduced. Firstly preprocessing is done using histogram equalization to smooth the image. Then fuzzy c-means clustering is used for segmenting the defected region. Secondly, the combination of 27 features is extracted. Finally, the detection and grading are done using SVM classifiers and achieve accuracy with 98.48 and 95.72%. Furtherly, the more concluded and powerful system may be generated with enriched performance in the future. The solution proposed in this work must be tested for multiple fruit images to access its generality, robustness, and accuracy and must be established in a real-life detection and sorting domain.