A New Method for Rapid Detection of the Volume and Quality of Watermelon Based on Processing of X-Ray Images

. Real-time online detection of fruit quality system has been applied to production practice because online testing and grading of fruits screening technology has matured. However, fruit size and quality online testing have always been difficult. Many detection methods of fruit size and quality are very complicated and time consuming, which cannot meet the needs of real-time detection. In this paper, a new method for rapid detecting small watermelon of volume and quality was based on the X-ray image processing. The volume and quality of the relevant model established the predicting outcome of coefficient of determination R 2 obtained were 0.9858 and 0.9922 respectively, showing that these two models have high correlation and predicting the volume and quality of watermelon accurately as well as laying the foundation for the watermelon online detection and classification.


Introduction
High fruit production and export capacity need large online testing and grading equipment to replace manual work to save costs and increase efficiency. There are many researches about nondestructive testing technology based on the spectrum [1][2][3][4]. The fruit size will affect light permeability resulting in error detections, particularly such a large watermelon. The volume and quality greatly affects its quality testing, so we need to measure volume and quality to correct its model. Depending on the detection principle, the main agricultural product quality nondestructive testing methods are acoustic detection technology, machine vision inspection technology, X-ray detection technology, electronic nose detection technology, the physical characteristics of the dielectric detection techniques, magnetic resonance imaging detection technology and near-infrared spectroscopy technique [5]. Currently, these nondestructive testing technologies have applications and researches in different degrees pachyderm fruits internal quality detection. For example, Cooke [6] proposed the Young's modulus to evaluate grade of watermelon maturity, and Chuma [7] studied the relationship between watermelon fruit resonance characteristics and quality with the sound plus vibration mode. Although many scholars at home and abroad studied the internal quality of watermelon based on the acoustic characteristics and some detection effect is ideal, these results largely confined to laboratory testing since there are so many factors that affect the actual testing process. Iwamota [8] invented a method and apparatus for detection of fruit sugar content based on near infrared transmission spectroscopy NDT. As for Nearinfrared spectroscopy, there are some challenges needing to solve in terms of detection of thick-skinned fruits. Since Roentgen discovered X-rays in Germany at 1895, X-ray has made considerable development in many areas after long_term efforts, such as medical CT [9], environmental monitoring, forestry and food testing. Compared with other detection techniques, X-ray detection technology has more advantages in agricultural products on the internal quality testing and evaluation. In recent years, X-rays detection of internal defects in agricultural products and foreign substance examination has become a hot research. The traditional methods of measuring the volume of the fruit are vertical and horizontal diameter law, surface area and drainage method [10], in which the method of drainage is more commonly used, but the method of its operation is not suitable for real-time online testing. Currently, non-destructive testing techniques have been widely used in agricultural product quality testing, such as getting fruit volume by processing the image of the visible region [11]. Generally, those techniques conclude more complex algorithms and impact the online testing speed, meanwhile, it is difficult to obtain internal information accurately because of its large volume of watermelon. The researches of watermelon nondestructive testing methods of quality are different with other ripe fruit, and the related reports are also uncommon in nondestructive testing of its volume and quality indicators. This paper presents a method based on X-ray images which can detect the volume and quality of watermelon quickly and effectively.

Materials
The materials were picked from a watermelon shed Yanqing County Beijing after pollination. Ten samples were taken every two days during growing period between 21 days to 37 days and a total of 94 samples of the different growing season were obtained, which the samples growth (growth is the difference between picking and pollination period) distribution was shown in Table 1. Volume was calculated with water displacement method and quality was measured by JJ500 Precision electronic balance, and collecting results of box diagram distribution were shown in Figure 1. Maximum volume of 94 samples was 1614 cm 3 , the minimum was 398 cm 3 , with an average of 765.0969 ㎝ 3 . With a big difference between maximum and minimum sample and its large range of variation, the experiment had a strong representation.  Figure 1 volume and mass distribution

Experiment device
Experimental devices were designed and manufactured, including the X-ray generator, a linear array detector, conveyor system, image acquisition card, host computer, image processing software and etc al (as shown in Figure 2) . The conveyor belt transmitted test samples, to meet test requirements for obtaining a sharp image, after several transformation of voltage and current experiments, the information could be obtained relatively rich images by adjusting the X-ray source voltage to 80 kV and current to 1 mA. Only the detector integration time matched conveyor speed, did we get the real picture. By adjusting the detector integration time to 2ms, conveyor belt speed to 17.8cm / s, undistorted image with vertical and horizontal proportion could be obtained accurately.

X-ray image acquisition software
Acquisition software includes an adjustable trigger, sweeping the surface velocity, gray value level module, whose parameters can be optimized. Baseline correction Xray image was collected as shown in figure 3, where in the black part belonged to watermelon. Image captured was saved as two formats, and one was an image file format which gray scale range was 0-255, the other document format was text which gray scale range was 0-16383. It was convenient to make intuition analysis with image and text facilitated to accurate calculation. Data processing in this article used text document format for its greater range of gray and the result was accurate.

X-ray image preprocessing
For watermelon's round shape, if it was placed directly on the conveyor, belt would shake transport, resulting in the acquisition of image distortion. In order to ensure access to get clear, uniform image, homemade base would be fixed and all samples would be collected images using the same fixed base experiment. All samples were placed upright, collecting vertical images. To remove the background noise on the base of image processing, it was necessary to determine the threshold value, which distinguishes watermelon itself and background in the image.
To determine threshold value, we needed to find the centroid of watermelon first, gray value curve was extracted through vertical line of the watermelon centroid image which was shown in Figure 4. The abscissa represented the number of pixels from top to bottom through image centroid vertical lines of the image, and the ordinate was the vertical line gray value of the pixel. Difference was much apparent by comparing the difference of the curve between the sample and background and the threshold value was 1600 at the knee, which could effectively remove background interference.

Results and Discussion
Using text document format of 0-214 gray scale to calculate the data, the number of pixels whose gradation value summed was below 1600 of each sample. Indicators statistical results of 94 sample's mass, volume, and the number of calculated pixels were shown in Table 2. The three sets of index data were for standardization (raw data minus the average of the data and then divide the standard deviation), then the data were displayed on the same graph (as shown in Figure 5). The dotted line represented pixels change trend of 94 samples, and chain line represented volume change trend of the true value, and the linear represented change trend of the true mass. The discovery was that the number of pixels calculated with the method in this article had a good linear relationship with the true value of watermelon volume and quality. When penetrating the material, X-rays were in line with the index variation. While the index trend lines within a certain small range could be approximated as a straight line, the number of pixels calculated by the X-rays image had a good correlation with quality and volume. It could be established linear correlation model for predicting the value of the volume of watermelon.

Figure 5 index change trend
As the using of the drainage volume method for measuring volume in this measurement, manual operation resulted in abnormal samples. In which 21-11, 25-4, 37-6, that was No.11 sample whose growing season was 21 days, the No. 4 sample whose growing season was 25 days, the No. 6 sample whose growing season was 37 days. The remaining 91 samples after removing outliers were for a linear regression, and quality was measured using an electronic balance with high accuracy so there are were no obvious abnormalities samples. After linear regression of 94 samples, modeling results of the volume and quality were shown in Figure 6, where volume forecasting model R 2 = 0.9858, quality prediction model R 2 = 0.9922, showing that this two prediction models had been relatively high correlation respectively.  Figure 7. From the linear correlation equation y = k x + b ,k coefficients were 1.0308 and 0.9826 respectively closing to 1, and the accurate prediction results proved that it was feasible to use the number of pixels by the X-ray image to estimate the volume of watermelon.

Conclusions
A method of measuring the volume and quality of small watermelon based on X-ray image processing was proposed, which built the best predictive model. Since the watermelon volume and quality determination coefficient of the linear regression model created reached 0.9927 and 0.9858, respectively, indicating that the model has a high correlation. In the predicting the value and the true value of the linear correlation equation y = k x + b k coefficients are 1.0308 and 0.9826, respectively, closing to 1.0 proving the model built has a high accuracy prediction. Therefore, this paper presented a small watermelon quality X-ray non-destructive testing method which can be more accurate and rapid. In the future to further expand the study of a large watermelon or other fruit for testing, for a variety of fruits optical nondestructive testing methods lay the foundation for online applications.