Department of Mathematics J.J.Strossmayer University of Osijek
Transcript of Department of Mathematics J.J.Strossmayer University of Osijek
Department of MathematicsJ. J. Strossmayer University of Osijek
Series: Technical Reports
Center-based clustering for line detection Ivan Vidović Rudolf Scitovski Ivan Vazler
1
Center-based clustering for line detection1
Ivan Vidović2
Faculty of Electrical Engineering, University of Osijek3
Cara Hadrijana 10b, HR – 31 000 Osijek, Croatia4
e-mail: [email protected]
Rudolf Scitovski16
Department of Mathematics, University of Osijek7
Trg Lj. Gaja 6, HR – 31 000 Osijek, Croatia8
e-mail: [email protected]
Ivan Vazler10
Department of Mathematics, University of Osijek11
Trg Lj. Gaja 6, HR – 31 000 Osijek, Croatia12
e-mail: [email protected]
Abstract. This paper proposes a new efficient method for line detection based on14
known incremental methods of searching for an approximate globally optimal partition15
of data point set A and on the DIRECT algorithm for global optimization. The pro-16
posed method was modified for solving the problem of detecting crop rows in agricultural17
production. This modification can recognize crop rows with a high accuracy, whereby18
the corresponding used CPU-time is very acceptable. The method has been tested and19
compared on synthetic data sets with the method based on Hough transformation. The20
efficiency of this method might be significantly improved in direct application. The pro-21
posed method has been used in this paper for the case of two or three crop rows and it22
could be easily generalized in case of a greater number of crop rows. Also, the method23
could be expanded in case when the number of crop rows is not known in advance.24
Key words: line detection; crop row detection; clustering; incremental method; global25
optimization; DIRECT.26
1 Introduction27
Line segment or line detection problem has many applications. Let us mention the one that28
has special importance in agricultural production. The processes of planting, fertilization,29
plant protection and finally harvesting are the most important processes in agriculture30
that can be automated. During any of the mentioned processes humans must handle a31
machine (a tractor, for example) with a high degree of precision and repeat the same32
activity for several hours, which can be very exhausting. With acceptably accurate crop33
1Corresponding author: Rudolf Scitovski, e-mail: [email protected], telephone number: ++385-31-224-800, fax number: ++385-31-224-801
2
row detection it is possible to automate machine work which is usually very exhausting1
and sometimes too demanding for humans.2
The mentioned automation processes of machines in agricultural production have been3
subjects of many papers. One of the first approaches to solving this problem is a Hough4
transform-based method. [22] proposed a method based on Hough transformation, which5
uses the information about the number of crop rows making this technique very tolerant6
to problems like missing plants and weeds. The method has been tested on cauliflowers,7
sugar beet and widely spaced double rows of wheat. [3] transformed captured color images8
to gray-scale images which have good contrast between a plant and background. Sugar9
beet rows have been detected using gray-scale Hough transformation. [15] proposed a cen-10
ter line crop row detection method using gradient-based random Hough transformation.11
The method has been tested on sparse, general and intensive plant distribution and the12
results have shown that the proposed method is faster and more accurate than general13
Hough transform-based algorithms. An adaptation of Hough transformation applied to14
soil and chicory rows detection was proposed by [18]. They used neural networks for15
plants detection and adapted Hough transformation for rows detection. In this adapta-16
tion, the Hough transformation method uses theoretical crop row position and direction17
for reference in Hough plane. Deviation of detected crop rows from the reference was a18
few centimeters and authors found this compatible with the application. [31] presented19
a combination of Hough transformation and connectivity analysis for finding a pathway20
between crop rows.21
Other possibilities for crop row detection are filter-based methods. The method for hoe22
guidance based on the extended Kalman filter was proposed by [39]. The prediction of row23
position has been calculated according to the previous state and inputs using the Kalman24
filter and corrected by least squares incorporation of new observations. This method is25
very sensitive to the presence of shadows. [27] proposed a method for detecting centre26
position of crop rows using an infrared filter based on summation of pixel gray values.27
The method is not sensitive to shadows while lateral winds and lateral illumination cause28
offset in the calculated row position. [14] proposed a combination of an [27] method and29
a Kalman filter. The method is applicable to images with presence of shadows unlike the30
method presented earlier [39].31
There are several other aproaches for crop row detection like methods based on vanish-32
ing points or linear regression. [29] presented a method for guiding a crop row navigation33
vehicle based on a scene structure building using a vanishing point. Feature extraction34
was done by a method based on region skeletons. The method does not work well when35
an image is captured at the end of the field where the remaining length of the rows is36
short. The method for detecting crop rows without image segmentation was proposed37
by [36]. Computation of line parameters was done by weighted linear regression and38
the method has been tested on real images. [23] proposed a new method for crop row39
detection in maize fields with a high presence of weeds. The method is based on three40
3
steps including image segmentation, double thresholding and linear regression. The Ex-1
cess Green vegetation index has been used for transforming captured RGB images to gray2
images and double Otsu thresholding has been applied for separating weeds and crops.3
For calculating line parameters associated to the crop rows, linear regression based on4
total least squares has been used. The main finding of this paper is double thresholding5
used for separating weeds and crops. The method has been favorably compared to a6
classical Hough approach measuring effectiveness and processing time. A new method for7
crop row detection in maize fields based on linear regression and Theil-Sen estimator was8
proposed in [13]. Crops and weeds are detected by using the Otsu thresholding method9
and the detection of crop rows is based on mapping the expected crop lines onto image10
and applying the Theil-Sen estimator to adjust them to the real ones.11
In our paper, we first consider the problem of recognizing several lines in general12
position (Section 2) and propose a new cluster-based incremental method of searching for13
approximate lines (Subsection 2.3.2). After that, in Section 3 we propose a new method14
for crop row detection as a combination of total least squares linear regression and a15
modification of the previously mentioned center-based incremental method. In Section 4,16
the proposed methods have been tested and compared with the Hough transform-based17
algorithm on synthetic data simulating various real situations.18
2 Line detection problem19
Let us notice first that, without loss of generality, we can suppose that the arbitrary line20
in the plane is given by21
ax + by − c = 0, a2 + b2 = 1, c ≥ 0. (1)22
Let us suppose that the data point set A is given whose elements derive from previously23
unknown lines. Thereby the number of lines can, but need not be, known in advance. On24
the basis of the given data point set A the lines could be reconstructed.25
2.1 Data point set construction26
The line detection problem shall first be considered on the data point set deriving from27
lines in general position. Let I = {1, . . . , m} be the set of indices and28
A = {Ti = (xi, yi) ∈ R2 : i ∈ I} ⊂ R (2)29
the data point set contained in the rectangle R = [xmin, xmax] × [ymin, ymax]. The data30
point set A is generated by k lines31
pj : ajx + bjy − cj = 0, a2j + b2
j = 1, cj ≥ 0, j ∈ J = {1, . . . , k}, (3)32
4
in the following way. First, we choose interval [ymin, ymax] ⊂ R and for each j ∈ J we1
define mj ≥ 3 equidistant spaced numbers η1, . . . , ηmj∈ [ymin, ymax] and the set (see2
Fig.1).3
Aj = {(ξ(j)i , η
(j)i ) + ϵ
(j)i (aj, bj) : ξ
(j)i = 1
aj(cj − bjη
(j)i ), ϵ
(j)i ∼ N (0, σ2), i = 1, . . . , mj}.4
ajx + bjy − cj = 0
(ξ(j)i , η
(j)i )
ϵ(j)i bj
ϵ(j)i aj
(ξ(j)i + ϵ
(j)i aj , η
(j)i + ϵ
(j)i bj)
ymin
ymax
Figure 1: Data generating
The data point set A =k∪
j=1Aj consists of m = ∑k
j=1 mj data points Ti = (xi, yi) ∈5
[xmin, xmax] × [ymin, ymax], where xmin = mini,j
{ξ(j)i + ϵ
(j)i aj}, xmax = max
i,j{ξ
(j)i + ϵ
(j)i aj}.6
On the basis of the given data point set A, lines p1, . . . , pk should be reconstructed.7
2.2 Hough transformation method for line detection8
Line detection by the Hough transform-based method [6] is achieved by searching for the9
maximum in the Hough plane (accumulator), which represents the transformation of the10
input image. Each point T = (ξ, η) ∈ A ⊂ R2 in the Hough plane is represented by all11
possible lines given in Hesse normal form passing through the point T , i.e. the set12
{(α, δ) ∈ R2 : ξ cos α + η sin α − δ = 0}.13
In this way, some line p in the plane R2 is represented by a pair (α, δ) in the Hough14
plane, and some point T ∈ R2 is represented by the sequence of points in the Hough15
plane. Points that in the original image lie on a line increase the intensity of the point16
that represents that line in the Hough plane. The algorithm for line reconstruction, which17
is based on recognizing the most intensive points in the Hough plane will be hereinafter18
simply referred to as HTA.19
2.3 Cluster-based line detection20
Line detection problem can also be considered [18, 41] as a data clustering problem of the21
set A in k nonempty disjoint subsets (clusters) π1, . . . , πk such that22
k∪i=1
πi = A, πr ∩ πs = ∅, r = s, |πj| ≥ 1, j = 1, . . . , k. (4)23
5
Such partition will be denoted by Π, and the set of all partitions of the set A consisting of1
k clusters π1, . . . , πk will be denoted by P(A; m, k). Clustering or grouping a data set into2
conceptually meaningful clusters is a well-studied problem in recent literature, and it has3
practical importance in a wide variety of applications such as medicine, biology, pattern4
recognition, facility location problem, text classification, information retrieval, earthquake5
investigation, understanding the Earth’s climate, psychology, ranking of municipalities for6
financial support, business, etc. [17, 20, 24, 28, 30, 32–34].7
If we introduce the distance from the point T = (ξ, η) ∈ A to a line pj(aj, bj, cj) given8
by (1) as orthogonal squared distance [4, 26]9
d(pj(aj, bj, cj), T ) = (ajξ + bjη − cj)2, (5)10
then to each cluster πj ∈ Π we can associate its center-line pj(aj, bj, cj) where11
(aj, bj, cj) = argminaj ,bj ,cj∈R
∑T ∈πj
d(pj(aj, bj, cj), T ). (6)12
Note that in this way the center-line pj(aj, bj, cj) of the cluster πj is defined as the best13
total least squares (TLS) line [4, 12, 23, 26, 35].14
After that, by introducing the objective function F : P(A; m, k) → R+ we can define15
the quality of a partition and search for the globally optimal k-partition by solving the16
following global optimization problem (GOP):17
argminΠ∈P(A;m,k)
F(Π), F(Π) =k∑
j=1
∑T ∈πj
d(pj(aj, bj, cj), T ), (7)18
where the center-line pj is determined by (6).19
Conversely, for a given set of center-lines p1, . . . , pk, by applying the minimal distance20
principle, we can define the partition Π = {π(p1), . . . , π(pk)} of the set A which consists21
of the clusters:22
π(pj) = {T ∈ A : d(pj, T ) ≤ d(ps, T ), ∀s = 1, . . . , k}, j = 1, . . . , k, (8)23
where one has to take into account that every point of the set A occurs in one and only24
one cluster. Therefore, the problem of finding an optimal partition of the set A can be25
reduced to the following GOP26
argmina,b,c∈Rk
F (a, b, c), F (a, b, c) =∑T ∈A
min1≤s≤k
d(ps(as, bs, cs), T ), (9)27
where F : R3×k → R+, and a = (a1, . . . , ak), b = (b1, . . . , bk), c = (c1, . . . , ck). The solution28
of (7) and (9) coincides. Namely, it is easy to verify the following equalities29
F (a⋆, b⋆, c⋆) = ∑T ∈A
min1≤s≤k
d(p⋆s, T ) =
k∑j=1
∑T ∈π(p⋆
j )min
1≤s≤kd(p⋆
s, T )
=k∑
j=1
∑T ∈π(p⋆
j )d(p⋆
j , T ) = F(Π⋆).(10)30
6
The objective function F can have a large number of independent variables. It does not1
have to be either convex or differentiable, but it is a Lipschitz continuous function [11, 28,2
32]. The objective function F can also be considered as a symmetric function Φ: Rk×3 →3
R+, Φ(ζ1, . . . , ζk) := F (a, b, c), where ζj = (aj, bj, cj). Because of the symmetry property,4
the function Φ has at least k! local and global minimizers. Therefore, this becomes a5
complex GOP for a symmetric Lipschitz continuous function.6
The following example gives a solution of the problem (9) in the simplest case k = 1.7
Example 1. For the given data point set A = {Ti = (xi, yi) ∈ R2 : i ∈ I} ⊂ R, R =8
[xmin, xmax] × [ymin, ymax], by solving GOP (6) the corresponding TLS line should be de-9
termined. The best TLS line passes through the centroid of the data (xc, yc), xc = 1m
m∑i=1
xi,10
yc = 1m
m∑i=1
yi and it can be determined [4, 26] by the eigenvector which belongs to a smaller11
eigenvalue of the matrix BT B, where12
B =
x1 − xc y1 − yc
... ...xm − xc ym − yc
.13
We will mention several known methods of searching for a globally optimal partition14
or an approximate globally optimal partition, which can be adapted for solving GOP15
(9). Since our objective function F in (9) is a Lipschitz continuous function, there are16
numerous methods for its minimization [7, 9, 25, 28]. One of the most popular algorithms17
for solving a GOP for a Lipschitz continuous function is the DIRECT (DIviding RECTangles)18
algorithm [8, 10, 16]. However, a large number of independent variables of the minimizing19
function F and a large number of its global minimizers make these methods insufficiently20
efficient.21
Instead of searching for the globally optimal partition, various simplifications are often22
proposed in the literature that would find a good partition. However, we usually do not23
know how close this partition is to the globally optimal one.24
2.3.1 Adjustment of the k-means algorithm25
The most popular algorithm of searching for a locally optimal partition is a well-known26
k-means algorithm (see e.g. [17, 20, 37, 38]). If we have a good initial approximation,27
this algorithm can provide an acceptable solution. In case we do not have a good initial28
approximation, the algorithm should be restarted with various random initializations, as29
proposed by [19]. This algorithm can be modified for solving GOP (9) (see Algorithm 1).30
7
Algorithm 1 (k-means algorithm)1. Let A = {Ti = (xi, yi) : i = 1, . . . , m}, and p1, . . . , pk be mutually different lines;2. By using the minimal distance principle (8) determine k disjoint unempty clus-
ters π1(p1), . . . , πk(pk);3. For each cluster πj define center-line pj according to (6);4. if {p1, . . . , pk} = {p1, . . . , pk} then5. STOP6. else7. set pj := pj, j = 1, . . . , k and go to Step 2;
1
2.3.2 Adjustment of incremental methods2
The next possibility of searching for the solution of (9) is adjustment of incremental3
methods of searching for an approximate globally optimal partition [1, 2, 21, 34]. This4
adjustment will be called Incremental Method for Line Detection (IMLD).5
First, suppose that the initial center-line p1(a1, b1, c1) is chosen or that we have taken6
it to be the best TLS line (see Example 1). The next center-line p2(a2, b2, c2) will be7
determined by solving the following GOP (see [34]):8
argminα,β,γ∈R
m∑i=1
min{d(p1(a1, b1, c1), Ti), d(p(α, β, γ), Ti)}, α2 + β2 = 1, γ ≥ 0,9
by using the DIRECT algorithm. After that, an approximate globally optimal partition10
Π⋆ = {π⋆1(p⋆
1), π⋆2(p⋆
2)} with center-lines p⋆1, p⋆
2 will be obtained by using the k-means11
algorithm (Algorithm 1) where we take (p1, p2) as initial center-lines.12
Generally, if the first k−1 center-lines p1, . . . , pk−1 are known, the center-line pk(ak, bk, ck)13
will be determined by solving the following GOP14
argminα,β,γ∈R
m∑i=1
min{δik−1, d(p(α, β, γ), Ti)}, δi
k−1 = min{d(p1, Ti), . . . , d(pk−1, Ti)}, (11)15
by using the DIRECT algorithm. After that, an approximate globally optimal partition16
Π⋆ = {π⋆1(p⋆
1), . . . , π⋆k(p⋆
k)} with center-lines p⋆1, . . . , p⋆
k will be obtained by using Algorithm 117
where we take (p1, . . . , pk) as initial center-lines.18
The following example illustrates HTA and the proposed IMLD for line detection.19
Example 2. On the basis of the given lines20
p1 : 0.9x − 0.4y + 0.18 = 0, p2 : x + 0.05y + 0.6 = 0, p3 : 0.135x + y + 0.3 = 0,21
data point set A is constructed as in Section 2.1 (see Fig. 2a). It can be noticed that22
IMLD has recognized all three lines (see Fig. 2c), whereas HTA did not recognize line p323
(see Fig. 2b).24
8
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
øø
øø
ø øø
ø
ø
ø
øø
ø
0.2 0.4 0.6 0.8 1.0
0.2
0.4
0.6
0.8
1.0
(a) Generated data points
p1 p2
p3
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
øø
øø
ø øø
ø
ø
ø
øø
ø
0.2 0.4 0.6 0.8 1.0
0.2
0.4
0.6
0.8
1.0
(b) HTA
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
øø
øø
ø øø
ø
ø
ø
øø
ø
0.2 0.4 0.6 0.8 1.0
0.2
0.4
0.6
0.8
1.0
(c) IMLD
Figure 2: Line detection by HTA and IMLD
3 An application: crop row detection1
A special case of the line detection problem is a crop row detecting problem, which has2
already been mentioned in the Introduction. Let us first formally define the problem.3
Suppose that the data point set A ⊂ R, R = [xmin, xmax] × [ymin, ymax] is generated as4
in Subsection 2.1 on the basis of lines p1, . . . , pk that intersect the interval [xmin, xmax]5
in equidistant knots ν1, . . . , νk ∈ [xmin, xmax] and have the common vanishing point B =6
(xB, yB), xmin ≤ xB ≤ xmax, yB > ymax [18] (see e.g. Figures 4a,5a,6a,7a). On the basis7
of the data point set A, lines p1, . . . , pk should be reconstructed.8
As stated in the Introduction, there are many different approaches to solving this prob-9
lem that can be found in literature. The problem can also be solved by using the IMLD10
method mentioned in Section 2.3.2. Numerical experiments carried out in Section 4 have11
shown that IMLD does not always offer the best results, and that additional modifications12
need to be done. These modifications were described in algorithms mentioned below. The13
algorithms for solving the problem of detecting two and three crop rows will be specially14
mentioned. These procedures can easily be generalized for multiple crop rows.15
3.1 The algorithm for solving the problem of detecting two crop16
rows17
On the basis of the given data point set A the following algorithm gives an approximation18
of two globally optimal crop rows. The algorithm includes searching for a TLS line (three19
times) and the k-means algorithm (Algorithm 1).20
9
Algorithm 2 (approximate globally optimal 2-partition)1. Let A = {Ti = (xi, yi) : i = 1, . . . , m};2. Determine the best TLS line p0;3. By using line p0 divide the set A into two disjoint subsets such that A = A1∪A2;4. for j = 1, 2 do5. For the data point set Aj determine the best TLS line pj;6. end for7. Apply the k-means algorithm (Algorithm 1) with initial center-lines p1, p2
1
3.2 The algorithm for solving the problem of detecting three2
crop rows3
On the basis of the given data point set A the following algorithm gives an approximation4
of three globally optimal crop rows. The algorithm includes searching for a TLS line,5
solving a GOP by using the DIRECT algorithm and the k-means algorithm (Algorithm 1).6
Algorithm 3 (approximate globally optimal 3-partition)1. Let A = {Ti = (xi, yi) : i = 1, . . . , m};2. For the data point set A determine the best TLS line p0;3. By using line p0 divide the set A into two disjoint subsets such that A = A1∪A2;4. for j = 1, 2 do5. By using the DIRECT method solve the following GOP
(ζ1, ζ2, ζ3) = argminα,β,γ∈R
∑T ∈Aj
min{d(p0, T ), d(p(α, β, γ), T )};
6. and set pj := p(ζ1, ζ2, ζ3)7. end for8. Apply the k-means algorithm (Algorithm 1) with initial center-lines p0, p1, p2
7
4 Numerical experiments8
The proposed algorithms for crop row detection will be compared to each other and also9
to the HTA algorithm.10
Let P = {p1, . . . , pk} be the set of original lines and let P ⋆ = {p⋆1, . . . , p⋆
k} be the set11
of reconstructed lines. The quality of reconstruction will be measured by using Hausdorff12
distance between the sets P and P ⋆13
dH := dH(P, P ⋆) = max{maxr
mins
dl(pr, p⋆s), max
smin
rdl(pr, p⋆
s)}, r, s ∈ {1, . . . , k}. (12)14
Thereby, the distance dl between two lines15
p1 : a1x + b1y − c1 = 0, p2 : a2x + b2y − c2 = 0,16
10
can be defined in the following ways.1
(i) Angle distance dA(p1, p2) is according to [5] defined by2
dA(p1, p2) =
1 − |n1 · n2|, if |n1 · n2| < 1,|c1−(n1·n2)c2|
1+|c1−(n1·n2)c2| , if |n1 · n2| = 1,n1 = a1i + b1j,
n2 = a2i + b2j.(13)3
(ii) Integral distance dI(p1, p2) represents the area between the lines p1, p2 in the data4
area [xmin, xmax] × [ymin, ymax]5
dI(p1, p2) =ymax∫
ymin
|x2(y) − x1(y)|dy, (14)6
where x1(y) = 1a1
(c1 − b1y), x2(y) = 1a2
(c2 − b2y). It can be shown that there holds7
dI(p1, p2) = (ymax −ymin)∣∣∣α − β2
2 (ymax + ymin)∣∣∣ , α = c1
a1− c2
a2, β = b1
a1− b2
a2. (15)8
Example 3. For pairs of lines in Fig. 3, both their angle (dA) and integral (dI) distances9
are shown in Table 1.10
0.0 0.5 1.0 1.5 2.00
1
2
3
4
5
(a)
p1p2 p30.0 0.5 1.0 1.5 2.0
0
1
2
3
4
5
(b)
p1p2 p30.0 0.5 1.0 1.5 2.0
0
1
2
3
4
5
(c)
p1p2 p30.0 0.5 1.0 1.5 2.0
0
1
2
3
4
5
(d)
p1p2 p3
Figure 3: Angle and integral distances between lines
As can be seen from the above example, unlike the integral distance, the angle distance11
does not recognize the distance between almost parallel lines well enough. For that reason12
we will use the integral distance (15) in Hausdorff distance (12) for the distance between13
two lines dl(pr, p⋆s).14
The proposed algorithms for crop row detection, Algorithm 2, Algorithm 3 and IMLD15
will be compared with HTA on synthetic data, which are constructed at the beginning of16
11
(Fig. 3a) (Fig. 3b) (Fig. 3c) (Fig. 3d)dA dI dA dI dA dI dA dI
dl(p1, p2) .01116 2.43 .00137 0.33 .0002 0.82 .00013 0.76dl(p1, p3) .00001 2.57 .00199 1.71 .0009 3.02 .00009 2.67dl(p2, p3) .01035 0.91 .00006 1.81 .0002 2.20 0 1.91
Table 1: Comparison of angle and integral distances between lines
Section 3. Let us first choose the vanishing point B ∈ [0, 1] × [2, 10] and k lines which1
pass through the vanishing point B and intersect the interval [0, 1] in k equidistantly2
distributed points 0 < ν1 < ν2 < · · · < νk < 1, where νj+1 − νj = δ < 1k−1 . For example,3
the point ν1 can be chosen in subinterval [0, 1 − (k − 1)δ], and other points are then4
νj = ν1 + (j − 1)δ, j = 2, . . . , k. After that, similarly to Subsection 2.1, using the line5
pj : ajx + bjy − cj = 0, a2j + b2
j = 1 passing through the point {B, νj} the set6
Aj = {(ξ(j)i , η
(j)i )+ ϵ
(j)i (aj, bj) : ξ
(j)i = 1
aj(cj − bjη
(j)i ), ϵ
(j)i ∼ N (0, σ2), i = 1, . . . , mj}, (16)7
will be determined, where η1, . . . , ηmj∈ [0, 2] are equidistantly spaced numbers. Data8
point set A is then9
A =k∪
j=1(Aj ∩ [0, 1] × [0, 2]) , |A| = m,10
and their elements will be denoted by Ti = (xi, yi), i = 1, . . . , m.11
The comparison will be carried out for “complete sowing” and for “incomplete sowing”12
in case of relatively small variance σ2 = 0.002 and also in case of 10-times greater variance13
σ2 = 0.02. By “complete sowing” we mean sowing where all the plants have sprung up,14
and by “incomplete sowing” we mean sowing where some of the plants have not sprung up.15
In our numerical experiments, complete sowing has been simulated in the way that sets16
Aj given by (16) contain 20 points, and incomplete sowing means that 5 − 25% randomly17
chosen points have been dropped from these sets.18
In each numerical experiment the Hausdorff distance (12) between the set of original19
lines and the set of detected lines obtained by applying HTA, IMLD, and Algorithm 220
(i.e. Algorithm 3) will be determined. Thereby, the distance between the lines pr and p⋆s21
in (12) as an integral distance (14) will be determined.22
The efficiency of considered algorithms will be measured by the used CPU-time.23
4.1 Comparison for k = 2 crop rows24
The experiment of choosing and reconstructing two crop rows, as described previously,25
will be carried out 100 times with m1 = m2 = 20, whereby the vanishing point B has26
been randomly chosen in [0, 1] × [2, 10].27
12
Complete sowing Incomplete sowingAlgorithm HTA IMLD Algorithm 2 HTA IMLD Algorithm 2
dH < 0.005 60 75 100 54 81 1000.005 ≤ dH < 0.01 39 - - 46 - -0.01 ≤ dH < 0.02 1 - - - - -0.02 ≤ dH < 0.20 - 25 - - 19 -
CPU-time (sec) 1.25 .23 .04 1.25 .23 .04
Table 2: Testing the methods for solving the problem of detecting two crops with σ2 =0.002
Table 2 shows the results of testing the observed methods for solving the problem of1
detecting two crop rows on data generated in the aforementioned way in case of relatively2
small variance σ2 = 0.002. It can be seen that Algorithm 2 always recognizes crop rows3
with a very high accuracy. IMLD attains the same recognition accuracy in about 80%4
cases, while in the rest 20% of cases the recognition accuracy is worse. The HTA attains5
the same high recognition accuracy in somewhat more than 50% cases, while in the rest6
of the cases the recognition accuracy is worse.7
Furthermore, as can be seen from Table 2, the average used CPU-time for Algorithm 28
per experiment is 0.04 sec and it is 5 times shorter than the used CPU-time for the IMLD9
and 30 times shorter than the used CPU-time for HTA.10
It is interesting to notice that in case of two crop rows detection there are no significant11
differences in the application in all of the observed methods with complete and incomplete12
sowing.13
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
0.2 0.4 0.6 0.8 1.00.0
0.5
1.0
1.5
2.0
(a) Data points
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
0.2 0.4 0.6 0.8 1.00.0
0.5
1.0
1.5
2.0
(b) HTA(dH = 0.26)
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
0.2 0.4 0.6 0.8 1.00.0
0.5
1.0
1.5
2.0
(c) IMLD(dH = 0.01)
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
0.2 0.4 0.6 0.8 1.00.0
0.5
1.0
1.5
2.0
(d) Algorithm 2(dH = 0.01)
Figure 4: An example of a numerical test of methods for solving the problem of detecting twocrop rows for data with variance σ2 = 0.02 that simulate complete sowing
Also, on the basis of data generated in the previously described way, in case of 10-times14
13
Complete sowing Incomplete sowingAlgorithm HTA IMLD Algorithm 2 HTA IMLD Algorithm 2
dH < 0.05 31 84 99 30 69 980.05 < dH ≤ 0.1 12 3 1 14 4 20.1 < dH ≤ 0.2 9 12 - 17 27 -0.2 < dH ≤ 0.5 48 1 - 39 - -
CPU-time (sec) 1.25 .24 .04 1.24 .23 .04
Table 3: Testing of the methods for solving the problem of detecting two crop rows withσ2 = 0.02
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
0.2 0.4 0.6 0.8 1.00.0
0.5
1.0
1.5
2.0
(a) Data points
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
0.2 0.4 0.6 0.8 1.00.0
0.5
1.0
1.5
2.0
(b) HTA(dH = 0.29)
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
0.2 0.4 0.6 0.8 1.00.0
0.5
1.0
1.5
2.0
(c) IMLD(dH = 0.11)
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
0.2 0.4 0.6 0.8 1.00.0
0.5
1.0
1.5
2.0
(d) Algorithm 2(dH = 0.01)
Figure 5: An example of a numerical test of methods for solving the problem of detecting twocrop rows for data with variance σ2 = 0.02 that simulate incomplete sowing
greater variance σ2 = 0.02, Algorithm 2 has attained good performance: a high accuracy1
(see Table 3 and Fig. 4d and Fig. 5d) and a very short used CPU-time (see Table 3).2
IMLD attains the same recognition accuracy in 70% to 85% cases (as in Fig. 4c),3
while in other cases the recognition accuracy is worse (see Table 3). One such experiment4
with complete sowing and good recognition is shown in Fig. 4c, and one experiment with5
incomplete sowing and bad recognition is shown in Fig. 5c.6
HTA attains the same high recognition accuracy only in 30% cases, while in other7
cases the recognition accuracy is worse (see Table 3). One such experiment with complete8
sowing and bad recognition is shown in Fig. 4b, and one experiment with incomplete9
sowing and bad recognition is shown in Fig. 5b.10
Furthermore, as can be seen from Table 3, in case of relatively high variance σ2 = 0.02,11
the used CPU-time for all methods has not changed.12
14
4.2 Comparison for k = 3 crop rows1
The experiment of choosing and reconstructing three crop rows in the previously described2
way will be carried out 100 times with m1 = m2 = m3 = 20, whereby the vanishing point3
B is randomly chosen in [0, 1] × [2, 10].4
Table 4 shows the results of testing the observed methods for solving the problem of5
detecting three crop rows on the basis of data generated in the previously mentioned way6
in case of relatively small variance σ2 = 0.002. It can be seen that Algorithm 3 as well7
as HTA always recognizes crop rows with a very high accuracy. IMLD attains the same8
recognition accuracy in 80% cases by complete sowing and in 60% cases by incomplete9
sowing, while in other cases the recognition accuracy is worse.10
Complete sowing Incomplete sowingAlgorithm HTA IMLD Algorithm 3 HTA IMLD Algorithm 3
dH < 0.05 100 79 100 100 63 1000.05 < dH ≤ 0.1 - 6 - - 5 -0.1 < dH ≤ 0.15 - 13 - - 16 -0.15 < dH ≤ 0.20 - 2 - - 16 -
CPU-time (sec) 1.25 .45 .37 1.25 .44 .36
Table 4: Testing the methods for solving the problem of detecting three crop rows withσ2 = 0.002
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
0.2 0.4 0.6 0.8 1.0
0.5
1.0
1.5
2.0
(a) Data points
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
0.2 0.4 0.6 0.8 1.0
0.5
1.0
1.5
2.0
(b) HTA(dH = 0.23)
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
0.2 0.4 0.6 0.8 1.0
0.5
1.0
1.5
2.0
(c) IMLD(dH = 0.02)
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
0.2 0.4 0.6 0.8 1.0
0.5
1.0
1.5
2.0
(d) Algorithm 3(dH = 0.02)
Figure 6: An example of a numerical test of methods for solving the three crop row detectionproblem for data with variance σ2 = 0.02 that simulate complete sowing
Furthermore, as can be seen from Table 4, the CPU-time for IMLD and Algorithm 311
is very acceptable, while the used CPU-time for HTA is 3 − 4 times longer.12
15
Again, in the case of recognizing three crop rows there are no significant differences in1
the application of all observed methods with complete and incomplete sowing.2
Complete sowing Incomplete sowingAlgorithm HTA IMLD Algorithm 3 HTA IMLD Algorithm 3
dH < 0.05 18 74 100 8 67 980.05 < dH ≤ 0.1 5 2 - 5 3 20.1 < dH ≤ 0.15 2 10 - 6 11 -0.15 < dH ≤ 0.20 6 14 - 4 19 -
CPU-time (sec) 1.25 .46 .36 1.25 .45 .36
Table 5: Testing the methods for solving the problem of detecting three crop rows withσ2 = 0.02
Also, on the basis of data generated in the previously mentioned way, in case of 10-3
times greater variance σ2 = 0.02, Algorithm 3 has attained good performances: the high4
recognition accuracy (see Table 5 and Fig. 6d and Fig. 7d) and very short used CPU-time5
(see Table 5).6
IMLD attains the same recognition accuracy in about 70% cases (as in Fig. 6c), while7
in other cases the recognition accuracy is worse (see Table 5). One such experiment8
with complete sowing and good recognition is shown in Fig. 6c, and one experiment with9
incomplete sowing and bad recognition is shown in Fig. 7c.10
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
0.2 0.4 0.6 0.8 1.0
0.5
1.0
1.5
2.0
(a) Data points
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
0.2 0.4 0.6 0.8 1.0
0.5
1.0
1.5
2.0
(b) HTA(dH = 0.30)
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
0.2 0.4 0.6 0.8 1.0
0.5
1.0
1.5
2.0
(c) IMLD(dH = 0.14)
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
ø
0.2 0.4 0.6 0.8 1.0
0.5
1.0
1.5
2.0
(d) Algorithm 3(dH = 0.01)
Figure 7: An example of a numerical test of methods for solving the problem of detecting threecrop rows for data with variance σ2 = 0.02 that simulate incomplete sowing
HTA attains the same recognition accuracy only in a small number of cases, while in11
most experiments the recognition accuracy is worse (see Table 5). Also, a large number12
of bad cases has not even been registered in Table 5. One such experiment with complete13
16
sowing and bad recognition is shown in Fig. 6b, and one experiment with incomplete1
sowing and bad recognition is shown in Fig. 7b.2
Furthermore, in case of relatively high variance σ2 = 0.02, the used CPU-time for all3
methods has not changed, as can be seen from Table 5.4
5 Conclusion5
The proposed method for crop row detection described in Algorithm 2 and Algorithm 36
recognizes crop rows with a very high accuracy. Thereby the used CPU-time is very7
acceptable from the application point of view. For this reason we suppose that the pro-8
posed method would be very acceptable in a direct application. However, in that case9
the used CPU-time could be even shorter such that Algorithm 2, i.e. Algorithm 3, is10
performed only at the beginning of the working process. After that, it is sufficient to11
perform corrections by k-means Algorithm 1 successively.12
The method proposed in this paper could easily be generalized in case of a greater13
number of crop rows.14
Also, this method could be extended for the case when the number of lines is not15
known in advance. In that case, some of the known indexes should be adjusted (see e.g.16
[40]).17
Acknowledgements18
This work is supported by the Ministry of Science, Education and Sports, Republic of19
Croatia, through research grants 235-2352818-1034 and 165-0361621-2000.20
References21
[1] A. M. Bagirov, Modified global k-means algorithm for minimum sum-of-squares22
clustering problems, Pattern Recognition, 41(2008) 3192–3199.23
[2] A. M. Bagirov, J. Ugon, An algorithm for minimizing clustering functions,24
Optimization, 54(2005) 351–368.25
[3] T. Bakker, H. Wouters, K. van Asselt, J. Bontsema, L. Tang,26
J. Müller, G. van Straten, A vision based row detection system for sugar27
beet, Computers and Electronics in Agriculture, 60(2008) 87–95.28
[4] N. Chernov, Circular and linear regression: Fitting circles and lines by least29
squares, volume 117 of Monographs on Statistics and Applied Probability, Chapman30
& Hall/CRC, 2010.31
[5] R. Cupec, R. Grbić, K. Sabo, R. Scitovski, Three points method for searching32
the best least absolute deviations plane, Applied Mathematics and Computation,33
215(2009) 983–994.34
17
[6] R. O. Duda, P. E. Hart, Use of the Hough Transformation to detect lines and1
curves in pictures, Communications of the ACM, 15(1972) 11–15.2
[7] Y. G. Evtushenko, Numerical Optimization Techniques (Translations Series in3
Mathematics and Engineering), Springer-Verlag, Berlin, 1985.4
[8] D. E. Finkel, DIRECT Optimization Algorithm User Guide, Center for5
Research in Scientific Computation. North Carolina State University, 2003,6
http://www4.ncsu.edu/definkel/research/index.html.7
[9] C. A. Floudas, C. E. Gounaris, A review of recent advances in global optimiza-8
tion, Journal of Global Optimization, 45(2009) 3 – 38.9
[10] J. M. Gablonsky, Direct version 2.0, Technical report, Center for Research in10
Scientific Computation. North Carolina State University, 2001.11
[11] R. Grbić, E. K. Nyarko, R. Scitovski, A modification of the DIRECT method12
for Lipschitz global optimization for a symmetric function, Journal of Global Opti-13
mization, (2012), Published online: 23 December 2012.14
[12] R. Grbić, K. Scitovski, K. Sabo, R. Scitovski, Approximating surfaces by15
the moving least absolute deviations method, Applied Mathematics and Computation,16
219(2013) 4387–4399.17
[13] J. Guerrero, M. Guijarro, M. Montalvo, J. Romeo, L. Emmi, A. Ribeiro,18
G. Pajares, Automatic expert system based on images for accuracy crop row detec-19
tion in maize fields, Expert Systems with Applications, 40(2013) 656–664.20
[14] T. Hague, N. Tillett, A bandpass filter-based approach to crop row location and21
tracking, Mechatronics, 11(2001) 1–12.22
[15] R. Ji, L. Qi, Crop-row detection algorithm based on Random Hough Transformation,23
Mathematical and Computer Modelling, 54(2011) 1016–1020.24
[16] D. R. Jones, C. D. Perttunen, B. E. Stuckman, Lipschitzian optimization25
without the Lipschitz constant, Journal of Optimization Theory and Applications,26
79(1993) 157 – 181.27
[17] J. Kogan, Introduction to Clustering Large and High-dimensional Data, Cambridge28
University Press, 2007.29
[18] V. Leemans, M.-F. Destain, Line cluster detection using a variant of the Hough30
transform for culture row localisation, Image and Vision Computing, 24(2006)31
541–550.32
[19] F. Leisch, A toolbox for k-centroids cluster analysis, Computational Statistics &33
Data Analysis, 51(2006) 526 – 544.34
[20] S.-H. Liao, P.-H. Chu, P.-Y. Hsiao, Data mining techniques and applications35
– a decade review from 2000 to 2011, Expert Systems with Applications, 39(2012)36
11303–11311.37
18
[21] A. Likas, N. Vlassis, J. J. Verbeek, The global k-means clustering algorithm,1
Pattern Recognition, 36(2003) 451 – 461.2
[22] J. Marchant, Tracking of row structure in three crops using image analysis, Com-3
puters and Electronics in Agriculture, 15(1996) 161–179.4
[23] M. Montalvo, G. Pajares, J. Guerrero, J. Romeo, M. Guijarro,5
A. Ribeiro, J. Ruz, J. Cruz, Automatic detection of crop rows in maize fields6
with high weeds pressure, Expert Systems with Applications, 39(2012) 11889–11897.7
[24] M. M. Mostafa, More than words: Social networks’ text mining for consumer8
brand sentiments, Expert Systems with Applications, 40(2013) 4241–4251.9
[25] A. Neumaier, Complete search in continuous global optimization and constraint10
satisfaction, Acta Numerica, 13(2004) 271 – 369.11
[26] Y. Nievergelt, Total least squares: state-of-the-art regression in numerical anal-12
ysis, SIAM Review, 36(1994) 258–264.13
[27] H. J. Olsen, Determination of row position in small-grain crops by analysis of14
video images, Computers and Electronics in Agriculture, 12(1995) 147–162.15
[28] J. D. Pintér, Global Optimization in Action (Continuous and Lipschitz Optimiza-16
tion: Algorithms, Implementations and Applications), Kluwer Academic Publishers,17
Dordrecht, 1996.18
[29] F. Pla, J. Sanchiz, J. Marchant, R. Brivot, Building perspective models to19
guide a row crop navigation vehicle, Image and Vision Computing, 15(1997) 465–473.20
[30] J. Reyes, A. Morales-Esteban, F. Martínez-Álvarez, Neural networks to21
predict earthquakes in chile, Applied Soft Computing, 13(2013) 1314–1328.22
[31] F. Rovira-Mas, Q. Zhang, J. Reid, J. D. Will, Hough-transform-based vision23
algorithm for crop row detection of an automated agriculture vehicle, Journal of24
Automobile Engineering, 219(2005) 999–1010.25
[32] K. Sabo, R. Scitovski, I. Vazler, One-dimensional center-based l1-clustering26
method, Optimization Letters, 7(2013) 5 – 22.27
[33] K. Sabo, R. Scitovski, I. Vazler, M. Zekić-Sušac, Mathematical models of28
natural gas consumption, Energy Conversion and Management, 52(2011) 1721 –29
1727.30
[34] R. Scitovski, S. Scitovski, A fast partitioning algorithm and its application to31
earthquake investigation, Computers and Geosciences, 59(2013) 124 – 131.32
[35] R. Scitovski, Šime Ungar, D. Jukić, Approximating surfaces by moving total33
least squares method, Applied Mathematics and Computation, 93(1998) 219–232.34
[36] H. Søgaard, H. Olsen, Determination of crop rows by image analysis without35
segmentation, Computers and Electronics in Agriculture, 38(2003) 141–158.36
[37] H. Späth, Cluster-Formation und Analyse, R. Oldenburg Verlag, München, 1983.37
19
[38] M. Teboulle, A unified continuous optimization framework for center-based clus-1
tering methods, Journal of Machine Learning Research, 8(2007) 65 – 102.2
[39] N. D. Tillett, T. Hague, Computer-vision-based hoe guidance for cereals - an3
initial trial, J. Agric. Engng Res., 74(1999) 225–236.4
[40] L. Vendramin, R. J. G. B. Campello, E. R. Hruschka, On the comparison5
of relative clustering validity criteria, In: Proceedings of the SIAM International6
Conference on Data Mining, SDM 2009, April 30 - May 2, 2009, Sparks, Nevada,7
USA. SIAM, 2009, 733–744.8
[41] P.-Y. Yin, Algorithms for straight line fitting using k-means, Pattern Recognition9
Letters, 19(1998) 31–41.10