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

HAL
open science

# An Automatic Counting Method of Maize Ear Grain Based on Image Processing

Mingming Zhao, Jian Qin, Shaoming Li, Zhe Liu, Jin Cao, Xiaochuang Yao, Sijing Ye, Lin Li

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

## To cite this version:

Mingming Zhao, Jian Qin, Shaoming Li, Zhe Liu, Jin Cao, et al. An Automatic Counting Method of Maize Ear Grain Based on Image Processing. 8th International Conference on Computer and Computing Technologies in Agriculture (CCTA), Sep 2014, Beijing, China. pp.521-533, 10.1007/978-3-319-19620-6_59. hal-01420267

HAL Id: hal-01420267

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

Submitted on 20 Dec 2016

HAL is a multi-disciplinary open access archive for the deposit and dissemination of scientific research documents, whether they are published 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_3.png" /></figure>

Distributed under a Creative Commons Attribution 4.0 International License
# An Automatic Counting Method of Maize Ear Grain

## Based on Image Processing

Mingming Zhao¹, Jian Qin², Shaoming Li¹, Zhe Liu¹, Jin Cao¹, Xiaochuang Yao¹, Sijing Ye¹, Lin LI*¹

(1.China Agricultural University, Beijing 100083, China

2.IBM China Development Labs, CDL, Beijing, China)

**Abstract:** Corn variety testing is a process to pick and cultivate a high yield, disease resistant and outstandingly adaptive variety from thousands of corn hybrid varieties. In this process, we have to do a large number of comparative tests, observation and measurement. The workload of this measurement is very huge, for the large number of varieties under test. The grain numbers of maize ear is an important parameter to the corn variety testing. At present, the grain counting is mostly done by manpower. In this way, both the deviation and workload is unacceptable. In this paper, an automatic counting method of maize ear grain is established basing on image processing. Image segmentation is the basis and classic difficult part of image processing. This paper presents an image pre-processing method, which is based on the characteristics of maize ear image. This method includes median filter to eliminate random noise, wallis filter to sharpen the image boundary and histogram enhancement. It also mainly introduces an in-depth study of Otsu algorithms. To overcome the problems of Otsu algorithm that background information being erroneously divided when object size is small. A new method based on traditional Otsu method is proposed, which combines the multi-threshold segmentation and RBGM gradient descent. The implementation of RBGM gradient descent leads to a remarkable improvement on the efficiency of multi-threshold segmentation which is generally an extremely time-consuming task. Our experimental evaluations on 25 sets of maize ear image datasets show that the proposed method can produce more competitive results on effectiveness and speed in comparison to the manpower. The grain counting accuracy of ear volume can reach to 96.8%.

**Keywords:** grain counting, Otsu, multi-threshold segmentation, RBGM gradient descent

## 1 Introduction

During the corn variety testing, the grain numbers of maize ear is an important parameter to the corn variety testing[1]. At present, the grain counting is mostly done by manpower. In this way, both the deviation and workload is unacceptable. In addition, the subjective errors are not easy to be avoided and the efficiency of manual measurement is very low. So this paper proposes a fast and high-accuracy automatic counting method of maize ear grain based on image processing. For the special

Received date: 201X-XX-XX Accepted date: 201X-XX-XX

* Corresponding author: Lin LI, Professor, China Agricultural University

Email:lilincau@126.com. Tel:13621097034
structure feature of maize ear grain, we need to find a new image segmentation algorithm and an automatic counting method of maize ear grain. It has high quality and high efficiency.

## 2 Review of Related Researches

Traditional image segmentation method mainly contains threshold segmentation, edge detection segmentation, region segmentation and segmentation method based on mathematical. At present some new image segmentation methods come up with the deep-research in image process.

In 1998 S.Beucher and C.Lantuéjoul proposed an image segmentation algorithm[2][3], watersheds in digital spaces, based on immersion simulations. Roughly speaking, it was based on a sorting of the pixels in the increasing order of their gray values, and on fast breadth-first scannings of the plateaus enabled by a first-in-first-out type data structure. This algorithm turned out to be faster and behave well in image segmentation. However this algorithm often has the problem of over-segmentation due to the tiny noise on the image. As illustrated by Figure1, the segmentation result of the maize ear grain based on watersheds has the problem of the over-segmentation, in this way, which is unacceptable.

<figure><img src="image_4.png" /><figcaption>Figure 1. Applying watersheds to the maize ear grain image. A: Original images from part of maize ear grain. B: Gray image of A. C: Gray image after filter. D: Result image of watersheds.</figcaption></figure>

In these years, there are some popular image segmentation algorithms based on active contour model, such as Snakes and MS model[4]. Snakes are active contour models, MS models are level set models. Applications of this algorithm with regard to tracking the face activity, medicine CT image segmentation and cell image segmentation, but this algorithm has the problem of huge calculations and slow-speed in image segmentation. As shown by Figure2, with the increase of iterations, it needs more time in image segmentation, which can't meet the need of corn variety testing.

<figure><img src="image_5.png" /></figure>
Figure 2. Applying level set method to the maize ear grain image. A: Convergence result with iterations of 300 times. B: Convergence result with iterations of 1400 times. C: Convergence result with iterations of 4000 times.

The threshold segmentation is the most popular algorithm and is widely used in the image segmentation field[5]. The basic idea of threshold segmentation algorithm is to select an optimal or several optimal gray-level threshold values for separating objects of interest in an image from the background based on their gray-level distribution. The classical threshold segmentation algorithm include histogram shape-based methods, clustering-based methods (Otsu), mutual information methods, attribute similarity-based methods, local adaptive segmentation methods, etc. Among them, Otsu method has received more attention and frequently used in various fields.

As is illustrated in Figure3, Otsu method behaves well in segmenting image of maize ear grain. But it doesn't give the satisfactory results because of the grains not separated completely. So to overcome this problem, this paper propose a new method that combines the multi-threshold segmentation and RBGM, based on Otsu method. It turns out to be high-accuracy and time-saving, which can meet the actually need of the corn variety testing.

<figure><img src="image_6.png" /><figcaption>Figure 3. Applying Otsu method to the maize ear grain image. A: gray image of maize ear grain. B: Gray histogram image of A. C: The segmentation image with Otsu of A. D: The gray image of complete maize ear grain image. E: Gray histogram image of D. F: The segmentation image with Otsu of D.</figcaption></figure>

Image segmentation is not only an important part but also a challenge part in image process. At present, the successful image process study on grains is mostly about soybean and wheat. Due to the feature of maize ear grain, there are not particular and efficient image segmentation algorithms for maize ear grain. YiXun[6] proposed an automatic segmentation of touching corn kernels in digital image, which releases automatic segmentation of touching corn kernels. Yaqiu Zhang[7] proposed a method that separates corn seeds images based on threshold changed gradually. Both of these methods have to take grains off the maize ear, which needs plenty of work for the corn variety testing.

So this paper proposes an image segmentation algorithm based on multi-threshold segmentation and RBGM (row-by-row gradient based method) for maize ear grain image.

### 3 Image preprocess
Image preprocess is an essential part to the image segmentation, which can enhance the visual appearance of images and improve the manipulation of datasets, including image resampling, greyscale contrast enhancement, noise removal, mathematical operations and manual correction. Enhancement techniques can emphasize image artefacts, or even lead to a loss of information if not correctly used. So this paper proposed a particular series of image preprocess methods based on the classical method for the feature of the maize ear grain, as follows:

## Median filter

Classical median filter algorithm only use the information of statistical in gray image, without considering the importance of other spatial information and different apex. So, we use the weighted median filtering method to remove noise, which is given by:

$$f'(x_0, y_0) = \left[ \text{Sort}_{(x_i, y_j) \in S} \omega_{ij} f(x_i, y_j) \right]_{\frac{|S|+1}{2}} \quad (1)$$

## Wallia filter algorithm

Wallia propose an adaptive operator to sharpen the edge based on the feature of Laplacian operator. Let the $[f(i, j)]_{M \times N}$ denote the original image, $\bar{f}(i, j)$ and $\sigma(i, j)$ denote the mean and the standard deviation, $[g(i, j)]_{M \times N}$ denote the pixel values of the image after image enhancement, these values are given by:

$$\bar{f}(i, j) = \frac{1}{M} \sum_{(m,n) \in D_{ij}} f(m,n) \quad (2)$$

$$\sigma(i, j) = \frac{1}{M} \sum_{(m,n) \in D_{ij}} [f(m,n) - \bar{f}(i, j)]^2 \quad (3)$$

$$g(i, j) = [\alpha m_d + (1 - \alpha) \bar{f}(i, j)] + [f(i, j) - \bar{f}(i, j)] \frac{A \sigma_d}{A \sigma(i, j) + \sigma_d} \quad (4)$$

## Histograms enhancement algorithm

Image enhancement is a mean as the improvement of an image appearance by increasing dominance of some features or by decreasing ambiguity between different regions of the image. Histogram processing is the act of altering an image by modifying its histogram, which is better suited for segmentation by multi-threshold algorithm.

# 4 Image Segmentation Algorithm

## 4.1 Multi-threshold Segmentation

In 1979, N. Otsu proposed the maximum class variance method (known as the Otsu method). For its simple calculation, stability and effectiveness, it has been widely used, was a well-behaved automatic threshold selection method, and its consumed time is significantly less than other threshold algorithms[8].

Set the pixels of segmentation image as N, there are L gray levels (0,1,...,L-1), $n_i$
pixels whose gray level is $i$, then $N = \sum_{i=0}^{L-1} n_i$, and we express the probability density distribution with the form of histogram $p_i = \frac{n_i}{N}$, $\sum_{i=0}^{L-1} n_i = 1, p_i \ge 0$. Let an image be divided into two classes $C_0$ and $C_1$ by threshold $t$. $C_0$ consists of pixels with levels $[1,...,t]$ and $C_1$ consists of pixels with levels $[t+1,...,L]$. Let $u_0$ and $u_1$ denote the mean levels, $\sigma^2$ denote the between-class variances of the classes $C_0$ and $C_1$, respectively. These values are given by:

$$ \mu_0 = \frac{\sum_{i=0}^{t} ip_i}{p(t)} = \frac{\mu_0(t)}{p(t)} \qquad (9) $$

$$ \mu_1 = \frac{\sum_{i=t+1}^{L-1} ip_i}{1-p(t)} = \frac{\mu_1(t)}{1-p(t)} \qquad (10) $$

$$ \sigma_t^2 = p(t)(1-p(t))(\mu_1 - \mu_0)^2 \qquad (11) $$

The threshold $t^*$ decided by maximizing the between-class variance proposed in Otsu is:

$$ \sigma_{t^*}^2 = \mathrm{Max}(\sigma_t^2) \quad t \in G \qquad (12) $$

The shortage of Otsu algorithm is that Otsu algorithm is suitable on condition that there are two categories in the image; when there are more than two categories in the image, Otsu can't make the background and the target separate like Figure3. So as to decide multi-threshold. The approach allows the largest between-class variance and the smallest in-class variance.

Based on Otsu, we can make out the multi-threshold as follows. Let an image be divided into n classes by threshold $t$, $t = \{t_k | k = 1, 2, ..., n-1\}$. Let $\omega_k$ denote the probability of each class, $\mu_k$ denote the mean levels of each class, $\sigma_k^2$ denote variances of each class. These values are given by:

$$ \omega_k = \sum_{i=t_k}^{t_{k+1}} P_i \quad k = 0, 1, ..., n-1 \qquad (13) $$

$$ \mu_k = \sum_{i=t_k}^{t_{k+1}} iP_i / \omega_k \quad t_0 = 0, t_n = L \qquad (14) $$

$$ \sigma_k^2 = \sum_{i=t_k}^{t_{k+1}} (i - \mu_k)^2 P_i / \omega_k \quad 1 < t_k < L(k = 1, 2, ..., n-1) \qquad (15) $$
Let $\sigma_w^2$ means the within-class variance, $\sigma_B^2$ means the between-class variance, respectively:

$$ \sigma_w^2 = \sum_{k=0}^{n-1} \omega_k \sigma_k^2 \qquad (16) $$

Similar to the classical Otsu algorithm, we have multi-threshold constraint equation:

$$ \sigma^2 = \sum_{i=1}^{L} (i - \mu)^2 P_i = \sum_{i=1}^{L} i^2 P_i - 2\mu \sum_{i=1}^{L} i P_i + \mu^2 \sum_{i=1}^{L} P_i = \sum_{i=1}^{L} i^2 P_i - \mu^2 \qquad (17) $$

According to (15), we have:

$$ \sigma_k^2 = \sum_{i=1}^{L} (i - \mu_k)^2 P_i / \omega_k = \frac{1}{\omega_k} \left( \sum_{i=1}^{L} i^2 P_i - 2\mu_k \sum_{i=1}^{L} i P_i + \mu_k^2 \sum_{i=1}^{L} P_i \right) = \frac{1}{\omega_k} \left( \sum_{i=1}^{L} i^2 P_i - 2\omega_k \mu_k^2 + \omega_k \mu_k^2 \right) \qquad (18) $$

Then

$$ \sum_{i=k}^{j=k+1} i^2 P_i = \omega_k (\mu_k^2 + \sigma_k^2) \qquad (19) $$

According to (14) (17) (19), we have:

$$ \sigma^2 = \sum_{k=0}^{n-1} \omega_k (\mu_k^2 + \sigma_k^2) - (\sum_{k=0}^{n-1} \omega_k \mu_k)^2 \qquad (20) $$

Then According to (16) (20), we have:

$$ \sigma_B^2 = \sigma^2 - \sigma_w^2 = \sum_{k=0}^{n-1} \sum_{j=k+1}^{n-1} \omega_k \omega_j (\mu_k - \mu_j)^2 \qquad (21) $$

## 4.2 RBGM algorithm

When the threshold $t^*$ decided by maximizing the between-class variance of multi-threshold proposed in $\sigma_B^2 = \sigma^2 - \sigma_w^2 = \sum_{k=0}^{n-1} \sum_{j=k+1}^{n-1} \omega_k \omega_j (\mu_k - \mu_j)^2$. However, with the increase of threshold from single to n, the resolution problem of $\sigma_B^2$ is changing from function of variable into multivariate function, which will needs plenty of time in selecting threshold. To overcome this problem, this paper take the method of the RBGM (row-by-row gradient based method). Given by:

$$ x_i^{mN+j+1} = x_i^{mN+j} - \eta_m \Box_i (x_i^{mN+j}), \quad i=1,2,...,N \qquad (22) $$

$$ \Box_i (x^{mN+j}) = \begin{cases} \frac{\partial f(x^{mN+j})}{\partial x^i}, & j=i-1, \\ 0, & j \neq i-1 \end{cases}, \quad j=0,1,...,N-1; \quad m=0,1,... \qquad (23) $$

The RBGM method is described as follows:

**Step 1:** given an initial point $x^0 = (x_1^0, x_2^0, \dots, x_N^0) \in \mathbb{R}^N$, error precision $\varepsilon > 0$, and Maximum Iterations $M_{max}$. Set $m := 0, j := 0$.

**Step 2:** complete a cycle to update $x^{mN+j}$ as follows:
$$ \text{for } m = 0: M_{\max} $$

$$ \text{for } j = 0: N-1 $$

$$ x_i^{mn+j+1} = x_i^{mn+j} - \eta_m \Box_i (x_i^{mn+j}) $$

$$ \Box_i (x^{mn+j}) = \begin{cases} \frac{\partial f(x^{mn+j})}{\partial x^i} & j = i - 1 \\ 0 & j \neq i - 1 \end{cases} $$

$$ j = j + 1 $$

$$ m = m + 1 $$

**Step 3:** if $f(x^{mN+j})$ satisfy the ending rules, terminate the algorithm and output $x^{mN+j}$. Otherwise go to step 2.

According to $\sigma_B^2 = \sigma^2 - \sigma_w^2 = \sum_{k=0}^{n-1} \sum_{j=k+1}^{n-1} \omega_k \omega_j (\mu_k - \mu_j)^2$ and the method RBGM, we

have:

$$ \begin{align} \frac{\partial \sigma_k^2}{\partial t_i} \tag{24} \\ &= \frac{\partial \left( \sum_{i=1}^{n-1} \sum_{j=k+1}^{n-1} \omega_k \omega_j (\mu_k - \mu_j)^2 \right)}{\partial t_i} \\ &= (p(t_i)\omega_{i-1} + p(t_{i+1})\omega_j)(\mu_k - \mu_{i+1})^2 + 2\omega_k p(t_i)(t_i - \mu_k) + 2\omega_j p(t_{i+1})(t_{i+1} - \mu_{i+1}) + \sum_{j=i+1, j \neq i+1}^{n} (\omega_j(\mu_k - \mu_j)^2 + 2\omega_j\omega_k) \nonumber \end{align} $$

Then we can get Multi-threshold segmentation iterative solution function:

$$ x_i^{mN+j+1} = x_i^{mN+j} - \eta_m \frac{\partial \sigma_B^2}{\partial t_i}, i=1,2,...,N \quad (25) $$

Given the initial point $\vec{t}_*$ and iteration step $\eta_m$, we can get the best threshold.

# 5 An automatic Counting Model of Maize Ear Grain

Counting the number of grains in binary image after multi-threshold by connected component labeling method. Let $p(x, y)$ denote the value pixel of the point $(x, y)$. The connected component in binary image are classified into two groups: the with value of one stands for maize grains, the $p(x, y)$ with value of zero stands for the background.

Then, the binary image is followed by a line-by-line counter to find all the connected component with the value of one. Finally we can get the number of the grains in image, but we should find a method of counting the total number of grains.

According to the biological nature of maize ear grain, the number of maize ear's rows is always double. So we did plenty of experiment, we found that the number of maize ear's rows is always 12 or 14. In this way, we proposed a maize ear grain estimation model that the total number of the grains has a linear relationship with the number of grains in image we collect, on the basis the rows is straight and neat. The model is given by:

$$ y = 1.9427x + 9.2498 \quad R^2 = 0.9664 $$

y means the total number of grains, x means the number of grains in image.

# 6 Experiment and Result Analysis

## 6.1 Experiment

In this paper an automatic counting method of maize ear grain based in image process
was proposed, and the detail experiment method was given as follows:

**Step 1:** We take pictures of 20 maize ear grain with digital camera. After collect maize ear grain image, we count the grains number of each maize ear and that in image as training data to obtain the maize ear grain estimation model. The obtained original maize ear grain image is shown in Figure 4

<figure><img src="image_7.png" /><figcaption>Figure 4. Data collecting. A, B: Original maize ear grain image.</figcaption></figure>

**Step 2:** A series of work with image preprocessing methods. First, the color image should be converted to the gray image. Then take median filter method with (1) to eliminate random noise of gray image, and wallis filter method with (4) to sharpen the image boundary. Finally, histogram enhancement method. The image preprocess image is shown in Fig 5.

<figure><img src="image_8.png" /><figcaption>Figure 5. Image preprocessing. A: Image before median filter method. B: Result image after median filter method. C: Image before wallis filter method. D: Result image after wallis filter method. E: Image before histogram enhancement method. F: Result image after histogram enhancement method.</figcaption></figure>

**Step 3:** Image segmentation with multi-threshold algorithm by (25) and obtain binary image of maize ear grain. Automatic counting method with connected component labeling method. The obtained image is shown in Fig 6.

<figure><img src="image_9.png" /><figcaption>Figure 6. Multi-threshold method result image. A: Original maize ear grain image. B: The result image of classical Otsu method. C: The result image of multi-threshold method. D: Result image with connected component labeling method.</figcaption></figure>
**Step 4:** Maize ear grains counting with an automatic counting model y = 1.9427x + 9.2498 after obtaining the grains number in image, the results is shown in Table 1.

**6.2 Analysis of experiment results**

From the table 1, we can see that the rows of maize is always double and the number is most 12 or 14. The fitted curves for the total number of maize grains to the part number of maize grains in image obtained from tests are plotted, and empirical expressions for these curves worked out by regressive analysis are given by :

$$y = 1.9427x + 9.2498 \quad R^2 = 0.9664$$

y denote the total number of maize ear grains, x denote the part number of maize ear grains in image we collect. It turns out well with R²=0.9664 and the average error is 1.2%.

<table><caption>**Table 1: the training data for estimation model**</caption><thead><tr><th rowspan="2">ID</th><th colspan="2">Total Maize</th><th colspan="2">Maize in Image</th><th colspan="2">Estimation Model</th></tr><tr><th>Grains number</th><th>Rows</th><th>Grains number</th><th>Rows</th><th>Estimated Value</th><th>Error</th></tr></thead><tbody><tr><td>1</td><td>485</td><td>14</td><td>243</td><td>7</td><td>481</td><td>0.008</td></tr><tr><td>2</td><td>487</td><td>14</td><td>244</td><td>7</td><td>483</td><td>0.008</td></tr><tr><td>3</td><td>374</td><td>10</td><td>189</td><td>5</td><td>376</td><td>0.006</td></tr><tr><td>4</td><td>474</td><td>12</td><td>237</td><td>6</td><td>470</td><td>0.009</td></tr><tr><td>5</td><td>453</td><td>12</td><td>235</td><td>6</td><td>466</td><td>0.028</td></tr><tr><td>6</td><td>484</td><td>14</td><td>247</td><td>7</td><td>489</td><td>0.011</td></tr><tr><td>7</td><td>485</td><td>14</td><td>240</td><td>7</td><td>475</td><td>0.020</td></tr><tr><td>8</td><td>487</td><td>14</td><td>243</td><td>7</td><td>481</td><td>0.012</td></tr><tr><td>9</td><td>374</td><td>10</td><td>186</td><td>5</td><td>371</td><td>0.009</td></tr><tr><td>10</td><td>474</td><td>12</td><td>238</td><td>6</td><td>472</td><td>0.005</td></tr><tr><td>11</td><td>453</td><td>12</td><td>239</td><td>6</td><td>474</td><td>0.045</td></tr><tr><td>12</td><td>484</td><td>14</td><td>244</td><td>7</td><td>483</td><td>0.002</td></tr><tr><td>13</td><td>485</td><td>14</td><td>242</td><td>7</td><td>479</td><td>0.012</td></tr><tr><td>14</td><td>487</td><td>14</td><td>242</td><td>7</td><td>479</td><td>0.016</td></tr><tr><td>15</td><td>374</td><td>10</td><td>187</td><td>5</td><td>373</td><td>0.004</td></tr><tr><td>16</td><td>474</td><td>12</td><td>239</td><td>6</td><td>474</td><td>0.001</td></tr><tr><td>17</td><td>453</td><td>12</td><td>237</td><td>6</td><td>470</td><td>0.037</td></tr><tr><td>18</td><td>484</td><td>14</td><td>241</td><td>7</td><td>477</td><td>0.014</td></tr><tr><td>19</td><td>485</td><td>14</td><td>244</td><td>7</td><td>483</td><td>0.004</td></tr><tr><td>20</td><td>375</td><td>10</td><td>188</td><td>5</td><td>374</td><td>0.001</td></tr></tbody></table>

As is shown in table 2, the performance comparisons with multi-threshold segmentation algorithm and RBGM algorithm of this paper. The method of multi-threshold with RBGM performance better than the original algorithm and it turns out to be well in time-saving obviously. Because with the increase of threshold, the resolution problem is changing from function of variable into multivariate function, which will needs plenty of time in selecting threshold. While RBGM find the best value in the gradient direction, which saves much work under the same precision.
<table><caption>Table 2: Comparison original algorithm with RBGM algorithm</caption><thead><tr><th rowspan="2">The threshold numbers</th><th colspan="2">Original Method</th><th colspan="2">RBGM Method</th></tr><tr><th>number of operation</th><th>operation time</th><th>number of operation</th><th>operation time</th></tr></thead><tbody><tr><td>1</td><td>256</td><td>0.19s</td><td></td><td></td></tr><tr><td>2</td><td>5536</td><td>0.78s</td><td>3000</td><td>0.51s</td></tr><tr><td>3</td><td>16777216</td><td>10s</td><td>50000</td><td>1s</td></tr><tr><td>4</td><td>4294967296</td><td>50min</td><td>10000000</td><td>9s</td></tr></tbody></table>

From the Figure3~Figure6 and table 3, we can see: compared with traditional threshold algorithm, our method performance better in image segmentation of maize ear grain, which can make each grain separate obviously. Besides, multi-threshold algorithm also behaves well in image edge. As is shown in table 2, most measured value is closed to the true value, which have an accuracy over 96%. Some have a low precision, because the method may generate errors at places when two grains overlap in such a fashion which are very smooth or over-closed.

<table><caption>Table 3: The result of maize ear grain</caption><thead><tr><th rowspan="2">ID</th><th colspan="2">True Value</th><th colspan="2">Measured Value</th><th rowspan="2">Accuracy</th></tr><tr><th>Grains number</th><th>Grains number in image</th><th>Grains number in image</th><th>Grains number</th></tr></thead><tbody><tr><td>1</td><td>485</td><td>243</td><td>236</td><td>468</td><td>0.964</td></tr><tr><td>2</td><td>487</td><td>244</td><td>230</td><td>456</td><td>0.936</td></tr><tr><td>3</td><td>374</td><td>189</td><td>185</td><td>369</td><td>0.986</td></tr><tr><td>4</td><td>474</td><td>237</td><td>226</td><td>448</td><td>0.946</td></tr><tr><td>5</td><td>453</td><td>235</td><td>229</td><td>454</td><td>1.002</td></tr><tr><td>6</td><td>484</td><td>247</td><td>240</td><td>475</td><td>0.982</td></tr><tr><td>7</td><td>485</td><td>240</td><td>236</td><td>468</td><td>0.964</td></tr><tr><td>8</td><td>487</td><td>243</td><td>231</td><td>458</td><td>0.940</td></tr><tr><td>9</td><td>374</td><td>186</td><td>176</td><td>351</td><td>0.939</td></tr><tr><td>10</td><td>474</td><td>238</td><td>229</td><td>454</td><td>0.958</td></tr><tr><td>11</td><td>453</td><td>239</td><td>230</td><td>456</td><td>1.007</td></tr><tr><td>12</td><td>484</td><td>244</td><td>234</td><td>464</td><td>0.958</td></tr><tr><td>13</td><td>485</td><td>242</td><td>236</td><td>468</td><td>0.964</td></tr><tr><td>14</td><td>487</td><td>242</td><td>230</td><td>456</td><td>0.936</td></tr><tr><td>15</td><td>374</td><td>187</td><td>179</td><td>357</td><td>0.955</td></tr><tr><td>16</td><td>474</td><td>239</td><td>230</td><td>456</td><td>0.962</td></tr><tr><td>17</td><td>453</td><td>237</td><td>229</td><td>454</td><td>1.002</td></tr><tr><td>18</td><td>484</td><td>241</td><td>233</td><td>462</td><td>0.954</td></tr><tr><td>19</td><td>485</td><td>244</td><td>235</td><td>466</td><td>0.960</td></tr><tr><td>20</td><td>375</td><td>188</td><td>181</td><td>361</td><td>0.962</td></tr><tr><td></td><td></td><td></td><td></td><td></td><td>0.964</td></tr></tbody></table>
## 7 Conclusion

An automatic counting method of maize ear grain based on image process with the algorithm of multi-threshold and RBGM is proposed in this paper. Compared with classical threshold method, this method turns out that performances well in image segmentation of maize ear grain and have an advantage of time-saving. Especially, the accuracy of counting is 96.4%, which is acceptable for the corn variety testing.

## Acknowledgements

This paper is supported by the “National Key Technology R&D Program under the Twelfth Five-Year plan of P.R. China” (Grant No. 2012BAK19B04-03). And National 863 Program (Grant No. 2011AA10A103-1).

## [References]

[1] Qin Jian, Li Lin, Li Shaoming, Wang Longhe, Shi Zhentong. New image segmentation method based on gradient[J]. Journal of Computer Applications, 2009, 29(8): 2071-2073.

[2] Luc Vincent, Member, Morphological Gray scale Reconstruction in Image Analysis: Applications and Efficient Algorithms[J], IEEE Transactions on image processing, VOL. 2, NO. 2, April 1993:583-598

[3] Luc Vincent, Pierre Soille, Watersheds in digital spaces---an efficient algorithm based on immersion simulations[J], IEEE Transactions on pattern analysis and machine intrllligence, VOL, 13, NO.6, June 1991

[4] Kassm, Witkina, Terzopoulos D. Snakes: active contour models[J]. International Journal of Computer Vision, 1987, 1 (4): 321-331.

[5] Chan T. Vese L., An efficient variation multiphase motion for the Mumford-Shah segmentation model[C]. Processing of Asiomar Conference Signals, Systems, and Computers, Pacific Grove, CA, USA: IEEE Press, 2000:490-494.

[6] Xun yi, Bao Guanjun, Yang Qinghua. Automatic Segmentation of Touching Corn Kernels in Digital Image[J]. Transactions of the Chinese Society for Agricultural Machinery, 2010, 4(04):033

[7] Zhang Yaqiu, Wu Wenfu, Wang Gang. Separation of corn seeds images based on threshold changed gradully[J]. Transactions of the CSAE, 2011, 27(7): 200-204.

[8] Xiangyang Xu. Characteristic analysis of Otsu threshold and its applications[J]. Pattern Recognition Letters, 2011:956-961.