Potato Size and Shape Detection Using Machine Vision

To reduce the error and faster classification by mechanizing in classifying the potato shape and size through machine vision using the extraction of characters procedure to identify the size, and using the shape detection procedure to identify the shape. Test results in potato size detection revealed 40/191 = 0.210mm/pixel as length scale or calibration factor (40/M) where 40 is the table tennis ball size (40mm) and 191 as image pixels table tennis (M); measurement results revealed that between the algorithm results and the manual measurements, the absolute error was <3mm, while the relative error rate was <4%; and the measurement results based on the ellipse axis length can accurately calculate the actual long axis and short axis of potato. Potato shape detection revealed the analysis of 228 images composed of 114 positive and 114 negatives side, only 2 have been incorrectly classified, mainly because the Extracted ratio (R) of the potato image of those two positive and negative images are near 0.67, respectively 0.671887, 0.661063, 0.667604, and 0.67193. The comparison to establish a calibration system method using both basic rectangle and ellipse R ratio methods to detect the potato size and shape, revealed that the basic rectangle method has better effect in the case of fixed place. Moreover, the ellipse axis method was observed to be more stable with an error rate of 7%. Therefore it is recommended that the ellipse axis method should be used to detect the shape of potato for differentiation into round, long cylindrical, and oval shapes, with the accuracy level of 98.8%.


Introduction
Currently potato processing enterprises have a variety of issues, such as small production scales, poor product quality, and sales difficulties in times of economic downturns [1,2].The potato size and shape does not only affect the commercial value of its processing, they have important significance on the crop's genetic and breeding research.Scholars have done a lot of work on agricultural products size and shape detection.Ying Yibin [3] proposed a method seeking the maximum diameter of citrus orange through the minimum bounding rectangle with the results showing that the relevance of actual maximum diameter and prediction maximum diameter was 0.9982.Lin Kai-Yan [4] proposed a fruit shape classification method based on Fourier transform by the gradient method to detect edge, boundary tracing algorithm to catch the fruit contour radius sequence, its discrete Fourier transform, and finally with the definitions of the Fourier coefficient device, according to the classification of a given threshold to classify the shape of the fruit.Zhang Cheng-hu [5] dealt with the morphological rambutan size using visible light image detection and x-ray image detection.When compared, the results showed that in using visible light, the long axis average error between the manual measurement and the test results was 7.3% and for the short axis, 8.5% while when using x-ray image detection, the average error of long axis was 3.4%, and the short axis was 2.7%.Johanna Torppa [6] studied the characteristic shape parameters of potato tubers modeling method using 3D triaxial ellipsoid model as reference, and by simulating by spheroid harmonic series on the potato irregular surface.The simulated results show that for some specific species, the 3D modeling was well fitted thereby proving traits such as shapes and sizes, as well as tools in determining them, has given greater value commercially in partnership with genetic breeding and computer vision testing.To date, there have been no studies on the automatic classification of potatoes [7,8].In light of current domestic and foreign non-destructive testing methods, the main contemporary research focuses on using computer vision technology to detect the shape and size of a potato, its skin quality and various external defects.

Potato tubers and computer vision system
All potato tubers were provided by the Hunan Provincial Engineering Research Center For Potatoes.Three different cultivars were investigated: Atlantic, Xiang No.1 and Favotita.According to the People s Republic of China Specialty Standard (ZB B23008-85) [9], 104 good potato tubers and potato tubers with machine damages, diseases and insect pests, scab, bruises, and foreign substances were chosen as the sample set.The computer vision system developed to detect the defects of potato was composed of a CCD camera, lighting chamber, light source and computer.An OLYMPUS C5060WZ CCD camera was used to acquire images.A lighting chamber was mainly used to provide an enclosed and uniform light illumination.The interior surface of the chamber was painted flat white.Tricolor ring light were mounted in such a way that a uniform light intensity was obtained at the potato tuber.Images were processed and analyzed by an HP7650 computer with a 2.8 GHz CPU, 80G hard disks and 512MB memory.

Segmentation of defects and Adaptive intensity interception method
The intensity of HSI (hue, saturation, intensity) color model is the most useful descriptor of monochromatic images and is selected as the graying method of potato image.The intensity component [10] in HIS is given by formula (1).
Where, R (Red), G (Green) and B (Blue) were the three color value of the JPG image and value ranges of R, G, B and I are from 0 to 255.
A great number of experimental results have shown that for yellow-skin potato the overwhelming majority of defects came from dark or black spots with low proportion and no significant peak in gray-level histogram.It is difficult to straight segment by some multilevel threshold methods.To solve this problem, two new methods, fixed and adaptive intensity interception method, were proposed by simulating characteristics of the human vision system.When humans focused on one object, other objects around it would be out of focus and ignored.In this case, the dark parts were considered the objects of interest, and other light parts would be ignored.An Adaptive Intensity Interception (AII) method for automatically selecting a threshold value was proposed for images with non-uniform illumination (light or dark).In fact, the position of bimodal distribution in the intensity histogram changed when the illumination of the image was different.It moved to the right (white part) when the illumination was too light, or to the left (black part) when the image was too dark.According to the above description, the importance here is to decide how much information can be ignored.AII selects a threshold value that can be automatically decided according to the position of the lobe of the potato.The adaptive intensitybased threshold method could be used in both uniform and non-uniform illumination and was given as follow: (1) Calculate the histogram of gray-level intensity in the range [0,255].
(2) Compute the threshold (T) that separated the potato and background in original image by using the Otsu method [11].
(3) Find the intensity value (M) of the peak of potato lobe in the range [0, T].
All the intensity value is greater than IIT will be considered as IIT and therefore be ignored.

Detection Methods of Potato Size
One of the basic tasks of computer vision is to start with the camera obtained image information to calculate the objects' geometrical data in 3-dimensional space, and thus make reconstruction and object recognition possible as data or space object is generated.As the image is "translated" from specific points on the surface of the space object, the relationship between 3-dimensional location and the corresponding point location in the picture is determined by the camera photo geometric model, those space model parameters are the camera parameters.In most conditions, these parameters can be obtained by experiment and calculation in a process called the system calibration.
In system calibration study, the basic method is determine the camera model, then based on the specific experimental conditions, such as a known shape, size calibration reference, deal with the image by a series of mathematical transformations and calculation methods to obtain the camera model's internal and external parameters to establish the picture and the actual physical contact to infer the material object size and shape [12,13].This study will start with the real-time detection, comparisons of several test methods using characteristic potato size and shape to find the simple, effective and needs less computations to minimize errors.
The original image through the B channel graying, median filter and the Otsu segmentation is obtained binary image.Abscissa according to the collection region to identify the acquisition after the potato split horizontal images of right values Xmax, and most left value Xmin, get the distance between Xmax-Xmin+1.Similarly, according to longitudinal coordinates to find throughout the collection region segmentation image vertically potato highest value Ymax and the minimum value Ymin, vertically between these two points a distance Ymax-Ymin+1.Through the left point and the most right point to straight a line vertical to horizontal, to the highest point and lowest point to straight a line parallel to the abscissa.4 line intersection form the basic rectangle contains the measured image (potato image).The Xmax-Xmin+ 1 and Ymax-Ymin+ 1 in the value of the larger rectangle is defined as the length, the smaller rectangle is defined as the width.
Basically potatoes' shapes are similar to ellipse or round.Therefore, the long and short axis of potato image can be used as the characterized parameters classify by the above described standard.Set {f(i,j),i,j=1,2,…,n} is the potato binary image, potato u, v-order statistical moment is defined as [14,15]: It can be obtained potato centroid (i, j) (1,0) / (0,0) j m m (5) Where (u + v) order the standard central moments as In The formula: Standard central moments reflect the regional distribution of gray for the amount of centroid, and the region symmetrical features characterize.In the actual potato analysis, it can be ordered the first seven moment invariants.They don't change with the translation, rotation, scaling, etc.The second-order moment invariants calculation formula as follows [16]: Ellipse major axis length: Ellipse minor axis length: Ellipse defined by the above ratio R for the short axis: Minor R Major (R<=1) (10)

Potato Shape Detecting Method
According to 'Potato Cultivation Studies In China' [17] tubers size varies mainly on the variety and growing conditions, the general weight of a block is about 50-250g, and bulk up to more than 1500g.Tuber shape differs in different varieties, different cultural environment, and climate conditions, it could broadly classify the shape of the tubers into 3 main types, and the others just are deformed.The 3 types are long cylinder shape, cylindrical and elliptical.For the Round tubers, the vertical and horizontal diameter is almost equal.Cylinder shape tubers the vertical diameter is more than one and half of the horizontal diameter.The oval shape is in the middle of the first two shapes.The difference of tubers because in the growing process, the cells division and increases at all directions in different speeds.In normal conditions, the mature tubers of each variety has a certain shape, it is one important basis to identify species.This research differ potato into round, oval and long cylinder, using the ellipse major and minor axis ratio to simulate the connection of the potato's horizontal and vertical diameter.
As the above describe, using the R for the shape parameter, see equation 8.
Differentiate the potatoes into 3 shapes by their corresponding R numerical value: if the R is less than 0.67, it is classified as long cylinder shape; if the R is more than 0.85, it defined as round shaped, and the others if their R values are in between these range are defined as oval shaped

Detection of potato size
This study uses the system calibration method to detect the actual size of potato tubers.Digital Image is measured in pixels and to calibrate the number of pixels to size each pixel represents the actual length in mm.The unit of calibration results is mm / pixel.In this study, the reference used is the table tennis ball the size of 40mm.In the calibration process, the vertical distance, between the CCD camera lens to the background board was fixed at 48cm, and then the ball was photographed.Photographs were then analyzed in the DIPS, calculate the diameter of the image pixels table tennis (M), and get an image of the length of the scale: 40 / M. Reference in the calibration of different locations depending on the region of the M values obtained are listed in Table 1.
After averaging, the horizontal rectangle length obtained is 190.875 while the long axis length is 191.0164;showing consistency in the two methods' results, determining the value of M = 191, therefore, giving the length scale or calibration factor as 40/191 = 0.210mm/pixel.Based on the basic rectangle 50 different sizes of potatoes were chosen, to compare the measure result by system calibration method and manual method.In the system calibration, the CCD camera was kept at the same height and location to take the photos as the DIPS was used to measure the rectangular length and width.Statistics show that between the algorithm results and the manual measurements the absolute error of <3mm was determined, while the relative error rate was <4%.Part of the statistics is shown in Figure 1 and Figure 2. Choose 50 different sizes of potatoes, compared the measure result by system calibration method and manual method.In the system calibration, keep the CCD camera at the same height and location, take the photos and use DIPS measure the major and minor axis length.Statistics show that between the algorithm results and the manual measurements the absolute error <7mm, the relative error rate <7%.Therefore, this method is better to calculate the potato's long and short axis.Part of the statistics shown in Figure 3 and Figure 4.
The above comparison shows that, the error rate of the method which based on basic rectangle is less than the method based on elliptic axis length, but the ellipse axis length method has obvious advantages in real-time detection.Because the accuracy of the basic rectangle method heavily affected by the potato placed in the camera field of vision, when the potato spindle parallel or perpendicular to the coordinate vision x-axis, can accurately measure the size of the potato; and when the potato spindle and vision x axis at an angle, the basic rectangle of length and width will not change with changes in the direction of the potato, which would result in large errors, as shown in Figure 5.It can be seen, different layout affect the calculate result of the ellipse axis length method is less, so the method can accurately calculate the actual long axis and short axis of potato.

Potato Shape Detection
One hundred fourteen (114) complete potato tubers were randomly selected then photographs were taken for positive and negative sides totaling 228 potato images gathered.After the classification, using the computer vision classification, the following steps were done: Step 1: Pretreatment with the DIPS: B channel graying, median filter and the Otsu segmentation Step 2: Extracted the ratio (R) of the potato image Step 3: Compared the classification results between manual and computer vision classification.The results of the study is shown in Table 2, the correct classification rate is 99.1%.

ICMEE 2015
Test results show that after analysis of the 228 images, only 2 have been incorrectly classified, mainly because the R of those two positive and negative images are near 0.67, respectively 0.671887, 0.661063, 0.667604, and 0.67193.While the potato shape classification don't require an accuracy level as the industrial products, when the R of positive and negative sides are near but different classification, could seen as ellipse shape.

DISCUSSIONS AND CONCLUSIONS
In the comparison to establish a calibration system method, using both basic rectangle and ellipse R ratio methods to detect the potato size and shape accurately, the results show that in the case of the fixed place, the basic rectangle method has better effect, but in the case of the random relay, ellipse R ratio method has the better effect.Moreover, the ellipse axis method was observed to be more stable with an error rate of 7%.After comparing accuracy levels, it is therefore recommended that the ellipse axis method can be used to detect the shape of potato for differentiation into round, long cylindrical, and oval shapes, with the accuracy level of 98.8%.

DOI: 10
.1051/ C Owned by the authors, published by EDP Sciences, 2015

Fig. 1 .Fig. 2 .
Fig. 1.The absolute error of length and width of rectangle

Table 1 :
The measurements of pixels of ping pong ball

Table :
The inspection results of three shapes