Communications Engineering
College, Jilin University,
Changchun, China
likh08@mails.jlu.edu.cn
Yuhong Zhu
Communications Engineering
College, Jilin University,
Changchun, China
yhzhu@jlu.edu.cn
Yun Tian
Engineering and Technology
College, Jilin Agricultural
University, Changchun, China
tianyun64@163.com
ABSTRACT
A fast recognition algorithm of weed is achieved and improved on the DSP of DM6437 with C64+ core in this paper. The algorithm is able to identify weeds between the crop rows with information of the locations and areas. Meanwhile, it is optimized based on the C64+ core. And it takes about 10.9ms to handle a weed image with 320*240 pixels, which meets the requirement of real-time application.
l. INTRODUCTION
Weed is one of the important factors which limit the yield and quality improvement of the crops. The traditional method to control weed is spraying herbicide uniformly in the field, even though there are no weeds. It not only increases the costs, but also sharpens the pollution of the environment. As the concept of precision agriculture is proposed, it is possible to detect weed accurately and spray variously according to the amount of weeds with the image recognition technology.
Currently, there have been plenty of researches on weed identification. D.M. Woebbecke originally turned the color image into the gray one with the color index of the normalized 2g-r-b in 1995 [1]. In 2008, George E. Meyer proposed the index of ExG-ExR(3G-2.4R-B) combined
with zero threshold which could quickly achieve the division of plant and background [2]. In 2009, Xavier P. Burgos-Artizzu put forward a method to filter crop with the combination of edge detection and window detection and the accuracy was up to 96%. However, the algorithm
was so time-consumed that it needed to take about five days to calculate one of the parameters before the algorithm could work [3]. Hossein Nejati took the advantage of the edge-density and frequency to detect weed in com field with the accuracy of 93.8% in 2008 [4].
The tests were executed on a computer with 3GHz
Pentium 4 Intel processor and average times were O.2sec for images with 640*480 pixels. Xin Li, in 2007, successfully filtered the crops from the image according to the location of the crops and the symmetry of the crop row in a short time [8]; In 2002, Lei Tian designed weed identification system with the computer to achieve real-time weed identification [5].
Although the studies can identify the weeds with a high accuracy, most of them are non-real-time simulation with the computer and their excellent performances are at
the expense of the time. So their applications are limited in practice. Several of the researches have made some practical devices for precision spraying, but they cannot work without the computer which is expensive and unwieldy.
To get over these limitations, a new implantation method is brought forward. It achieves a quick weed identification algorithm on the DSP (Digital Signal processor) of TMS320DM6437 (referred as DM6437 for short) produced by n, which works at 600MHz. The algorithm makes use of the color index of 3G-2.4R-B and the feature of the crop location [7] [8].
2. WEED IDENTIFICATION ALGORITHM
With the guarantee of real-time implement, a new process for weed identification is proposed. It is presented in Fig.l .2.1. Plant and background segmentation So far, there are many methods to segment the plants (crops and weeds) from the background (soil, crop residues, gravel and so on). Among them, color feature is widely used. As the plants are always green, while the soil
and other background are in other colors, we can use the difference to realize the segmentation.
Before segmentation, the transformation should be realized between the color image and the gray one. In the RGB color model, the method using the combination of the three components, R, G and B to realize image grayscale, is proved to be positive and effective. In 2008, George E. Meyer proposed the combination ExG-ExR (3G-2.4R-B) to realize image grayscale and took zero as the threshold to segment the plant from the background with the accuracy up to 94%. The test showed that, in different backgrounds, the segmentation results are better than ExG (2G-R-B) and NDI «G-R)/(G +R» with the combination of Otsu threshold algorithm. So in this paper, the 3G-2.4R-B is used to segment the plant from the background.
2.2. Crop and weed separation
As most of the crops are distributed in rows in the field, while the weed's distribution is irregular, the location feature can be used to separate them in the binary image [7][8].
2.2.1. crop rows' center determination
The crops are distributed in rows, so in the binary image, the number of non-zero pixels along the direction of crop rows will certainly be more than the one along the non-crop lines [6]. Therefore, by counting the non-zero pixels along the direction of crop rows in the binary image,
a vector g(x) with the size of 1 *W can be obtained, where W is the width of the image. g(x) is described in equation (1).
f(x, y) is the value of the pixel whose coordinate is (x, y). If the pixel belongs to crop. f(x, y) = 1; while if the point belongs to background, f(x, y)=O. W is the width of the image, and H is the height of the image. According to g(x), all the central coordinates and the number of the crop rows can be determined.
2.2.2. Crop Filtering
The following task is to fix the rows of crop and filter them, so that an image can be gained where there are only weeds. Xin Li has proposed a method as following: firstly, fix a threshold according to the percentage of peak valueof g(x) and the left boundary of the crop rows can be
determined according to the threshold; secondly, determine the width of the crop rows based on the distance between the left boundary and the center of the row; at last, the right boundary can be determined according to the symmetry of the crop row. The correct central position and the symmetrical distribution of the crop are the predictions for the good performance of his method. But in practice, the crop rows may be tilted due to the sowing operations and the crops are not necessarily symmetrical when growing, so that the method has some limitations in filtering the crops.
So according to the reference [14], it is improved in this paper: firstly, fix a threshold Tc according to the percentage of the maximum value of g(x); secondly, take Xk as the starting point where Xk is central coordinate of the kth crop row and fmd out the left boundary m and the right boundary n in g(x), where m and n satisfy the equation (2).
By repeating this process, all the borders of the crop rows can be found out. And then all the pixels in the crop rows are set to zero in order to filter them.
2.3. Weed determination
In the weed image obtained in the previous step, there are some non-weed interference points. Therefore it is necessary to remove them before the locations of the weeds are determined. This process can be achieved by the method of area filtration. By labeling the image with the regional growth method considering the nonzero pixels in the 8-pixel neighborhood [9], the areas of the connected blocks can be counted. Then a threshold is determined according to the maximum value of the areas. The blocks whose area is below the threshold are considered as interference points and should be removed. As a result, theweed image is gained. And the locations and areas of the weeds can be calculated.
3. ALGORIGHM IMPLEMENTATION AND OPTIMIZATION
In this paper, the weed identification algorithm is implemented on the DM6437 which is a high-performance DSP belonging to the TI's C6000 family. The DM6437 is designed for audio and video processing with the Da Vinci architecture. The core of the processor is C64+ which is
the enhancement of C64 and fully compatible with it [10]. Before the algorithm is programmed with C language, it is simulated with Matlab to identify the feasibility. And the C functions used in weed detection are shown in Table 1.
Tablel C functions for weed detection
Function | Description |
g3GrayO | Change the color image to the gray one |
BinaryO | Change the gray image to the binary one |
plumb SumO | Calculate the non-zero pixel numbers in the direction of the crop row |
cropEdgeO | Detect the edges of the crop row |
cropFilterO | Filter the crop |
LabelingO | Label the binary image with 8-pixel neighborhood |
weedFilter() | Filter the interference points |
weedLctO | Detect the locations of weeds and calculate the areas |
3.2. Algorithm optimization
Generally, there are two ways to optimize the algorithm which is carried out on the DSP: the C-Ievel optimization and the assembly-level optimization. Considering the complexity of migration and programming of the code, the weed identification algorithm is only optimized in the C-Ievel. With the powerful development tool, CCS, which is the development environment for DSP provided by n, the C code can be converted to efficient assembly language easily [11][12][13]. The methods for the optimization of C code are as follows:
3.2.1. intrinsics
The compiler of C6000 recognizes a number of intrinsic operators which are directly mapped to the assembly command and allow you to express the meaning of certain assembly statements that would otherwise be cumbersome or inexpressible in C language. With the help of intrinsics,
the programmer is able to complete some codes with high efficiency. For example: the function _sub2 (srcl , src2) can compute the difference of src I and src2 in the corresponding high and low half-words separately in one instruction cycle, which is superior.
3.2.2. Data package
Data package is a method that operates a long word-length data instead of the several short word-length ones. Because the memory access of C6000 is time-consuming, the programmer should read or write more data at a time and operate the data with some corresponding instructions. For instance, one can use _amem4_const(ptr) to read four bytes once, reducing the times of memory access.
3.2.3. Loop optimization
Software pipe lining is a technique used to schedule from a loop so that multiple iterations of a loop execute in parallel, which can enhance the efficiency of code. So when programming a loop, the programmer should take full advantage of the software pipelining. Since the compiler
only optimizes the internal loop, the programmer should unroll the short loop or write the code without any loops embedded taking into account of the implementation of filling and emptying of the software pipeline each time for the interior loop. At the same time, the structure of a
software pipelined loop requires the minimum number of the loop iterations in order to fill or prime the pipeline to ensure the correctness of the execution. The programmer can use pragma directives, such as "# pragma MUST_ITERATE (a, b, c)" and "# pragma unroll n" to provide the complier with the information of the loop.
With the information, the complier will be able to fully optimize the loop.
Take the function of g3GrayO as an example. It uses the combination of color index, 3G-2.4R-B, to change the RGB image into the gray one. The optimized codes are as follows:
#pragma MUST ITERA TE(8, ,8);
#pragma UNROLL(8);
for(i=O; i
Process the image with 320*240 pixels showed in Fig.2 with the algorithm proposed in this paper, and the results are laid out separately in Fig.3 and Fig.4
Between the two figures, Fig.3 is the recognition result of the algorithm simulated by Matlab and Fig.4 is the outcome of the recognition achieved by DM6437. By comparing the two, it can be found that the algorithm implemented on DM6437 has successfully identified the weeds. And the time for recognition is about 10.9ms which also meets the need of real-time application.
5. CONCLUSION AND FUTURE WORK
In this paper, a fast weed recognition algorithm is carried out and improved on the DM6437, by projecting in the direction of crop row and labeling based on the color and location characteristics of the plant. It is also optimized with the reference to the features of the C64+ core. With the algorithm, a weed image with 320*240 pixels is able to be recognized within 1O.9ms, which meets the real-time demand. And it also inaugurates a new way for the
implementation of precise spraying in practice. In future studies, more efforts should be ploughed into further improving the adaptability of the algorithm, and some time-consuming codes should be compiled in assembly language for optimization if it is necessary. Of course, some new fast and efficient identification algorithms should be explored to identify the weeds within the crop rows.
ACKNOWLEDGEMENTS
This work is supported in part by the 863 Program of China (No. 2003AA209090-3).