Evaluation of image processing technique and discriminant analysis methods in postharvest processing of carrot fruit

Abstract The most important process before packaging and preserving agricultural products is sorting operation. Sort of carrot by human labor is involved in many problems such as high cost and product waste. Image processing is a modern method, which has different applications in agriculture including classification and sorting. The aim of this study was to classify carrot based on shape using image processing technique. For this, 135 samples with different regular and irregular shapes were selected. After image acquisition and preprocessing, some features such as length, width, breadth, perimeter, elongation, compactness, roundness, area, eccentricity, centroid, centroid nonhomogeneity, and width nonhomogeneity were extracted. After feature selection, linear discriminant analysis (LDA) and quadratic discriminant analysis (QDA) methods were used to classify the features. The classification accuracies of the methods were 92.59 and 96.30, respectively. It can be stated that image processing is an effective way in improving the traditional carrot sorting techniques.


| INTRODUC TI ON
Carrot (Daucus carota L.) is consumed by millions of people all over the world. It belongs to the family Umbelliferae. Carrot is one of the most important and useful vegetables for the human body since it contains nutrients and vitamins. Also, it increases an individual's resistance to infectious diseases (Abbas, 2011;Zhu et al., 2019).
Carrot is used mostly as a raw edible product. One of the carrot problems is shape nonhomogeneity. Although carrots with irregular shapes have no problems regarding their nutritional properties, they are not commonly selected by customers in the markets.
This causes to remain the carrots in the markets for long times and then increase the material loss. Therefore, adopting an appropriate method for sorting and packaging this product can increase its desirability in the market and decrease product loss (Jahanbakhshi & Kheiralipour, 2019).
Sorting of agricultural products based on the product quality is one of the most basic and important operations after harvesting. The operation assists customers in recognizing product quality more easily and leads to a more organized distribution and supply of an agricultural product. Until some decades ago, quality control in food industries was carried out by experts. Evidently, in traditional method, the performance is low and it is expensive and inefficient to respond to the increase in consumers' demands. Image processing is a modern technology, which has witnessed considerable progress both theoretically and practically in recent years.
The main advantages of using a machine vision system for quality control of agricultural products are the precision and consistency. table for detecting size, shape, and defect (Kheiralipour, Ahmadi, Rajabipour, & Rafiee, 2018;Pathmanabana, Gnanavel, & Sundaram Anandan, 2019). Riquelme, Barreiro, Ruiz-Altisent, and Valero (2008) sorted olive fruits based on the shape of their external defects. First, the fruits were classified into seven categories by experts and then they were categorized according to features such as color and the shape of external defects. Furferi and Carfagni (2010) designed a machine vision system to sort olive fruits based on the ripeness level and external defects. Liming and Yanchao (2010) implemented an automated system for sorting strawberries based on image analysis. The system was able to identify the physical properties of strawberries according to the image features. They reported that the sorting precision was 88.8% based on color features and 90% based on shape features. Mousavi Balestani (2012) discriminated and sorted cherry fruits according to the fruit size, ripeness, and defects using image analysis method. They reported that sorting based on size, ripeness, and defects was carried out with accuracy of 96%, 92%, and 90%, respectively. Elmasry et al. (2012) designed a rapid and accurate machine vision system to distinguish irregular from regular shape potatoes and reported that the practical accuracy of the system was 96.2%. Mohammadi et al. (2015) sorted persimmon fruit based on ripeness level through image processing technique. The results of their study showed that image analysis indicated a significant difference among different ripeness levels for most image features such as R, G, B channels and the gray level. They also reported that quadratic discriminant analysis (QDA) could sort fruits with accuracy of 90.24%. Kheiralipour and Pormah (2017) used image processing technique and artificial neural networks to sort cucumber fruits and reported that the best sorting model was obtained through neural network with the accuracy of 97.1%.
Literature review on the subject shows that there are no reported studies about carrot sorting based on shape. Thus, the aim of the present study was to distinguish the carrot shape using machine vision, which is useful for carrot sorting in order to increase its marketability and waste control of the product.

| MATERIAL S AND ME THODS
In the present study, 135 carrot samples with different shapes (56 regular and 79 irregular) were selected and their images were acquired through an imaging system. First, an expert divided the carrots into two classes: regular and irregular shape. The carrots with irregular shapes were the ones with double or triple roots, curved, damaged, broken, and upright ones ( Figure 1).
After image acquisition, the obtained images were used for processing by a programmed algorithm in MATLAB R2012a software.
The images were first read by the algorithm. Image preprocessing was the first step in processing. In this step, the red, green, and blue channels (R, G, and B) were extracted from the RGB images. Other features such as roundness, elongation, and compactness of the carrot images were calculated through Equations 1-3, respectively: where Ro is roundness, Co is compactness, El is elongation, a is length, b is width, p is perimeter, and A is the area of carrot.
Some new features of carrot image were calculated, called partial centroid nonhomogeneity (Fc i ) and partial width nonhomogeneity (Fb i ). For this, the carrot image was divided into seven parts. For calculating partial centroid nonhomogeneity, the centroid of each part of carrot image (c i ) was found ( Figure 5). where Fc i is partial centroid nonhomogeneity and c i is centroid of each image part. The width of each part was also determined to calculate the partial width nonhomogeneity (Fb i ) ( Figure 6).
Then, the width of image part number 4 was subtracted from that of other parts and six features were obtained as Fb 1 to Fb 3 and Fb 5 to Fb 7 (Equation 5): where Fb i is partial width nonhomogeneity and b i is the width of each image part.
The total centroid and width nonhomogeneity were extracted (Kheiralipour & Pormah, 2017). The sum of all partial centroid nonhomogeneity was calculated and divided by the biggest carrot width (Equation 6).
where Fc t is the total centroid nonhomogeneity, Fc i is the partial centroid nonhomogeneity of the carrot, and bm is the biggest carrot width. The total width nonhomogeneity was calculated by summing the all partial width nonhomogeneity and dividing by the biggest carrot where Fb t is total width nonhomogeneity, Fb i is partial width nonhomogeneity, and bm is the largest carrot width (Kheiralipour & Pormah, 2017).
The last feature was extracted as the number of the roots (N) of carrot. This feature for single root carrots is equal to 1, but for several root carrots, it is more than 1. In Figure 7, the image of a 2-root carrot is provided. In this sample, the number of root of the left end part is equal to 2.
In this study, efficient features of carrot shapes were selected for the classification. For this, an algorithm was programmed in MATLAB 2012a software using cross-validation method based on quadratic discriminant analysis. Then, the carrot images were classified using linear discriminant analysis (LDA) and quadratic discriminant analysis (QDA) using SAS 9.1 software. The efficient features were used as input of the classification methods, and the output was class number, for example, 1 for regular and 2 for irregular shape carrots.

| RE SULTS AND D ISCUSS I ON
The efficient features of the carrot sample images were selected using cross-validation based on quadratic discriminant analysis method. These features that were considered as the input of the LDA and QDA methods are given in Table 1. All features had different values for regular and irregular shapes at 5% probability level.
The average width of regular and irregular carrots was equal to 922.86 and 1,082.69, respectively, and the mean of their perimeter was equal to 9,797.17 and 10,507.58, respectively, which indicates that the average width and perimeter of the irregular carrot were more than those of regular one due to inappropriate shape of the appearance shape of the irregular shaped carrots.
The roundness of the studied groups with average values of 1,053,465.08 and 897,945.07 showed that the roundness of irregular carrots was lower than that of regular shape carrots. Also, the averages of the remained features in Table 1 including Fc 2 to Fb 6 and number of roots for regular carrots were lower than those of irregular ones. According to differences between the data of regular and irregular carrot shapes (Table 1), there can be told that the features are useful for the classification of the two groups.
The confusion matrix of linear discriminant analysis (LDA) is given in Figure 8. The first category is related to regular shape carrot, and the second one is representative of irregular shape carrots.
As shown in Figure 8, 53 out of 56 samples of regular shape samples have been correctly distinguished by LDA, while three samples have been wrongly identified as irregular shape carrot. From 79 irregular shape carrots, 72 samples have been correctly recognized as irregular shape but seven samples have been wrongly identified as regular shape carrot. In the end, as can be seen in Figure 8, the LDA method could be able to classify carrot samples with correct classification rate of 92.59%.
(4) The results of the quadratic discriminant analysis (QDA) method are shown in Figure 9. According to Figure 9, correct classifica- Note: The unit of all features is pixel except for the number of roots.