<figure><img src="image_1.png" /></figure>

HAL
open science

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

Ling Zou, Sun Ming, Di Zhang

► To cite this version:

Ling Zou, Sun Ming, Di Zhang. A New Method for Rapid Detection of the Volume and Quality of Watermelon Based on Processing of X-Ray Images. 8th International Conference on Computer and Computing Technologies in Agriculture (CCTA), Sep 2014, Beijing, China. pp.731-738, 10.1007/978-3-319-19620-6_79. hal-01420290

HAL Id: hal-01420290

https://inria.hal.science/hal-01420290

Submitted on 20 Dec 2016

HAL is a multi-disciplinary open access
archive for the deposit and dissemination of sci-
entific research documents, whether they are pub-
lished or not. The documents may come from
teaching and research institutions in France or
abroad, or from public or private research centers.

L'archive ouverte pluridisciplinaire HAL, est
destinée au dépôt et à la diffusion de documents
scientifiques de niveau recherche, publiés ou non,
émanant des établissements d'enseignement et de
recherche français ou étrangers, des laboratoires
publics ou privés.

<figure><img src="image_2.png" /></figure>

Distributed under a Creative Commons Attribution 4.0 International License
# A new method for rapid detection of the volume and quality of watermelon based on processing of X-ray images

Ling Zou<sup>1,a</sup>, Sun Ming<sup>1,b</sup>, Di Zhang<sup>1,c</sup>

¹Key Laboratory of Modern Precision Agriculture System Integration Research, Ministry of Education,

Key Laboratory of Agricultural Information Acquisition Technology,

Ministry of Agriculture,

College of Information and Electrical Engineering, China Agricultural University, Beijing
100083 China

a¹475126006@qq.com, bsunming@cau.edu.cn

cadalyme@hotmail.com

**Abstract.** 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² 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.

**Keywords:** X-ray image, small watermelon, quality, rapid detection

## 1 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-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 Near-infrared 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 non-destructive 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.

## 2 Materials and Methods
## 2.1 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³, the minimum was 398 cm³, with an average of 765.0969 cm³. With a big difference between maximum and minimum sample and its large range of variation, the experiment had a strong representation.

<table><caption>**Table 1.** Sample growing distribution table</caption><thead><tr><th>After pollination, the growing season (days)</th><th>Number of samples (a)</th><th>After pollination, the growing season (days)</th><th>Number of samples (a)</th></tr></thead><tbody><tr><td>21</td><td>12</td><td>31</td><td>11</td></tr><tr><td>23</td><td>10</td><td>33</td><td>10</td></tr><tr><td>25</td><td>11</td><td>35</td><td>10</td></tr><tr><td>27</td><td>11</td><td>37</td><td>9</td></tr><tr><td>29</td><td>10</td><td></td><td></td></tr></tbody></table>
<figure><img src="image_3.png" /></figure>

<figure><img src="image_4.png" /><figcaption>Figure 1 volume and mass distribution</figcaption></figure>

## 2.2 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.

<figure><img src="image_5.png" /><figcaption>Figure 2 X-ray detecting means</figcaption></figure>

2.3 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 X-ray 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.

<figure><img src="image_6.png" /><figcaption>Figure 3 X-ray image</figcaption></figure>
## 2.4 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.

<figure><img src="image_7.png" /><figcaption>Figure 4 Determining a threshold value</figcaption></figure>

## 3 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.

<table><caption>Table 2. Indicators statistical results</caption><thead><tr><td>Index</td><td>Distribution</td><td>Mean</td><td>Standard</td></tr></thead></table>
<table><thead><tr><th></th><th></th><th></th><th>deviation</th></tr></thead><tbody><tr><td>Volume (cm<sup>3</sup>)</td><td>678-1884</td><td>1190.3351</td><td>263.32813</td></tr><tr><td>Weight (kg)</td><td>0.621-1.697</td><td>1.16091</td><td>0.234394</td></tr><tr><td>Pixels</td><td>74198-207392</td><td>147067.8191</td><td>30312.43563</td></tr></tbody></table>

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><img src="image_8.png" /><figcaption>Figure 5 index change trend</figcaption></figure>
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² = 0.9858, quality prediction model R² = 0.9922, showing that this two prediction models had been relatively high correlation respectively.

<figure><img src="image_9.png" /><figcaption>Figure 6 linear regression models</figcaption></figure>

Small watermelon mass and volume values were calculated by linear regression equation, where the calculated value and the true value had a linear relationship shown in 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.

<figure><img src="image_10.png" /><figcaption>Figure 7 The linear regression model of predictive value and the true value</figcaption></figure>
## 4 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 = kx + b$ 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 non-destructive testing methods lay the foundation for online applications.

## Acknowledgment

Funds for this research was provided by the Public service sectors (agriculture) research and special funds for modern fishing digital and physical networking technology integration and demonstration (No. 201203017).

## References

1. Bobelyna, E., A. S. Serbanc, and M. Nic. 2010. Postharvest quality of apple predicted by NIR spectroscopy. Study of the effect of biological variability on spectra and model performance. *Postharvest Biology and Technology*, 55:133-143.

2. Chew, L., and X. G. Ma. 1995. Compare several commonly used methods for measuring the volume of the fruit of Chinese fruit, (2): 44-45.

3. Liu, Y. D., X. M. Chen, Y. Ou, and G. Ai. Non-destructive measurement of soluble solid content in Gannan navel or anges by visible/ near-Infrared spectros copy[J]. *Acta Optica Sinica*, 28(3):478-481.

4. Xin, R. G., Z. Z. Zhu, and J. M. Ning. 2012. Such as near in frared spectroscopy NDT tea ingredients based ATR spectral calibration laboratories, 29 (4): 2148-2154.

5. Sun, X. D., Y. Hao, and Y. D. Liu. 2013. Apple soluble solids detection influencing factors of near-infrared spectroscopy. *Online Chinese agricultural chemicals reported*, 34 (1): 86-90.

6. Ying Y. B., D. H. Han, J. Wang, and J. P. Wang. 2005. Agricultural nondestructive testing technology Beijing: Chemical Industry Press.

7. Cooke, J.R. An interpretation of the resonant behavior of intact fhjits and vegetables. Transactions of the Amercian Society of Agricultural Engineering. 1972, 15: 1075-1080.

8. Chuina, Y., Shiga,T.' Hikida, Y. Vibrational and impact response properties of agricultural products for non-destructive evaluation of internal quality (Part 1). The Japan America Society of Minnesota. 1977,39(3): 335-34.

9. YAN, W. X - ray medical applications [J] Chinese Medical Equipment, 2005, 2 (3): 31--32.
10. Sun, X. D., J. H. Wang, and W. S. Fu. 2007. Based on the X-ray image of the Apple online quickly measure the volume of SPIE, 27 (11):2096-2100.

11. Ye, A. O., and X. W. Zhang. 2013. SiPLS algorithm based on near-infrared spectroscopy pear soluble solids content Spectroscopy Laboratory, 30 (1): 68-72.