# A Detection Method of Rice Process Quality Based on the Color and BP Neural Network

Peng Wan, Changjiang Long, Xiaomao Huang

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

To cite this version:

Peng Wan, Changjiang Long, Xiaomao Huang. A Detection Method of Rice Process Quality Based on the Color and BP Neural Network. 4th Conference on Computer and Computing Technologies in Agriculture (CCTA), Oct 2010, Nanchang, China. pp.25-34, 10.1007/978-3-642-18333-1_4. hal-01559632

HAL Id: hal-01559632

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

Submitted on 10 Jul 2017

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 Detection Method of Rice Process Quality
Based on the Color and BP Neural Network

Peng Wan¹,², Changjiang Long¹, Xiaomiao Huang¹

¹ College of Engineering, Huazhong Agricultural University, Wuhan, P. R. China

² College of Biological and Agricultural Engineering, Jilin University, Changchun, P. R. China
wanpeng09@mail.hzau.edu.cn(Corresponding author),
longchj@mail.hzau.edu.cn, huangxiaomao@mail.hzau.edu.cn

**Abstract.** This paper proposed a detection method of rice process quality using the color and BP neural network. A rice process quality detection device based on computer vision technology was designed to get rice image, a circle of the radius R in the abdomen of the rice was determined as a color feature extraction area, and which was divided into five concentric sub-domains by the average area, the average color of each sub-region H was extraction as the color feature values described in the surface process quality of rice, and then the 5 color feature values as input values were imported to the BP neural network to detection the surface process quality of rice. The results show that the average accuracy of this method is 92.50% when it was used to detect 4 types of rice of different process quality.

**Keywords:** Process quality, Rice color, BP neural network, Rice

# 1 Introduction

Rice is one of the most important crops in the world, the staple food of about half of the world's population is rice. The harvested paddy needs be processed into rice for human consumption by the processes of huller, mill, polishing and so on. The evaluation standards of rice process quality including grain shape, appearance and color, chalky, fragmentation rate, et al. The process quality of rice is one of the most important factors to determine the appearance quality and the selling price of rice. In the process of rice, the process quality of rice often judged by skilled workers, but due to people's subjective factors, it is difficult to describe accurately the results of the process quality of rice.

With the development of science and technology, image analysis technology is widely used to detect and evaluate the rice quality[1][2][3][4]. The color of rice is one of the main factors of evaluating the quality[5]. While detecting the rice quality by the color features, people adopt more RGB color space and HIS color space; in addition, L*a*b* color space is also commonly used to extract the color feature value[6][7].

Since Rumelhart and others[8] proposed the back propagation algorithm, neural networks are widely used in many fields of agriculture. Majumdar S., D.S. Jayas and others[9] identified the type of grain by neural network system based according to the
characteristics of grain morphology; Kazuhiro Nakano[10] used the neural networks to identify the quality of Apple's appearance, and the experiments showed that the BP neural network can classify the apple into three classes by the color features of the apple.

The purpose of this paper is to propose a method of extracting rice color feature values, and detect the process quality of rice according to color feature values and through artificial neural network.

# 2 Materials and methods

## 2.1 Rice samples

The rice samples were Wan Chang Rice, produced in Changchun, Jilin Province. The samples of rice grain were processed by huller, milling, polishing and other processes, and then respectively obtained the rice samples with 500g of four different forms: brown rice (BR), the first process rice (FR), the second process of rice (SR), polished rice (PR), and then packaged in sealed bags and kept in the shade.

## 2.2 Computer vision system

In order to obtain images of rice grains, the paper designs of the rice quality detection vision system for collection the images of rice samples.

## 2.3 Rice image processing

To extract the color features of rice, rice needs to be extracted from the background image firstly. The process flow chart of a rice image was in Figure 1. The detection flow chart of rice process quality by image analysis was shown in Figure 2.
<figure><img src="image_3.png" /><figcaption>Fig. 1. The processing flow chart of rice image</figcaption></figure>

<figure><img src="image_4.png" /><figcaption>Fig. 2. The detection flow chart of rice process quality by image analysis</figcaption></figure>

## 2.4 Color extraction

For extracting the color values of rice image, we must first identify the color region in the abdomen of the rice. In order to guarantee every rice' color extraction region contains the same number of pixels, this paper detected the equal area in the abdomen of the rice.

This paper firstly calculates the centroid of rice image by image processing, then an extraction region of the color values of rice image (CA, Color Area) is identified, which has the centroid of rice image and a circle of radius R. The extraction region of the color values of rice image (CA) must be in the outline of the rice image.

The pixel coordinates of the rice image are expressed as {(xi, yi) | 0 ≤ i ≤ M, M is the pixel image points}, and the centroid coordinate of the rice image is (X, Y), then:
$$ \left\{ \begin{aligned} X &= \frac{1}{M} \sum_{i=0}^{M} x_i \\ Y &= \frac{1}{M} \sum_{i=0}^{M} y_i \end{aligned} \right. \qquad (1) $$

The color extraction regional diagram of rice image is in Figure 3.

<figure><img src="image_5.png" /><figcaption>Fig. 3. The color extraction region diagram of rice image</figcaption></figure>

The extraction region of the color values of rice image (CA) was divided into 5 equal sub-regions (Sa, Sub area) by the concentric circles which have a centroid coordinate(X, Y) and ranging radius. The sub-regions have the number for the Saᵢ (i = 1,2, ... 5) from the inside to the outside of the circle. Set the concentric circles in the CA have the radius of rᵢ(i = 1,2, ... 5), the sketch map of 5 sub-regions in CA is shown in Figure 4.

<figure><img src="image_6.png" /><figcaption>Fig. 4. The sketch map of 5 sub-regions in CA</figcaption></figure>

The relationship between the radiuses rᵢ of the concentric circles and the radius R of the rice color extraction region (CA) is:

$$ r_i = \sqrt{\frac{i}{5}} R \qquad (2) $$

In this paper, the average value of the pixel color values in sub-regional Saᵢ of the CA is the color value of sub-regional Saᵢ, and then the color of every rice can be described by 5 color values extracted from the CA.
## 2.5 Color conversion

The rice images obtained by the CCD are based on RGB color space. HSI color model is based on the human visual, which describe the color by using the Hue(H), Saturation(S) and Intensity(I) to sort. As HSI color mode is related with the hardware features, and is little sensitivity to the light source. This paper describes the rice color by using the HSI color system.

Firstly, the RGB color values of rice pixel in CA are extracted, and then the RGB color values are converted to HSI color values.

According to the characteristics of HSI color system, this paper uses the hue values H as the color characteristic values detecting the rice process quality. As the rice color extraction area (CA) in this paper is divided into 5 equal sub-regions, the color characteristic values of each sub-region is set to $H_i(i = 1,2, ... 5)$, then each rice color feature value could be described as follow:

$$H^* = (H_1, H_2, H_3, H_4, H_5) \qquad (3)$$

## 2.6 The identification method of rice process quality

In this paper, BP neural network model is used to detect the process quality of rice. The rice samples of four forms are respectively selected to be used to image analysis, and to obtain the color feature value for making up of the sample set of the neural network training set. Suppose the detection values of brown rice (BR), first process rice (FR), second process rice (SR), polished rice (PR) are 0、1、2、3, and then the goals set of the neural network training set is (0, 1, 2, 3). Other 40 full rice are respectively selected from the rice samples of four forms to obtain the color feature value for making up of the detection set of the neural network.

The BP neural network in this paper has three layers, the number of input layer neurons is 5, that is the number of the color feature values of rice samples; the number of output layer neuron is 4, and the output signal is (0, 1, 2, 3), and which respectively denotes the rice sample of BR, FR, SR, PR; the number of hidden layer neurons is confirmed according to the accuracy of the test results by using MATLAB software and test set. Neural network identification function is the logistic function:

$$f(x) = \frac{1}{1 + \exp(-x)} \qquad (4)$$

# 3 Results and discussion

## 3.1 Obtain the images of rice samples
First of all, 120 rice are respectively selected from the 4 rice samples which have different process grade, then the rice images are obtained by the rice quality detection vision system. The rice images of four forms samples are shown in Figure 5.

<figure><img src="image_7.png" /><figcaption>**Fig. 5.** Rice sample images of different forms. (1)brown rice samples (BR); (2)the first process rice samples (FR); (3)the second process rice sample (SR); (4)polished rice samples (PR)</figcaption></figure>

From Figure 6, brown rice(1) has the hard cuticle on the external layer, so brown rice shows a different color from the rice, and the outer layer of the brown is smooth; After milling, brown rice is processed into the initial processing rice samples(2), and as cutting through the rice milling machine, the outer layer of brown rice most of the stratum corneum epidermidis is cut, thus the entire outer layer of brown rice puts up mixture colors. After the second milling, brown rice is processed into secondary processing rice samples(3), then the outer layer of the stratum corneum epidermidis of whole rice is almost cut and shows the color of the rice, and at the same time, the outer layer of the rice will produce more fine particles, the surface of the rice is not smooth; After the second milling process, rice is polished into rice sample(4) by polishing processing, the fine particle layer of rice surface is removed, and the rice shows glossy color.

## 3.2 Rice image processing

The goal image of rice can be obtained from the rice image through the rice image process, and the object images of rice are shown in Figure 6.

<figure><img src="image_8.png" /></figure>
<figure><img src="image_9.png" /><figcaption>**Fig. 6.** The object images of rice samples (1) object image of BR; (2) object image of FR; (3) object image of SR; (4) object image of PR</figcaption></figure>

### 3.3 Extract the color feature value of rice

After the rice goal image was separated from the background, the color extraction area (CA) of the rice is firstly identified, and then the color feature values are extracted. The schematic diagram of the color extraction area (CA) of rice is shown in Figure 7. The radius R of the largest circle (CA) is 60, the CA is divided into five equal parts by the red circles, and code-named of the rice color feature extraction sub-regions from the inner circle to the cylindrical are $Sa_1, Sa_2, Sa_3, Sa_4, Sa_5$.

<figure><img src="image_10.png" /><figcaption>**Fig. 7.** Schematic diagram of the color feature extraction region</figcaption></figure>

The color feature values of each 120 samples in four form rice are extracted, and the relationship between the image pixels contained in the color feature extraction region of rice image and the image pixels contained in the rice image is shown in Table 1.

<table><caption>**Table 1.** The relationship of the image pixels contained in the equal portion circles of the rice image</caption><thead><tr><th>Color extraction region</th><th>Sa<sub>1</sub></th><th>Sa<sub>2</sub></th><th>Sa<sub>3</sub></th><th>Sa<sub>4</sub></th><th>Sa<sub>5</sub></th><th>CA</th></tr></thead><tbody><tr><td>pixel points</td><td>2286</td><td>2272</td><td>2270</td><td>2264</td><td>2264</td><td>11356</td></tr><tr><td>percentage of total CA</td><td>20.13</td><td>20.01</td><td>19.99</td><td>19.94</td><td>19.94</td><td>100%</td></tr><tr><td>percentage of total image (%)</td><td>5.19</td><td>5.16</td><td>5.16</td><td>5.14</td><td>5.14</td><td>25.79</td></tr></tbody></table>

prompt: the rice sample images have an average 44016 pixels.

From the table, the color extraction area (CA) contains 11 356 pixels; the pixels contained in the sub regions were 2286, 2272, 2270, 2264, 2264 and the error
between the sub-region is less than 22 pixel; the percentages of total CA were 20.13%, 20.01%, 19.99%, 19.94%, 19.94%, the error is less than 0.19%; rice image contains an average of 44 016 pixels, the pixels points in CA is 25.79% of total pixel points of rice image; the percentages of the pixel points in sub-regions were 5.19%, 5.16%, 5.16%, 5.14%, 5.14% of the average total pixel points of rice images, the error is less than 0.05%. Therefore, the method of the division of the rice color extraction region into 5 equal sub-regions can insure the rice pixel points in every color feature extraction sub-region are equal.

## 3.4 Variation rules of color feature values

The color feature values were extracted from 120 rice samples for four forms of rice respectively, and then transformed the color feature value from the RGB color space into the HSI color space, and the average values of the color characteristics H of four forms of rice samples were shown in Table 2.

<table><caption>**Table 2.** The color characteristics H for four forms of rice samples</caption><thead><tr><th rowspan="2">rice sample</th><th colspan="5">The color feature value of the color featureextraction region</th></tr><tr><th>Sa<sub>1</sub></th><th>Sa<sub>2</sub></th><th>Sa<sub>3</sub></th><th>Sa<sub>4</sub></th><th>Sa<sub>5</sub></th></tr></thead><tbody><tr><td>BR</td><td>1.3624</td><td>1.8812</td><td>1.8509</td><td>1.9821</td><td>1.4798</td></tr><tr><td>FR</td><td>3.1121</td><td>2.5987</td><td>2.5019</td><td>2.2124</td><td>2.5013</td></tr><tr><td>SR</td><td>3.5502</td><td>2.9942</td><td>3.1421</td><td>2.9278</td><td>2.6696</td></tr><tr><td>PR</td><td>3.9702</td><td>3.6774</td><td>3.0815</td><td>3.7286</td><td>3.1869</td></tr></tbody></table>

From the Table 2, there are some variation rules between the color feature values H of 4 rice samples. The color feature values $H_i(i=1, 2, \dots, 5)$ of the same rice samples of different process methods don't have significant variation rules, which are the same with the different structure and distribution of the composition in rice and the milling and polishing process in the different regions of the rice surface. But among the different forms of rice samples, the color feature values $H_i(i=1, 2, \dots, 5)$ increased significantly on the whole. when the rice sample is brown rice, H values are in the range[1.3624, 1.9821]; when brown rice are milled through first process, H values are in the range[2.2124, 3.1121]; after the second milling process, H values are in the range[2.6696, 3.5502], after the rice polished, H values are in the range[3.0815, 3.9702]. Obviously, this is the same with the removal process of the cuticle layer and the aleurone layer on the surface of the rice by milled and polished.

The distribution histogram of the color feature values $H_i (i = 1, 2, \dots, 5)$ of 4 rice samples is shown in Figure 8.
<figure><img src="image_11.png" /><figcaption>Fig. 8. The relationship between the color feature values H of 4 rice samples</figcaption></figure>

From the figure 8, as for the different forms of rice samples in the same color feature extraction sub-region, the color feature values H change with the milling process and present a growing trend.

Consolidated Table 2 and Figure 8, rice samples show the appearance of different colors with the rice milling process; and the color feature values of rice samples show some variation rules.

## 3.5 Identification of rice process quality

The train set is established adopting the color feature values H and detection values of 100 rice samples of 4 forms to train the BP neural network, and then the BP neural network is verified through the color feature values H and detection values of 50x4 rice samples of 4 forms, and the detection result of the number of different hidden layer neurons is shown in Table 3.

<table><caption>Table 3. The color detection results of the rice sample using BP neural network</caption><thead><tr><th rowspan="2"></th><th rowspan="2">rice samples</th><th colspan="5">The number of hidden layer neurons and the detection results</th></tr><tr><th>Sa<sub>1</sub></th><th>Sa<sub>2</sub></th><th>Sa<sub>3</sub></th><th>Sa<sub>4</sub></th><th>Sa<sub>5</sub></th></tr></thead><tbody><tr><td rowspan="2">BR</td><td>the number of rice</td><td>45</td><td>44</td><td>47</td><td>46</td><td>47</td></tr><tr><td>accuracy rates(%)</td><td>90.00</td><td>88.00</td><td>94.00</td><td>92.00</td><td>94.00</td></tr><tr><td rowspan="2">FR</td><td>the number of rice</td><td>45</td><td>48</td><td>48</td><td>46</td><td>43</td></tr><tr><td>accuracy rates(%)</td><td>90.00</td><td>96.00</td><td>96.00</td><td>92.00</td><td>86.00</td></tr><tr><td rowspan="2">SR</td><td>the number of rice</td><td>40</td><td>41</td><td>44</td><td>44</td><td>41</td></tr><tr><td>accuracy rates(%)</td><td>80.00</td><td>82.00</td><td>88.00</td><td>88.00</td><td>82.00</td></tr><tr><td rowspan="2">PR</td><td>the number of rice</td><td>43</td><td>45</td><td>46</td><td>45</td><td>46</td></tr><tr><td>accuracy rates(%)</td><td>86.00</td><td>90.00</td><td>92.00</td><td>90.00</td><td>92.00</td></tr></tbody></table>

From the table, when the number of hidden layer neuron is 15, the rice samples' overall accurate rate identification is highest, the accurate rate of brown rice is 94.00%, and the accurate rate of first process rice is 96.00%, the accurate rate of second process rice is 88.00%, and the accurate rate of the polished rice is 92.00%, the overall identification accuracy rates is 92.50%.
From above mentioned, detect the rice process quality can achieve a satisfactory result by constructing the 3 layers BP neural network with 5 neurons in the input layer, 15 neurons in the hidden layer, 4 neurons in the output layer, and discriminate function of the logistic-type function, and using the rice color feature values H extracted from the surface of the rice samples.

## 4 Conclusions

In this paper, the method of detecting rice process quality was verified by experiments based on the color and BP neural network.

First of all, the rice images was obtained, then definite color feature extraction region, and then the color feature extraction region is divided into five color feature extraction sub-regions of the same area with concentric circles of different radius. The color values H of the color feature extraction sub-regions are regarded as the color feature value of the rice, and finally a BP neural network of three layers is adopted to detect the process quality of the rice. The experiment's results show that accuracy rate of this method of extracting the hue values of the rice image to detect the process quality of the rice is 92.5%.

## References

1. Hou Caiyun, Seiichi Oshita, Yasuhisa Seo, et al. Application of 3D-Microslicing image processing system in rice quality evaluation[J]. Transactions of The Chinese Society of Agricultural Engineering, 2001, 17(3):92-95

2. Ling Yun, Wang Yiming, Sun Ming, et al. A machine vision based instrument for rice appeara-nce quality[J]. Transactions of The Chinese Society of Agricultural Machinery, 2005, 36(9):89-92

3. Wan Y N, Lin C M. Rice quality classification using an automatic grain quality inspection syste-m[J]. Transaction of ASAE, 2002, 45(2):379-387

4. M. Z. Abdullah, L. C. Guan, K. C. Lim. The applications of computer vision system and tomogr-aphic radar imaging for assessing physical propert-ies of food[J]. Journal of Food Engineering, 2004, (61):125-135

5. Shang Yanfen, Hou Caiyun, Chang Guohua. Automatic detection of yellow-colored rice using image recognition[J]. Transactions of The Chinese Society of Agricultural Engineering, 2004, 20(4): 146-148

6. Cai Jianrong. An analysis of color models and criteria for their application to quality test of farm products[J]. Journal of JiangSu University of Science and technology, 1997,18(5):22-25

7. Vizhanyo T, Felfoldi J. Enhancing color differences in images of diseased mushrooms[J]. Computers and Electronics in Agriculture, 2000, 26(2):187-198

8. Rumelhart D. E., Hinton G. E., Williams R. J.. Learning representations by backpropagation errors[J]. Nature, 1986, (323):533-536

9. Majumdar S., D. S. Jayas. Classification of cereal grains using machine vision: Morphology models.Trans of the ASAE, 2000, 43(6):1669-1675

10. Kazuhiro Nakano. Application of neural networks to the color grading of apples[J]. Computers and electronics in agriculture, 1997, 18:105-116