Potato Sorting Based on Size and Color in Machine Vision System

Potato (Solanum tuberosum) is cultivated as a major food resource in some countries that have moderate climate. Manual sorting is labor intensive. Furthermore in mechanical sorting the crop damages is high, for this reason we must operate a system in which the crop damages would be diminished. For sorting of potatoes fast, accurate and less labor intensive modern techniques such as Machine vision is created. Machine vision system is one of the modern sorting techniques. The basis of this method is imaging of samples, analysis of the images, comparing them with a standard and finally decision making in acceptance or rejection of samples. In this research 110 numbers of potatoes from Agria variety were prepared. Samples were pre-graded based on quantitative, qualitative and total factors manually before sorting. Quantitative, qualitative and total sorting in Machine vision system was performed by improving images quality and extracting the best thresholds. The accuracy of total sorting was %96.823.


Introduction
The potato (Solanum tuberosum) is an herbaceous annual that grows up to 100 cm (40 inches) tall and produces a tuber -also called potato -so rich in starch that it ranks as the world's fourth most important food crop, after maize, wheat and rice.The potato belongs to the Solanaceae -or "nightshade"-family of flowering plants, and shares the genus Solanum with at least 1,000 other species, including tomato and eggplant.S. tuberosum is divided into two, only slightly different, subspecies: indigene, which is adapted to short day conditions and is mainly grown in the Andes, and tuberosum, the potato now cultivated around the world, which is believed to be descended from a small introduction to Europe of andigena potatoes that later adapted to longer day lengths (FAO, 2008).
Potato consumption in any form as seed, using for human food, feeding animals or processing operations as chips, conserve operation and so on are dependant to special conditions which must prepare before those operations.The objective of sorting is preparation of these conditions.
By sorting we can grade crops based on size, shape, color, ripeness, damaging etcetera.The sorting operation by hand is time-consuming and its efficiency is low and sometimes its cost is high (Where the worker's wage is high).Mechanical grading can increase the sorting efficiency and the need for workers is decreased.
Technological advancement is gradually finding its applications in the field of agricultural and food, in response to one of the greatest challenges i.e. meeting the need of the growing population.Efforts are being geared up towards the replacement of human operator with automated systems, as human operations are inconsistent and less efficient.Automation means every action that is needed to control a process at optimum efficiency as controlled by a system that operates using instructions that have been programmed into it or response to some activities.Automated systems in most cases are faster and more precise (Narendra and Hareesh, 2010).
By using machine vision systems and image processing techniques we can grade the crops by high precision and speed and diminish crop damages.Computer vision has been recognized as a potential technique for the guidance or control of agricultural and food processes.Therefore, over the past 25 years, extensive studies have been carried out, thus generating many publications (Narendra and Hareesh, 2010).
In this research we operated the image processing techniques and finally the program is tested.
Machine vision has been applied for sorting of a wide range of agricultural products.Some of theses researches are mentioned bellow: Von Beckmann and Bulley in 1978 developed an electronic sorter for color and size grading of tomatoes.They used the ratio of surface reflectance in wavelength of 600 and 660 nm to sort tomatoes in 4 grades (Von Beckmann and Bulley, 1978).
Miller and Delwiche in 1989, developed a color vision system for detection and sorting of ripe peaches.For peach sorting their color was compared to color of standard ripe peach (Miller and Delwiche, 1989).
A prototype inspection station based on the United States Department of Agriculture (USDA) inspection standards was developed for potato grading.The station consisted of an imaging chamber, conveyor, camera, sorting unit, and personal computer for image acquisition, analysis, and equipment control.A sample of 9.1kg (201b) of pregraded potatoes was evaluated in three separate experimental runs to assess the system performance.The system correctly classified 80%, 77%, and 88% of the moving potatoes in the three runs at 3 potatoes/min, and 98%, 97%, and 97%, in three runs of stationary potatoes.Shape analysis was adversely affected by the potato motion, and this contributed to the misclassification error (Heinemann et al., 1996).
Laykin in 2002, used three methods for sorting of tomatoes.These methods were: Mean-Standard deviation, Slide Blocks and Quad tree (Laykin et al., 2002).
Deck in 1995 compared the color segmentation results of a Multilayer Feed Forward Neural Network (MLF-NN) and a traditional classifier for the color inspection of potatoes (Deck et al., 1995).Tao et al., in 1995 represented a method for sorting of green and good potatoes.They used HSI color system.Samples of potatoes were sorted by experts and farmers.They used 40 numbers of green and good potatoes in training phase and 20 numbers for each grade in test phase.In training phase all 40 good potatoes and 38 numbers of 40 green potatoes and in test phase all 20 good potatoes and 18 of 20 numbers of green potatoes were sorted correctly.The results of human and machine detection were close (Tao et al., 1995).
A high speed machine vision system for the quality inspection and grading of potatoes has been presented by Noordam et al. in 1995.The vision system graded potatoes on size, shape and external defects.For color grading of potatoes they used Linear Discriminate Analysis (LDA) and MLF-NN techniques.Results of LDA and MLF-NN sorting techniques implementing for different variety of potatoes were respectively 86.8%-98.6%and 88.1% -99.2% (Noordam et al., 1995).Zhou et al. (1998) evaluated weight, cross-sectional diameter, shape, and color of three cultivars of potato using a computer vision system which was able to classify 50 potato images per second.An ellipse was used as the shape descriptor for potato shape inspection and color thresholding was performed in the hue-saturation-value (HSV) color space to detect green color defects.The average success rate was 91.2% for weight inspection and 88.7% for diameter inspection.The shape and color inspection algorithms achieved 85.5% and 78.0%success rates, respectively.The overall success rate, combining all of the above criteria, was 86.5%.Rios-Cabrera et al. (2008) determined potato quality evaluating physical properties using Artificial Neural Networks (ANN's) to find misshapen potatoes.The results showed that FuzzyARTMAP outperformed the other models due to its stability and convergence speed with times as low as 1 ms per pattern which demonstrates its suitability for real-time inspection.Several algorithms to determine potato defects such as greening, scab, cracks were proposed.Barnes, et al. (2009) introduced novel methods for detecting blemishes in potatoes using machine vision.The results show that the method is able to build "minimalist" classifiers that optimize detection performance at low computational cost.In experiments, minimalist blemish detectors were trained for both white and red potato varieties, achieving 89.6% and 89.5% accuracy respectively.

Sorting Mechanism
The sorting mechanism was consisted of: The lighting source selection is a key factor in image processing operation.In designing the lighting chamber the outer light must be eliminated.In this research we used four florescent lamps by lateral positions in chamber and camera lens was entire to lighting chamber by a hole which was only entrance to outer which was covered by camera lens.Potatoes were placed under camera lens in the center of lighting chamber.A camera which was selected for image capturing was CCD camera.The software of this system was MATLAB (R2008a).

Transformation of RGB to Gray Scale Image
When a RGB is transformed to gray scale image, the image size is decreased and the image processing is accelerated.

Calculation of Threshold
Threshold extraction is the best way for image segmentation.If the image is consisted of a light object in a dark background, the grayscale pixels are placed in two modes.

Image Noise Elimination
In this research for elimination of some noises and reaching the best boundary, we used 25 by 25 Gaussian Low-pass Filter by standard deviation of 15.The way which we selected was the Replicating method.In this method size was developed by replication of values in outer boundary.

Extraction of Boundary
Boundary extraction is a major technique in image pre-processing and is used in the most algorithms.Boundary detection is the basic process for extraction of image information.We must select one method which its sensitivity to image noises is the least and can extract continuous boundary in a simple and fast way.We used Sobel estimate which its sensitivity to horizontal and vertical boundaries is higher than others.Sobel extracts boundary by non-linear calculation and it isn't dependant to point value.

Calculation of Area
By labeling the extracted boundary we can calculate quantitative parameters such as max diameter, min diameter, equivalent diameter, area, and perimeter and so on.We can use all these parameters to grade potatoes based on size.In this research we employed the area.The area was calculated by counting the number of pixels in the labeled region.

Evaluation the Combination of Intensity Transformation Functions and Color Spaces
The various combinations of intensity transformation functions and color spaces were implemented on images and by detection the pixels that belong to health class and numbering them, by dividing them to the total number of pixels the percentage of health class was calculated.By comparing the percentage with the percentage that specified by experts, the R 2 of them was calculated.The best combination which has the highest R 2 is 0.989 that belongs to the combination of HSV color space and logarithmic transformation (figure1).

Threshold Extracting and Evaluating in Quantitative Sorting
For calculation of area threshold, we divided each grade to training and testing groups.In training group the numbers of Small, Medium and Large groups were respectively: 12, 20 and 23.
For extracting the proper threshold, the tubers were pre-graded by experts in classes of Small, Medium and Large sizes.Thereafter each class was divided to phases: Training and Testing.In Training phase the threshold was extracted according to table (1), relations (1), ( 2) and (3).For evaluating the accuracy of this threshold to classify the samples based on size, it was operated on the samples of Test phase.This process is represented in table (2).As represented in this table the accuracy of this threshold on sorting test samples based on size was 100%.(3)

Threshold Extracting and Evaluating in Qualitative Sorting
110 numbers of potatoes were pre-graded by experts into 19 numbers of Grade1, 37 numbers of Grade 2, 33 numbers of Grade 3 and 21 numbers of Rejected groups.For extraction of appropriate threshold the samples were divided into two groups of Training and Testing.In Training phase the threshold was extracted by implementing the qualitative algorithm based on combination of logarithmic transformation with coefficient of 0.5 and HSV color space.The extracted threshold was implemented on the testing phase to identify accuracy of qualitative sorting.The process of threshold extraction is represented in table (3) and relations (4), ( 5) and ( 6).The evaluating of the extracted threshold is represented in table (4).

Threshold Extracting for Total Sorting
For total sorting, at first the threshold was extracted.This threshold was based on the considerable sorting factors in quantitative and qualitative sorting.For example the factors of small size and rejected qualitative were combined to create the total sorting threshold in Rejected group and so on.These factors are represented in table (5).

Total Sorting
For total sorting the samples were pre-graded by experts then the total sorting threshold was implemented by applying the total sorting algorithm.The result of total sorting was based on the comparison between pre-graded and algorithm graded samples.The result is shown in table (6).

Conclusions
For total sorting of potato (Agria variety), the quantitative and qualitative sorting was performed.At first step, in the quantitative sorting experts pre-graded the samples and those were divided into two groups of training and testing phases.In the training phase the threshold was extracted based on applying area calculation algorithm.For evaluating the quantitative algorithm, it was evaluating in the domain of testing phase.
For extraction of qualitative threshold, experts pre-graded potatoes based on health percentage.The pre-graded samples were divided into two groups of training and testing phases.The threshold was extracted in training and evaluated in testing phases.Accuracy of threshold evaluating in quantitative sorting based on Area in all three groups of Small, Medium and Large was 100%.The accuracy of qualitative threshold evaluation in groups of Rejected, Grade3, Grade2 and Grade1 was respectively: 100%, 96.97%, 89.19% and 100%.
For total sorting the quantitative and qualitative thresholds were combined.Potatoes were pre-sorted by experts based on both quantitative and qualitative factors.Then the accuracy of total sorting was obtained by comparison between pre-graded and Machine vision grading.The accuracy of total sorting was 96.823%.

Figure 1 .
Figure 1.The best combination of color spaces and intensity transformation functions

Table 1 .
Threshold extraction of quantitative sorting (Training phase)

Table 4 .
Threshold testing of qualitative sorting (Testing phase)