#### Abstract

Evaluating the merits of the wheat seed is an important significance for wheat breeding. We studied analytic hierarchy process (AHP) for seeds grading by digital image processing techniques in the paper. Firstly, preprocess the collected wheat seed images; extract some parameters, such as area, plumpness, rectangular, and elongation of the seed, and then build the level model. Experiments showed the model is right, and level accuracy rate is more than 95%.

#### 1. Introduction

Wheat is one of the most important grains in the world, which yield ranks 2 after rice. It is a major food resource and an important industrial raw material as well. The good and bad wheat gain is not only the determining factor for yield and quality but is also the comprehensive index of species adaptations. Identifying and grading of wheat seed size and plumpness have important significance for improving wheat quality and promoting the development of the wheat industrial chain.

There is a lot of research in wheat with image processing. In 1985, Zayas et al. [1, 2] distinguished between two varieties of winter wheat by visual images. In 1987, Sapirstein [3] studied the classification of cereal crops and designed classifier. In 1989, Neuman et al. [4] analyzed the color feature of wheat seed by image processing. In 2000, Jayas et al. [5, 6] classified wheat by the texture characteristics and established the texture feature model. In 2005, Ferrio et al. [7] forecasted wheat yield according to visible and near-infrared reflectance spectra. Domestically, in 2004, Guiqin et al. [8], from China Agricultural University, extracted wheat image morphological and color characteristic parameters to establish a yield dynamic model and forecasted wheat yield. In 2005, HongWei [9] judged the level quality of wheat by color, shape, and texture based on signal processing method. In 2011, Kun et al. [10] extracted some characteristics of the wheat awn number, awn length, and wheat spike length color and identified four spring wheat varieties from Xinjiang by BP neural network. Xu et al. [11, 12] classified four wheat varieties by median filtering and threshold method.

On the whole, it is wide about wheat researches based on image processing, but most of them are limited to species identification, and it is rare on wheat seed grading. Reference [4] mentions a method with the signal processing to determine wheat quality, which requires amount of data and long time as well as expensive equipment. Aiming at the existing problems in the detection of agricultural products, we put forward the level method of wheat seed quality based on AHP and lay the foundation for the application of wheat grading detection technology.

#### 2. Image Capturing and Preprocessing

##### 2.1. Image Capturing

Images are taken by Sony DSC-WX50 digital camera, which is equipped with 16 million pixels and the 3x optical zoom camera. The actual images are about 9 million pixels and saved as BMP format.

When images are captured, we select plain black wood as background, adequate illumination, and then make wheat seed drying tile based on the background. In order to prevent the shadow on image segmentation, incandescent light is filled with illumination in the shadow side. The camera, fixed on the solid support, vertically shoots wheat seed with 3x optical macrozoom mode and shoots the wheat seed of different densities at the same conditions.

##### 2.2. Preprocessing of Wheat Seeds Images

In order to get wheat seed features accurately, wheat seed images are preprocessed through grayscale, enhancement, smoothing (denoising), binarization, and segmentation; finally, we obtain the desired images.

The images are processed by gray scale to simplify the original image color, so that the seed seeds are separated more easily from the background. The images are enhanced by the Gauss filter template, which can effectively eliminate the noise and preserve the image detail. Images are segmented by Otsu method to optimize threshold; histogram and threshold make the wheat binarization images separated from the background, which lays the foundation for the gain feature extraction. Figure 1 is the original wheat gain image; Figure 2 is the one after preprocessing.

#### 3. Feature Extractions of Wheat Seeds

Feature extraction is a key step in wheat seed grading; the goodness and badness of wheat seed are mainly reflected by geometric features. In this paper we judge the wheat seed level by extracting geometric features of wheat seed, including perimeter, area, and elongation.

##### 3.1. Perimeter Extraction

Perimeter is a measure of the size of an object appearance, under normal circumstances. In general, the better the quality of wheat is, the larger the perimeter is. Firstly, the paper extracts and tracks the image edge and gets seed profile; and then it chooses 8-connectivity chain code method to calculate the perimeter. 8-connectivity chain code method is exactly in line with the actual situation of pixels that can accurately describe the information center of the pixel and its neighbors. The formula based on 8-connectivity chain code is as follows:

In this formula, represents the number of chain code in the diagonal direction; represents the number of pixels in the horizontal direction; represents the number of pixels in the vertical direction; represents the number of even chain code.

##### 3.2. Area Extraction

Area is a measure of the size of plane taken by an object, and it is a metric evaluation for object size in the two-dimensional space. A high-quality seed looks smooth and plump; when it is projected onto a two-dimensional plane, the area will be larger.

Wheat area extraction is simple, which calculates the number of pixels taken by wheat seed directly; the length of each pixel is 1.

##### 3.3. Circularity Extraction

Circularity indicates deviation degree between an object and a standard circle, which is determined by the perimeter and area of the object and represented by . Wheat seed circularity is similar with plumpness. High-quality wheat is ripe and plump with cylindrical appearance. The larger the deviation degree between an irregular object and a standard circle, the lesser the circularity. Circularity is defined by the following equation:

In this formula, represents the area of wheat seed; represents the perimeter of wheat seeds.

##### 3.4. Elongation Extraction

Elongation, also called eccentricity, is the ratio of the minor axis and the major axis of the target image, which describes stretch ability and slenderness of the image. Elongation is usually used for the slender objects apart from circular and square object and reflects partly the compact degree of the target object. Its symbol is , which is calculated as

In this formula, represents the major axis of wheat seeds; represents the minor axis of wheat seeds.

##### 3.5. Rectangularity Extraction

Rectangularity indicates the external smallest rectangle of target object and reflects the filling degree. The object placement angle has great influence on external rectangle. Its symbol is , which is calculated as

In this formula, represents the area of wheat seed; represents the major axis of wheat seed; represents the minor axis of wheat seed.

#### 4. The Model of the Wheat Seeds Grading

##### 4.1. The Analytic Hierarchy Process

The analytic hierarchy process, called AHP for short, is a combination of qualitative, quantitative, systematic, and hierarchical analysis methods.

AHP is a complex problem which is decomposed into a number of layers and compares the effect between various layers or factors. According to the influence, AHP establishes judgment matrix, calculates maximum feature value and feature vector matrix, obtains the weight coefficients of importance from different solutions, and compares the weight coefficients to get the best solution.

##### 4.2. Steps of AHP Model

###### 4.2.1. Building Comparison Matrix

Assuming there are factors in a layer, is to compare the extent of their impact on a criterion (or target) of upper layer and determine the proportion of the layer relative to the criteria (i.e., sort the influence degrees of the factors on the target of the upper layer). represents the comparison on result of the number factor relative to the number factor

In this formula, is called paired comparison matrix, .

###### 4.2.2. Hierarchy Single Ranking and Its Consistency Test

Hierarchy single ranking is the process of determining degree that the factors of underlying factors influence a factor of the upper layer, with weight value to indicate the degree. For each pairwise comparison matrix, it calculates the maximum eigen value and the eigen vector and then makes the consistency test with consistency index, random consistency index, and consistency ratio. If it passes the tests, normalized eigen vector is the weight value; otherwise, it has to rebuild the paired comparison matrix.

###### 4.2.3. Hierarchy General Ranking and Its Consistency Test

Hierarchy general ranking is the sorting process of determining degree that the factors of one factor influence the overall goal; the sorting process is from the top to the lowest layer by layer. It calculates the weight vector of sorting results from the top to the lowest and uses consistency ratio of hierarchy general ranking for testing. If the test is passed, it can make decisions by weight vector of general ranking; otherwise it has to rethink the model to reconstruct the paired comparison matrices of greater consistency ratios.

##### 4.3. AHP Model of Wheat Seed Grading

###### 4.3.1. Extraction Characteristic Parameters of Wheat

To facilitate the presentation, we select 14 wheat seeds with the numbers 1–14, and then they are divided into three different levels: excellent, good, and poor. There are 6 excellent seeds, 3 good seeds, and 4 poor seeds. Through pretreatment of wheat seed and the image feature extraction, the image characteristic values of wheat seeds are obtained, which are shown in Table 1.

In Table 1, Num is seeds number, is area, is perimeter, is circularity, is elongation, and is rectangularity.

Considering area, perimeter, circularity, elongation, and rectangularity, a comprehensive evaluation model is constructed at last. Target layer is to determine the wheat seed; criterion layer is the factors including area, perimeter, circularity, elongation, and rectangularity; project layer is the wheat seeds.

###### 4.3.2. Building Paired Comparison Matrix

According to AHP, it is easy to build judgment matrix. The method of constructing judgment matrix is as follows: every downward subordinate element (called criteria) is considered as the first element of judgment matrix (located in the upper left corner of the matrix); elements attached to it are orderly arranged in the first row and the first column followed.

The method of filling in the matrix is as follows: according to the matrix criteria, compare all of the elements with each other and calculate degree of importance between two elements; then assign the degree of importance by 1–9 (importance scale in Table 2).

The importance analysis of the judgment matrix is as follows: the extractions of area, perimeter, and elongation are independent; the extraction of circularity is not independent and based on area and perimeter; the extraction of rectangularity is not independent too, which is dependent on area and the minor axis as well as the major axis. The judgment matrix are a is shown in Table 3.

In Table 3, feature is wheat seed features, is area, is perimeter, is circularity, is elongation, and is rectangularity.

Because we do not know the extent of the influence of each characteristic parameter on wheat seed grading, the coefficients of the judgment matrix are for test and will be adjusted according to classification results.

From Table 3, paired comparison matrix is as follows:

Attention: should satisfy the following properties: , , and ; is called positive reciprocal matrix.

###### 4.3.3. Calculating the Sum of Weight by Single Criterion

*Step **1* (elements of are normalized by column). Consider

Every column element is divided by the summation of relative column, and the result is as follows:

*Step **2.* Add the normalized rows together and then the vector is divided by . is the matrix order, and in current model is 5. Weight vector is as follows:

*Step **3* (test the consistency of judgment matrix). Consistency test is designed to test the degree of importance of coordination between various elements. Only to avoid critical contradictions (e.g., is more important than ; is more important than ; and is more important than also), the judgment matrix can be normalized; otherwise the matrix must be rebuilt.

###### 4.3.4. Comprehensive Calculation of Wheat Seeds Feature Weights

*Step **1* (normalize the feature weights). We view the feature vector of wheat seed judgment matrix as feature weights . It determines the summation of the productions that is multiplied, respectively, by perimeter, area, elongation, circularity, and rectangularity of wheat seed as total weight value. To make degree of influence about the same among area , perimeter , elongation , circularity , and rectangularity , all above 5 coefficients should be normalized to ensure that the final evaluation is a comprehensive evaluation. Consider , , , , and . Among them, , , , , and are the max value of sample feature. The normalized data are shown in Table 4.

*Step **2* (comprehensive calculation of wheat seeds feature). Comprehensive evaluation is the summation of the productions that is multiplied, respectively, by perimeter, area, elongation, circularity, and rectangularity of wheat seed. Comprehensive evaluation is marked as

A comprehensive evaluation coefficient of the samples is shown in Table 5.

*Step **3*. After sorting, comprehensive evaluation coefficient is shown in Table 6.

##### 4.4. Experiment Result

Compared with actual situation, the numbers of excellent seeds in Figure 1 are 4, 8, 9, 12, 13, and 14; the numbers of good seeds are 1, 6, 10, and 11; the numbers of badness are 3, 2, 5, and 7. It adopts 0.8 or more as excellent classification line and 0.7 or less as bad classification line. Compared with the experimental results, there is error number 1 seed, the overall error rate of 7.1%. By the same way, the error rate is less than 5% for different number of wheat and different forms of placement.

#### 5. Conclusions

Wheat seed grading with digital image processing provide further possibilities for the agricultural automation. It helps the manual classification of wheat seed, reduces the amount of labor, and improves the quality of wheat seed. The paper discusses the feature value of wheat seeds and calculates the comprehensive evaluation by AHP. According to the sorting result of comprehensive evaluation, wheat seed can be graded. Compared with the fact, the overall accuracy rate of wheat seed is more than 95%, which meets the actual needs. The method can be extended to the other granular agricultural classification test.

#### Conflict of Interests

The authors declare that there is no conflict of interests regarding the publication of this paper.

#### Acknowledgments

This paper is supported by Special Fund for Agro-scientific Research in the Public Interest, the Bureau of Science and Technology Hebei (no. 2014055214), Science and Technology Fund of the Agricultural University of Hebei 2009, National Natural Science Foundation of China under Grants (no. 60873236), Natural Science Foundation of Hebei Province in China under Grants (nos. F2009000653 and F201204089). In addition, this research is also supported by the Youth Science Research Foundation of Hebei Province in China under Grants (no. 2010251).