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

: 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%.

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.

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

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: 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.

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), pixels whose gray level is , then , and we express the probability density distribution with the form of histogram , , .Let an image be divided into two classes and by threshold t.
consists of pixels with levels and consists of pixels with levels . Let and denote the mean levels, 2  denote the between-calss variances of the classes and , respectively. These values are given by: The threshold decided by maximizing the between-class variance proposed in Otsu is: 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 According to (15), we have: According to (14) (17) (19), we have: Then According to (16) (20), we have:

RBGM algorithm
When the threshold decided by maximizing the between-class variance of multi-threshold proposed in . However, with the increase of threshold from single to n, the resolution problem of 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: The RBGM method is described as follows: Step 1: given an initial point 0 Step 2: complete a cycle to update mN j x  as follows: Then we can get Multi-threshold segmentation iterative solution function: 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 R² = 0.9664 y means the total number of grains, x means the number of grains in image.

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 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 Figure4   Figure 4. Data collecting. A, B: Original maize ear grain image.
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)    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.

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 R² = 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%. 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.