Research Algorithm on the Wheat Phenotypic Feature Extraction based on Image Processing

In order to solve the problems of manpower and long cycle in traditional manual measurement, a wheat phenotypic feature extraction and analysis system was designed and implemented based on the image processing technology. The system can analyze and estimate the phenotypic parameters of wheat leaf, plant and wheat ear in different growth stages. The paper introduces the estimation algorithm of wheat leaf and wheat ear characteristics in detail, including the following contents: image acquisition, image preprocessing, feature extraction, parameter data estimation, etc. the estimated data provide data basis and reference for wheat breeding experts.


Introduction
Wheat is one of the most important food crops in China, it has large planting area and wide distribution. Its sowing area, yield and total yield are second only to rice and corn, accounting for about 20% of the total national food consumption. Therefore, ensuring stable and high yield of wheat plays an important role in ensuring China's food supply, promoting farmers' income, maintaining social stability and promoting economic development. Using image processing and computer vision technology to study wheat image has always been a hot spot in the field of agricultural information [1] . Under the background of Internet plus application in agriculture, it is particularly important to study how to use information technology to monitor wheat growth and seedling and build a reasonable evaluation method [2] .
Wheat seedling condition will directly affect the final yield and quality of wheat, and its can be generally characterized by wheat leaf, plant height, wheat ear shape, wheat grain shape etc. [3] Among them, the shape of wheat leaf and wheat ear are two important characteristics for wheat, which play a certain role in wheat breeding, planting, yield and variety differentiation. In order to solve the problem of work efficiency and production efficiency in traditional measurement methods, the paper uses machine vision technology to process and analyze the images of wheat leaf and wheat ear in different growth stages. The results can provide basis and reference for wheat breeding experts.

system design and image acquisition
The purpose of this project is to provide wheat breeding experts with a quick and convenient way to estimate the phenotypic feature of wheat at different growth stages, such as the wheat plants and ears in the process of wheat growth, and to design and implement a wheat phenotypic feature extraction and analysis system. The system consists of five modules: image acquisition and preprocessing, analysis and estimation of wheat leaf phenotypic features, analysis and estimation of wheat ear phenotypic features, analysis and estimation of plant phenotypic features, and statistics of wheat grain number. This paper

system function structure
According to the actual needs of breeding experts, the wheat phenotypic features extraction and analysis system is designed and implemented. The functional structure of the system is shown in Figure 1.

Fig1. system function structure
The system mainly realizes five functional modules: image acquisition and preprocessing module, wheat leaf feature analysis and estimation module, wheat ear feature analysis and estimation model, plant feature analysis and estimation module and wheat seed number statistics module. The image acquisition module and image preprocessing algorithm of wheat leaf and ear are introduced in detail.

image acquisition of wheat leaf
According to the actual needs, three types of images are collected: wheat leaves with reference object under a single background, wheat leaves without reference object under a single background and wheat leaves under field background. The image of wheat leaves in the project is taken from the Top view angle of the mobile phone. The original images of wheat leaves of three types are shown in Figure 2

image acquisition of wheat ear
In order to facilitate the later image processing, according to the features of wheat ear, the image of single plant spike in different periods was taken from the angle of up to 35 degrees, as shown in Figure  5.Another acquisition method, under a single black background, the image of wheat ear was taken from the top of the laboratory ,as shown in Figure 6.

RGB to gray
The amount of data and storage space occupied by color image are much larger than gray image, it is necessary to transform it into gray image with relatively small amount of data and easy to process. The commonly image graying methods as following [4] .
(1) Maximum method: take the largest value of the three components R, G and B, and then assign the three components respectively.
(2) Average method: find out the average value of R, G and B, which is the new value of R, G and B.
(3) Weighted average method: give different weights to the three components of R, G and B and calculate the average value. The average value obtained is the new value of R, G and B. In general, the effect of graying color image by weighted average method is the best.
In the system, the weighted average method is used to gray the color image.

image enhancement
Through the image enhancement processing, different parts of the image can be selectively enhanced, so that the key parts of the image can be more prominent, and the unnecessary details can be shielded. Through the image enhancement processing, the image can better meet the actual needs, and the quality of the image can also reach the standard. The system using enhancement method are histogram equalization and contrast enhancement.

image segmentation
The image segmentation is to divide the image into several parts according to different features. Each part of the content must have a strong correlation with the object or region we are interested in, and then extract the edge or region of the decomposed image to separate it from the background [5][6][7] .
(1)Threshold segmentation method The basic principle of threshold segmentation method is: by analyzing the gray or color features of the original image, the histogram of the image is obtained , and then the image is segmented by different thresholds .According to the different thresholds divide the image into different parts. When the background of image is not complex or the quality of extraction is not high, the single threshold segmentation method is an ideal choice. However, in the case of complex image background or high requirements for extraction quality, the single threshold segmentation method can not meet the requirements. At this time, we need to use the most appropriate segmentation method according to our own needs, that is, select the appropriate method for different occasions.
(2) maximum inter class variance method The maximum inter class variance method is an adaptive threshold determination method proposed by Otsu. Its basic principle is: separate the region to be extracted from the image and its background region, and then calculate its variance through the characteristics of the gray value of the image. When the variance between the target object and its background is greater, the difference between the two parts is greater, and the segmentation effect is better.
For any image ( , ), the threshold of segmentation is defined as T, the ratio of target pixels in the whole image can be defined as 0 , its average gray value can be recorded as 0 , the ratio of background pixels in the whole image can be defined as 0 , its average gray value can be recorded as 1 , for the whole image, its average gray value can be recorded as μ.The pixel values of image length and width are recorded as M and N, and the variance between classes is recorded as g. Suppose that the number of pixels whose gray value in the image is smaller than the set threshold T is recorded as 0 , otherwise it is recorded as 1 , and the specific formula is as follows: The formula (4) and (5) are obtained: = 0 × 1 × ( 0 -1 ) 2 (6) The maximum value of g is the threshold T. In this system, maximum inter class variance method are used to segment wheat leaf and ear images.

morphological treatment
Morphological processing refers to the operation of matching the image and its similar parts with specific shape structural elements. It is a common operation means in image processing. The purpose of image recognition can be achieved through morphological processing.There are several methods for morphological processing as following [8][9] .
(1)Expansion The definition of inflation is: select the structural element B, translate B, if it contacts with the target a, then write down the center point of B at this time as point a, then the combination of all points a is the final result. The expansion operation of the image can effectively fill the gap in the object in the image.
(2) Corrosion The definition of corrosion is: select the structural element B, translate B, if it is completely covered by a, then write down the center point of B at this time as B point, then the set of all B points is a, which is the result of B corrosion. The interference noise smaller than the structure element can be removed by etching the binary image, and the boundary can be smoothed. (

3) Open and close operation
The open operation of the image is to corrode the image first and then expand it. The closed operation is the opposite. The open operation can eliminate the tiny connection between the targets, and it can also play the role of separation and smoothing; the closed operation can play the role of filling the gap, and it can also play a very good smoothing effect on the boundary of the target. In the actual processing, open and close operations will not change the size of the target area too much.

Feature extraction and algorithm implementation
Shape feature is the description of the object's region space characteristic and contour boundary characteristic. Region space characteristic is the shape attribute obtained by processing the whole object's region space. Contour boundary attribute is the shape attribute obtained by processing the object's contour boundary with algorithm. The phenotypic features of wheat leaf and wheat ear are length, width, perimeter, area and so on.

algorithm processing flow
The process of feature extraction and analysis of wheat flag leaf and ear is shown in Figure 7.In the estimation algorithm of wheat leaf and ear feature, it is necessary to perform image enhancement, image segmentation, morphology and other preprocessing operations on the original image, and then estimate the corresponding phenotypic features according to different images.

implementation of wheat flag leaf feature analysis algorithm
It can be seen from Figure 7 that the image preprocessing operation is carried out for the three types of images that have been collected, the feature analysis and extraction are carried out for the obtained binary image, and the corresponding calculation algorithm is used to obtain the characteristic value of wheat leaf in three situations: no reference object, reference object and field background.
(1) Analysis of algorithm without reference For the estimated method of wheat leaf area without reference object, from the perspective of digital image, it is to count the number of pixels contained in the closed area of the main object (wheat leaf) in the binary image. Specific idea: in the two-dimensional matrix, first count the number of foreground pixels in each row, and then cumulatively calculate the total number of pixels in all rows, that is, the wheat leaf area.
(2) Analysis of algorithm with reference For the method of wheat leaf area with reference object, when calculating the wheat flag leaf area, we first obtain the size of the binary image, create two zero matrices of one row, the length of which is the length and width of the binary image respectively, and traverse the pixels of the binary image through double loops. If the value of the pixel is 0, the value in the corresponding column of the zero matrix is added by one, and after the traversal, the two zero matrices are traversed The maximum value of the zero matrix is found, which is the length and width of wheat leaf. Then, the position of the reference object in the binary image is counted to find the maximum value as the number of pixels corresponding to 0.5cm. The number of pixels of the length and width of the wheat leaf is divided by twice the number of pixels of the reference object, and the length and width of the wheat leaf in cm are obtained. According to the calculation formula of wheat leaf area: length * width * 0.7, the corresponding wheat leaf area is calculated.
(3) Under the background of field For the algorithm of wheat leaf area in the field background, the first step is to cut the collected image. The image cutting method of this system is manual, that is, importing the collected image into the system, and directly dragging the mouse to cut the target image in the original image. After graying and binarizing the cropped image, the latter processing method is the same as the estimated method of wheat leaf area without reference.
The algorithm implementation effect is shown in Figure 8-10.  First of all, we need to separate the stems and get the image of only wheat ears. According to the national breeding standard, ear length is the length from ear neck node to ear top (excluding awn). According to the width difference between the upper part of the ear and the stalk, the upper part of the