# The Extraction Algorithm of Crop Rows Line Based on Machine Vision

Zhihua Diao, Beibei Wu, Yuquan Wei, Yuanyuan Wu

► To cite this version:

Zhihua Diao, Beibei Wu, Yuquan Wei, Yuanyuan Wu. The Extraction Algorithm of Crop Rows Line Based on Machine Vision. 9th International Conference on Computer and Computing Technologies in Agriculture (CCTA), Sep 2015, Beijing, China. pp.190-196, 10.1007/978-3-319-48357-3_18. hal-01557961

HAL Id: hal-01557961

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

Submitted on 6 Jul 2017

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

Distributed under a Creative Commons Attribution 4.0 International License
# The Extraction Algorithm of Crop Rows Line Based on Machine Vision

Zhihua Diao<sup>1,2,*</sup>, Beibei Wu<sup>1,2</sup>, Yuquan Wei<sup>1,2</sup>, Yuanyuan Wu<sup>1,2</sup>

1.Institute of Electric and Information Engineering, Zhengzhou University of Light Industry, Zhengzhou 450002, China

2.Henan Key Lab of Information Based Electrical Appliances, Zhengzhou 450002, China

**Abstract:** The accuracy of crop rows line extraction is the key to the automatic navigation of agricultural machinery. In the paper, an improved algorithm is proposed to solve the problem of poor connectivity, single pixel and redundant pixels. Firstly, image pre-processing operations is used in order to obtain a binary image, then the binary image is thinned. In the refinement process, the connectivity of the skeleton is maintained by the introduction of Euclidean distance. Experimental results show that the proposed method has good adaptability to the row crop, and the skeleton lines that are extracted is more accurate. Compared with the traditional algorithms, the error of the navigation line is relatively small by using this algorithm, which could meet the needs of the practical application.

**Key words:** super green algorithm; crop rows; skeleton point; redundant pixels

## 1. Introduction

Agricultural machine vision navigation plays a key role in automatic picking, irrigation, fertilization and visual navigation is the basis of crop recognition. Precision pesticide technology is a mainstream trend in the development of modern precision agriculture. Its main idea is using an image acquisition device to analyze and process these images. Then a series of processes were used to extract the navigation line of crop to control agricultural machinery for walking.

In the early 20th century, Marchant and Brivot Silsoe research center [1] and the Swedish expert Bjorn Astrand [2] had made a contribution to vision navigation algorithm research respectively and achieved some results. Ollis [3] used color camera to obtain the field map of crops and the edge of the harvest crop is extracted. Søgaard [4] proposed a algorithm with respect to the extraction of crop line based on the Hough transform. Yutaka Kaizua, Long Qi [5] extracted the characteristics of seedling through analysing the spectral characteristics of seedling and the extraction of seedling target line was achieved. In recent years, the domestic also appeared a lot of researches in this aspect. Zhang Zhibin [6-7] who had combined hough transform and Fisher criterion overcame the insufficiency of the traditional hough transform and made a model of multiple ridge line. Luo Xiwen [8] set up a mobile platform for agricultural intelligent operation. Zhao Ruijiao [9] put forward a kind of improvement algorithm based on vertical histogram projection and combined the projection and hough transform method to detect crop rows. Although these algorithms are valuable, the application of precision pesticide machinery is difficult to achieve because of poor adaptability.

The improved super green algorithm was used greatly reduce the effect of noise. Hough transform reduced the operation time and improved the accuracy. At the same time, an experimental platform was built to conduct different images and a good reconstrucyion result was obtained, which had good adaptation and accuracy and satisfied the needs of practical application.

## 2. Segmentation of Crop Rows

### 2.1 Acquisition of Crop Rows Image

The rows of chinese chives were taked as research object in the experiment. The model of industrial digital camera is MV-VD030SM/SC that was produced by Shanxi Dimensional Image Technology Co., LTD and the model of industrial lens is AFT-0641MP that was produced by AI Feite Photoelectric Technology Co., LTD, which
was used to acquire leek images. The output was 8 bit RGB color images. The original image of chinese chives was shown in fig.1.

<figure><img src="image_2.png" /><figcaption>Fig.1 Original chinese chives image</figcaption></figure>

## 2.2 Gray Processing

Leek images usually contain much color information. It was found that these color information was not very well for the following process. However, RGB color image was converted to grayscale image had more advantages than using color information processing. Gray processing is the basis of image analysis. The image of leek crop rows taken in farmland had obvious characteristics of green (as shown in fig.1). In other words, the G component was higher than the soil background. In order to distinguish crop rows and background better, the traditional super green gray algorithm (2G-R-B) [10] was used to process this image and the effect was shown in fig.2a. It was seen that the background noise of the traditional super green gray algorithm was obvious from fig.2a, which is not conducive to the following processing. Therefore, the super green gray algorithm was improved. The improved super green algorithm was as below:

$$Gr = \begin{cases} 1.8G - R - B & G > R \text{ or } G > B \\ 255 & \text{others} \end{cases} \quad (1)$$

From fig.2b, it could be seen that the background noise of chinese chives crop rows were greatly reduced and the crop lines profile were also obvious.

<figure><img src="image_3.png" /><figcaption>Fig.2a Common gray image</figcaption></figure>

<figure><img src="image_4.png" /><figcaption>Fig.2b Improved gray image</figcaption></figure>

## 2.3 Filtering Denoising

The crop rows after gray processing were still exist noise. In order to get the target of low noise, the grayscale image need to further denoise. The method of combining 3x3 Gaussian template and 3x3 median filter window was used to filter operation. The image after two filtering times was shown in fig.3. After filtering, crop rows had been separated clearly.
<figure><img src="image_5.png" /><figcaption>Fig.3 Median filtering image</figcaption></figure>

<figure><img src="image_6.png" /><figcaption>Fig.4 Binary image</figcaption></figure>

## 2.4 Two Value Processing

In order to further extract the row target, the image was processed by two value operation. The two main methods of two value had threshold and the biggest variance. The threshold of threshold method was determined according to experiment and experience, but the brightness of different pictures or the same picture were different, which made the application of the method inconvenient. In order to extract the target region, OTSU algorithm was used to process the image automatically. In addition, it was not disturbed by the brightness information and had good treatment result. The binary image was shown in fig.4.

# 3 The Detection of Crop Rows

## 3.1 Morphological Processing

As there were still many small noise in the crop row image after binarization processing. These noise that was compared with the crop row area was small, so morphological algorithm was used to remove these noise. The main morphological method is erosion and dilation. The crop rows towarded its center gradually and removed the holes that was smaller than structural element by erosion. While, the dilation had the opposite effect, which could filled the void and increased crop line width. In order not to change and eliminate the useful information of crop row, the morphological processing template that would be used must be appropriate. The structure elements of 3*3 template was used in this paper. The times was determined by experiment. The chinese chives lines contour were shown in fig.5.

<figure><img src="image_7.png" /><figcaption>Fig.5 Morphological processing image</figcaption></figure>

## 3.2 The Skeleton Extraction of Crop Rows

As the navigation path [11-15] is a linear structure, the skeleton of crop rows should be single pixel width. The outline image after morphological processing could not meet the requirements of machine vision navigation line. Then in order to extract the skeleton information of crop row, thinning algorithm was used(as shown in fig.6a). At the same time, the crop rows that were most closely to the center were remained and the redundant skeleton lines was removed to reduce calculation and increase accuracy. The extracted result of the central crop rows was shown in fig.6b.
<figure><img src="image_8.png" /><figcaption>Fig.6a Thinning process</figcaption></figure>

<figure><img src="image_9.png" /><figcaption>Fig.6b The skeleton of the center row</figcaption></figure>

## 3.3 Trunk Line Fitting

The skeleton of central crop rows does not reflect the navigation line. In precision spraying, the skeleton line should be fitted a straight line to realize path planning [16]. The random hough transform [17] was used to fit the crop rows in this paper. The traditional hough transform put the data points of image space map into the parameter space. This was a dispersed mapping of one to many. The random Hough transform improved the velocity of calculation. The result was shown in fig. 7.

<figure><img src="image_10.png" /><figcaption>Fig.7 Center line image</figcaption></figure>

## 3.4 The Effect of Extraction of other Images

In order to verify the algorithm that had been proposed in this paper has a good adaptability to the chinese chives crop rows, the corn crop rows were also carried out the same behavior. The results were shown in fig.8. From the figure, it can be seen that the goal lines of the corn crop rows can be extracted clearly, and the skeleton contain less redundant branches. It provided a basis for the analysis of precision pesticide system.

<figure><img src="image_11.png" /><figcaption>Fig.8a Original corn crop rows image</figcaption></figure>

<figure><img src="image_12.png" /><figcaption>Fig.8b The skeleton image</figcaption></figure>

<figure><img src="image_13.png" /><figcaption>Fig.8c Center line fitting image</figcaption></figure>

<caption>Fig.8 The extraction images of corn crop rows</caption>

## 3.5 Deviation Calculation

The deviation that is compared by center line of crop rows after fitting and the actual crop lines was the key technology of precision spraying. In this paper, the deviation of the above two kinds of crop rows were analysed, and it was shown in Table 1. From Table 1, we can see that the algorithm could meet the demand of precision spraying technology in the field.
<table><caption>Table 1 Comparison table of deviation</caption><thead><tr><td>Experiment object</td><td>Deviation /pixels</td><td>Running time /ms</td></tr></thead><tbody><tr><td>Fig.1</td><td>-29</td><td>215</td></tr><tr><td>Fig.8a</td><td>18</td><td>210</td></tr></tbody></table>

## 4 Conclusions

(1) The method of gray processing was improved for background segmentation, which had better result and adaptability than before. The median filtering algorithm could reduce the noise effectively.

(2) In this paper, the morphological processing and thinning on binary image were used. The navigation offset was got according to deviation and position information and realized the automatic navigation of agricultural machinery.

(3) The information of corresponding deviation that was got through experiment proved that this method had improved accuracy and adaptability greatly, which achieved desired results on chinese chives. It had certain reference value to the follow-up study.

**Acknowledgments:** This work was financially supported by the open fund project of NERCITA (KFZN2012W12-012), Zhengzhou Municipal Science and Technology Bureau project (131PPTGG411-13), and backbone teacher plan project of Zhengzhou University of Light Industry, Science and Technology Innovation Fund Project of Zhengzhou University of Light Industry graduate student (2014003).

## References

[1] Marchant JA, Brivot R. Real time tracking of plan trows using a Hough transform[J]. Real Time Imaging, 1995, 1(5): 363-371.

[2] Bjorn Astrand, Albert-Jan Baerveldt. A vision based row-following system for agricultural field machinery[J]. Mechatronics 2005, 15(2): 251-269.

[3] Ollis M, Stentz A. First result in vision-based crop line tracking[C]//Proceedings of the 1996 IEEE Conference on Robotics and Automation (ICRA'96), Minneapolis, MN. 1996: 951-956.

[4] Søgaard H T, Olsen H J. Determination of crop rows by image analysis without segmentation[J]. Computers and Electronics in Agriculture, 2003, 38(2): 141-158.

[5] Yutaka Kaizua, Kenji Imoub. A dual-spectral camera system for paddy rice seedling row detection[J]. Computers and Electronics in Agriculture, 2008, 63(1): 49-56.

[6] Zhang Zhibin, Luo Xiwen, Zhou Xuecheng, et al. Crop rows detection based on Hough transform and fisher discriminant criterion function[J]. Journal of Image and Graphics, 2007, 12(12): 2164-2168.

[7] Zhang Zhibin, Luo Xiwen, Li Qing, et al. New algorithm for machine vision navigation of farm machine based on well-ordered set and crop row structure[J]. Transactions of the Chinese Society of Agricultural Engineering (Transactions of the CSAE), 2007, 23(7): 122-126.

[8] Luo Xiwen, Ou Yinggang, Zhao Zuoxi, et al. Research and development of intelligent flexible chassis for precision farming[J]. Transactions of the Chinese Society of Agricultural Engineering (Transactions of the CSAE), 2005, 21(2): 83-85.

[9] Zhao Ruijiao, Li Minzan, et al. Rapid Crop-row Detection Based on Improved Hough Transformation[J]. Transactions of the Chinese Society for Agricultural Machinery, 2009, 40(7): 163-165, 221.

[10] Zhang Lei, Wang Shumao, Chen Bingqi, et al. Crop-edge Detection based on machine vision[J]. New Zealand Journal of Agricultural Research, 2007, 50(5): 1367-1374.

[11] N. Nirmal Singh, Avishek Chatterjee, Amitava Chatterjee, et al. A two-layered subgoal based mobile robot navigation algorithm with vision system and IR sensor[J]. Measurement, 2011, 44(5): 620-641.
[12]Jinlin Xue, Lei Zhang, Tony E. Grift. Variable field-of-view machine vision based row guidance of an agricultural robot[J]. Computers and Electronics in Agriculture, 2012, 84: 85-91.

[13]Ronghua Ji, Lijun Qi. Crop-row detection algorithm based on Random Hough Transformation[J]. Mathematical and Computer Modeling, 2011, 54(3-4): 1016-1020.

[14]Haibo Jiang, Yilong Xiao, Yunwei Zhang, et al. Curve Path detection of unstructured roads for the outdoor robot navigation[J]. Mathematical and Computer Modelling, 2013, 58(3-4): 536-544.

[15]Kuo-Yi Huang. Detection and classification of areca nuts with machine vision[J]. Computers and Mathematics with Applications, 2012, 64(5): 739-746.

[16]Faisal Ahmed, Hawlader Abdullah Al-Mamun, A.S.M.Hossain Bari, et al. Classification of crops and weeds from digital images: A support vector machine approach[J]. Crop Protection, 2012, 40(10): 98-104.

[17]Junhong Ji, Guodong Chen, Lining Sun. A novel Hough transform method for line detection by enhancing accumulator array[J]. Pattern Recognition Letters, 2011, 32(11): 1503-1510.