Vision-Based Row Detection Algorithms Evaluation for Weeding Cultivator Guidance in Lentil

It is important to detect crop rows accurately for field navigation. In order to accurate weeding, cultivator guidance system should detect the crop center line precisely. The methods of vision-based row detection for lentil field were studied. Monochrome and color images were used in this research. The color images are transformed into grey scale images in two different formulas to make comparing among them and find an optimal one. In order to detect the center of the crop row rapidly and effectively, Hough transform and gravity center image processing algorithms were applied to acquired images. The field crop images were segmented into two parts by using optimal thresholding (plant and soil as a background), then Hough transform was applied on these binary images. Gray scale images were used in gravity center method. The center line detection algorithms were tested for two weed distribution density, include general and intensive. It was observed that both systems successfully detects and calculates the pose and orientation of the crop row on synthetic images. The mean errors between the calculated and manually estimated lines were obtained. Mean errors for Hough transform and gravity center methods were 8 and 10 mm with standard deviations of 7 and 12 mm in general distribution density and 12 and 16mm with standard deviation of 11 and 15mm in high distribution density, respectively. Computational time for Hough transform and gravity center were 0.7 and 0.4 s for general distribution density and 1.2 and 0.8 s for high distribution density, respectively.


Introduction
The presence of weeds in agricultural fields leads to competition between weeds and planted crops.Therefore, it is necessary to eliminate the weeds for better crop growth.The two widely used methods for weed control are chemical and non-chemical weed control.The inorganic chemicals are mainly used to eliminate the weeds in agricultural fields and to increase and protect the crop production.During a past few years, the primary concern in agriculture was organic production.In organic farming no herbicides are permitted, since they have adverse impacts on the environments, soil health, food safe and they cause water pollution and disorder population of healthy worms, and other soil organisms (Asif, Amir, Israr, & Faraz, 2010).
Non-chemical weed control uses some mechanical technique to remove weeds.Manual weeding require labors for which is expensive and is not always available (Dedousis, 2007).Tractor driven cultivator was substituted for manual weeding.It almost improves operation efficiency and productivity.In mechanical weed control, weeding equipment is able to control the weeds between the rows.The lateral position of weeding cultivator tools relatively to crop rows, are usually controlled by the driver of the tractor.This task needs more concentration and could hardly be maintained during a long period, because driver has to give his attention to both tractor and tools position, therefore it exhausts the driver.The precision of the driver guidance between rows determines width of hoeing unit.If driver couldn't be able to achieve the required driving accuracy, the mentioned width should be decreased, so inter-row untreated area would be increased.Weed control within the row and untreated area requires a lot of manual labors, if we could decrease untreated area between rows, we will be managed to decrease the time needed for this manual working.Under these circumstances, developing an assistant system that can automatically detect rows and guide tools or vehicles, would be helpful.
GPS-based and vision-based guidance systems are the most promising navigation methods for the autonomous guidance (Wilson, 2000;Hague, Marchant, & Tillett, 2000).
GPS-based guidance system relies on prior predefined path information that had been already obtained by sowing machines.However, the coordinates of the crop rows in the real world are currently unavailable (Bakker, Wouters, & Asselt, 2008).GPS has a common limitation on obtaining local accurate position which is often very important for performing efficient automated field operations.The guidance system based on GPS requires more accuracy than common GPS receivers, RTK-GPS is expensive and isn't available in all over the world.
Navigation along the crop row is based on real-time sensed data.Machine vision can obtain this real-time information by detecting rows.In contrast to a real-time differential global positioning system (RTK-GPS), Machine vision is cheaper and has a higher precision.Furthermore, machine vision can provide local or relative information.
In vision-based guidance, data is provided by images acquired from vehicle-mounted cameras.As most crops are cultivated in rows, it is the key to find guidance information from crop row structure in vision-based guidance systems, to precisely control tool or vehicle.
CPU's speed development in recent years copes with high computational load that is needed to vision-based tools and vehicles guidance.A machine vision-based guidance system manages to achieve accurate navigation in an appropriate time that is necessary for real time control.It also does not require a priori field information The problem of guiding automatically an implement in a farm using machine vision is not new, many technologies and algorithms of image processing were investigated to find guidance line from the row crops.
Recent developed technologies could be divided into the two general categories: autonomous steering and guidance assistance.The main purpose of them, were to evaluate the position of the tool or vehicle in the field relatively to the rows (Leemans and Destain, 2006).Billingsley and Schoenfisch (1997) presented a method to steer a tractor by following cotton rows.At first they segmented image pixels by applying thresholding.The line position was determined by regression method.Hague et al. (2000) used Hough transform and Kalman filter methods for localizing the row structure and obtaining experimental automatic vehicle position based on image processing.Sogaard and Olsen (2003) mounted a camera on a hand operated vehicle and later on a cultivator to evaluate the accuracy of guidance system based on machine vision.At first they divided images into band strip.Then they calculated their center of gravity.The row position was calculated by weighted linear regression.The standard deviation was about 15 mm.Tillett, Hague and Mile (2002) applied a method similar to previous work.They used state vector and Kalman filter instead of regression to determine the row position.They succeed in getting the precision of 16 mm.The Hough transform is the most common crop row detection algorithm used.The Hough transform algorithm is used in line detection for its high robustness.The Hough transform was first proposed by Marchant and Brivot (1995) to detect the crop center line.Marchant (1996) applied the Hough transform to infra-red images to detect crop rows.Leemans and Destain (2006) used a mean shift algorithm to search the maximum value in the Hough transform domain, to identify the crop rows.To obtain good results for detecting several crop rows, an adapted Hough transform was combined with a priori knowledge of the spacing between rows, and then tested.Åstrand and Baerveldt (2005) applied a row detection method, which combined the Hough transform and the geometric model.The Hough transform was used for detecting crop row structures, while the geometric model determined the link between the image and the ground coordinates.Bakker et al. (2008) opposed a gray-scale Hough transform based crop row detection algorithm.At first color image were transformed into a gray scale images in their method.Then the Hough transform was applied on these gray images to detect the crop rows.They selected three rectangular sections of crop row spacing, and then he summed up the grey values of the sections and used the grey-scale Hough transform to find the row.Pla, Sanchiz, Marchant and Brivot (1997) offered an algorithm based on finding the vanishing point of the rows.Tillett et al. (2002) described an algorithm based on the periodic variations of brightness between the plants and soil in the parallel crop rows.Han et al. (2004) described a guidance line detection algorithm.The algorithm first segmented images using the K-cluster algorithm, then detected rows with the moment algorithm and guidance line was selected based on the cost function.Kise and Zhang (2008) developed a stereo-vision system capable of performing three dimensional (3D) field mapping for measuring crop height and volume and detecting crop rows in 3D for tractor guidance.
Jiling and Liming (2010) offered a vision-based row guidance method to guide a robot platform which was designed independently to drive through the row crops in a field according to the design concept of open architecture.Their method's accuracy of row guidance was up to ± 35mm.Tillett et al. (2002); Åstrand and Baerveldt (2002); Bakker et al. (2008) applied their vision based crop row detection algorithms in a sugar beet field.Tillett and Hague (1999); Sǿgaard and Olsen (2003) tested their vision guidance methods for cereals.Some of the researchers tested their guidance system for Lettuce and tomato (Slaughter, Chen, & Curley, 1999), cotton (Billingsley & Schoenfisch, 1997;Slaughter et al., 1999) and cauliflower (Marchant & Brivot, 1995), soybean (Kise et al., 2005).But these vision based guidance algorithms were not evaluated for lentil.
Different automatic guidance algorithms have been developed for agricultural applications.But as it was mentioned before above, Hough transform and gravity center were the most successful methods that were applied in most researches.
In this paper, these two successful algorithms were studied on images that were acquired from lentil farm by an experimental platform constructed in University of Tabriz.The objective was to get the best image processing method to navigate weeding units automatically between the inter-row spaces of crop for improving the percentage of treated area, reduce labor cost and time.

Materials and Methods
A lentil experimental filed for performing the tests was prepared in research farm.Lentil seeds were sown manually to eliminate adverse effect of seed bouncing.Two bars were inserted into the ground on the sides of field and a rope was fastened on them.And lentil seeds were laid in the furrow exactly below the rope.The length of the experimental field was about 40 m.Three rows were sown at distances of 30 cm (figure 1).
Two image acquisition systems were used.First system was a CMOS monochrome camera equipped with a near infra-red band-pass filter.It was used to remove visible wavelength to enhance the images.Second system was a CCD camera with color output to obtain sample images from lentil farm.The resolution of image was 640×480 pixels.The focal length of the camera lens was 8 cm.The cameras were mounted on an experimental platform (figure 1).

Figure 1. The experimental platform and lentil farm
The mobile platform was driven by a DC electric motor over the field.The platform consisted of two main parts: stationary and movable frames.Stationary frame was driven by a DC motor on 4 wheels.The motor speed could be controlled by PWM pulses adjusted by the computer.The cameras were mounted on the movable section of the platform.They were able to get the images and send them to computer to save them.One image frame per second was saved in the computer.The camera was directed downward at a specific angle 30˚, and the vertical distance from the camera to the ground was 100 cm.The covered area by one image was 1 m long in row direction and 1.5m wide.After acquiring the images, two crop-row detection algorithms were executed on a computer.
Image processing was performed using an industrial laptop computer having an Intel Dual Core i7-2620M 2.7 GHz CPU 8 GB RAM.
Images were acquired at the Agricultural faculty Farm (Khalatposhan) in Tabriz, during growing season of 2012 and 2013.To test the robustness of the system, they were taken under various weed and soil conditions .In three stage of plant growing tests were undertaken.The crop heights in the images were around 5(small), 16(medium) 24(large) centimeters (approximate 1-3 weeks of growth time).
Suitable ROI (region of interest) was selected to restrict the image processing and to reduce the processing time.This ROI was selected based on calibration process.A striped course textile with 10cm width vertical black and white strips, was used to calibration, as was shown in figure 2. This area should be selected as a rectangle with 30cm width so three vertical strips were selected, image perspective model made the ROI figure to be trapezoidal.The corner coordinates of this Trapezoid were found in the image.These coordinates were used to separate ROI from the image.ROI selection is set manually as shown in figure 2.

Image Processing
In order to detect the center line of the crop row in field images, several image processing steps should be applied to the field images, which include color transformation, image segmentation, noise removal, edge detection and line parameter calculation.

Transform Color Images to Gray Images
The crop-row image mainly consists of crops and background (such as soil).There is a big difference between the crop and background in color.Therefore, color was taken as the feature.But just gray-scale images could be used in image processing.The gray images with bimodal histograms can be segmented effectively by a threshold segmentation algorithm.The color field images, which were taken under natural conditions, were grayed by three color features.
In the first color transformation method, the color images were transformed into a grey image by emphasizing the green value and decreasing the red and blue value.The green value was larger than the red and blue value.Its principle is shown as equation (1).I 1 (x,y)=2×G-B-R (1) Where G, R, B were equal to the green, red and blue value of point (x, y) respectively in the color image.I 1 (x, y) denotes the grey value of pixel(x, y) in the grey image, and were limited to [0,255].
The second color transformation was performed using the Intel image processing formula.This formula is used for color to gray conversion in common image processing toolboxes like MATLAB.I 2 (x,y)= 0.212671R + 0.715160G + 0.072169B (2) Gray-scale images were stored with 8 bits per sampled pixels, so color conversion decreased the image processing calculation load by two third.
So we had three kinds of gray-scale images: two types of transformed images from color images and images acquired directly from monochrome camera equipped with a NIR band-pass filter.

Segmentation
Segmentation technique was used to separate the soil and crop by their color difference.After segmentation images were partially processed that includes just crops information.Other objects like soil, stone and residues were considered as background.
A threshold segmentation algorithm was applied in this system for its simplicity and speed.The outdoor agricultural navigation system needs to be adaptable to various weather and lighting conditions.It requires the proposed threshold values selection has the robustness to the lighting variety as well, so adaptive global thresholding algorithm was used to perform the segmentation.Constant threshold values didn't show satisfactory result in changeable condition.Otsu automatic threshold value calculation was applied on the image gray values as the flow chart of figure 3. The basic principle of Otsu is looking for the best threshold value to divide grey-level histogram of an image into two classes on the condition that between-classes variance is maximal.

Noise Reduction
To improve the resulted binary images and reduce the fine details in an image the median filtering was used.The median filtering reduced the details in the images by applying the image blurring operation.

Edge Detection
After converting the image into the binary images, edge detection was performed.To optimize and better edge information, Sobel edge detection was applied.The vertical and horizontal Sobel gradient operators were used to get better edge detection results.The Sobel edge detection was computationally simple so it was spent just about 0.05-0.07sfor the Sobel implementation.

Line Detection
The center line of the crop row should be detected for tool navigation.Center line of the crop row was detected by two algorithm based on the Hough transform and gravity center.

Hough Transform Method
Binary images were used for Hough transform based row position detection method.
The Hough transform is a line detection algorithm based on the relationship between point (x,y) and line (y=ax+b).For applying Hough transform algorithm, a set of points in image space were mapped to a set of lines in parameter space.If these points in image space are all located on the line (y = ax+b), the mapped lines in parameter space will pass the common point (a, b).This parameter space was not suitable for the studies like our research that 'a' approaches infinity as line approaches the vertical direction.So, normal representation of a line was used.It is named Hough space.

Xcosθ+ysinθ=ρ
(3) In this study ρ and θ were position and orientation of the crop row.
After transforming the points in the image space to Hough space, peak detection was performed on all the points of the space that are identified as accumulators.The peak point (ρ,θ) coordinate was the line parameters that we were looking for.

Gravity Center
Gray scale images were used in gravity center row position detection method.The gray images were divided into a number of horizontal strips as shown in figure 4. Three factors affect the number of strips: existence of minimum one plant in a strip, computational load, and accuracy.In order to reduce the amount of subsequent computations, it may be better choose the least number of strips.Exceeding number of strips causes more accuracy, because it makes more points for fitting line.Drilled crops like cereals and pea don't have any given interval between crops so more strips can be selected.When strip numbers were exceeded more than 10, significant increasing in computational time was observed, so 10 strips were chosen (figure 4).It was just 4 strips were shown in the figure 4 for convenience and better appearance.The gravity center method was used for getting the center of the row for each image strip.The resolution of image was considered to be M ×N pixels.The image strip size is M ×k.I (i, j) was the grey value of the pixel in position (i, j), w( j) was the result of summation of column j : And s was the sum of the grey values of the whole image strip: (5) Right section of figure 4 shows the grey values distribution of each column.As can be shown in left section of figure 5, the grey values of crop's area were higher than the background.Weeds roll in the both side of the crop row were the same in the distribution histogram.Weighted center of strips was the position of the column (j) that was encountered the condition of equation 5.

(6)
This process was continued for all the strips and weighted center points of strips were computed.The best fitted line to these points was estimated by using the regression method.So the crop center line was obtained.

Results and Discussion
The performance of the mentioned algorithms, were evaluated against three criteria: accuracy, robustness and computational requirements.The mean errors between the calculated and manually estimated lines pose (ρ) were obtained to detect the method accuracy.The orientation (θ) was used just for the acceptance basis of the process.
Since the main purpose of the study was to achieve real-time automatic guidance of weeding cultivator in lentil, the time requirement was the most important issue.
Both monochrome images acquired with a camera equipped with a band filter and gray-scale showed better robustness in different weather (sunny or cloudy) and soil (dry or wet) conditions.They showed almost constant results.These gray-scale transformation methods were tested by Hough transform method.Mean error were 7, 8 and 15mm and standard deviation were 8, 10 and 19mm for medium size of plants with transformed images with filter, green-emphasized (equation 1)and ordinary gray-scale (equation 2) transformation methods, respectively.The experimental results indicated that the filtered images could overcome the impact of shadows better than others.Green-emphasized images was managed to omit shadow from the images, but sometimes it was observed that it omit some information of plant leafs covered by shadow, so it was confronted some errors.
Segmentation time requirement was omitted in the gravity center and calculation load of this algorithm was so lower than Hough transform, so time costs were about 0.3, 0.45 and 0.7 for small, medium and large size of plants, respectively.
The images that edge detection were applied on them in spite of showing the best time costs (about 2-3s) represented the weakest accuracy with mean error of 25-30mm.So these images weren't used any more for the line detection.
Two center line detection algorithms were tested for two weed distribution density, include general and intensive.Mean errors for Hough transform and gravity center methods were 8 and 10 mm with standard deviations of 7 and 12 mm in general distribution density and 12 and 16mm with standard deviation of 11 and 15mm in high distribution density, respectively.Computational time for Hough transform and gravity center were 0.7 and 0.4 s for general distribution density and 1.2 and 0.8 s for high distribution density, respectively.

Conclusion
The experimental result indicated that the band-filtered images had lower mean errors and could overcome the impact of shadows.
It was observed that both algorithms successfully detect and calculate the pose and orientation of the crop row on synthetic images.Hough transform demonstrated better accuracy in the images including non-germinated gaps.The gravity center presented better time costs result.Lentil crops are sown with drill planters so its row seems continuous without gaps between plants in the row.In this ideal situation this algorithm showed better result.But the row with non-geminated gaps showed weak results with higher errors.Times costs for Hough transform algorithm was higher than gravity center method.

Figure
Figure 2. Calibration process

Figure 3 .
Figure 3. Otsu automatic threshold value detection method

Figure 4 .
Figure 4. image division and their histogram distribution