## 3 Autonomous Mapping and Navigation with Satellite Imagery and Cadastral Information
### Second Stage: Path Planning
#### 3.2.1 Detecting Tree Lines  
The organization of citric groves is well defined as it can be seen in the artificial composition depicted in Figure 2; the trees are organized in rows separated by a relatively wide path to optimize treatment and fruit collection. The first step of the navigation module consists of detecting the tree lines. The _Obstacles binary map_ (_Obstacles_ in Algorithm 5) contains the pixels located inside the parcel that correspond to trees. For this reason, the rows containing trees are extr  
Figure 2: A farmer performing maintenance tasks in a young orange grove: The red lines stand for the rows of citrus trees (or just tree rows), and the green line stands for the path where the farmer is walking. Transform method (see Reference [24]). Moreover, some constraints to this technique have been added to avoid selecting the same tree line several times. In this procedure, the _Hesse standard form_ (Equation (1)) is used to represent lines with two parameters: \(\theta\) (angle) and \(\rho\) (displacement). Each element of the resulting matrix of the Hough Transform contains some votes which depend on the number of pixels which corresponds to the trees that are on the line. \[y\cdot sin(\theta_{path})+x\cdot cos(\theta_{path})-\rho_{path}=0 \tag{1}\]  
According to the structure of the parcels, the main tree rows can be represented with lines. We applied Algorithm 7 to detect the main tree rows (rows of citric trees). First, the most important lines, the ones with the highest number of votes, are extracted. The first extracted line (the line with the highest number of votes) is considered the \"main\" line, and its parameters (\(\theta_{1}\),\(\rho_{1}\) and \(\mathit{votes}_{1}\)) are stored. Then, those lines that have at least \(0.20\cdot\mathit{votes}_{1}\) and of which the angle is \(\rho\pm 1.5\) are also extracted. This first threshold (\(\Gamma_{1}=0.20\)) has been used to filter the small lines that do not represent full orange rows, whereas the second threshold (\(\Gamma_{2}=1.5\)) has been used to select those orange rows parallel to the main line. We have determined the two threshold values according to the characteristics of the analyzed groves: the target groves have parallel orange rows with similar length. ```
Apply Hough to \(\mathit{Threes}\): \(H=Hough(\mathit{Trees})\) Extract line with highest value from \(H\): \(value_{main}=H(\rho_{main}\),\(\phi_{main}\)) Set Treshold value: \(\Gamma_{1}=0.20\cdot\mathit{value}_{main}\) Limit \(H\) to angles close the main angle (\(\phi_{main}\pm 1.5^{\mathrm{o}}\)): \(HL\) lines = true Store main line parameters in \(\mathit{StoredLines}\): \(\rho_{main}\)\(\phi_{main}\)\(value_{main}\) while lines do Extract candidate line with highest value from \(HL\): \(value_{c}=HL(\rho_{c}\phi_{c})\) Remove value in the matrix: \(HL(\rho_{c},\phi_{c})=0\) if(\(value_{c}>\Gamma_{1}\)) then  Calculate that distance to previous extracted lines is lower than threshold: \(\|\rho_{c}-\rho_{i}\|>(12\cdot(1+\|\theta_{c}-\theta_{i}\|))\) if distance between candidate and stored lines is never lower than threshold then  Store line parameters in \(\mathit{StoredLines}\): \(\rho_{c}\)\(\phi_{c}\)\(value_{c}\) endif else  lines = false endif endwhile Sort stored lines: \(\mathit{SortedTreeLines}\) Return:\(\mathit{SortedTreeLines}\)
```  
**Algorithm 7** DetectLines[_Trees_,_Path_]  
Furthermore, to avoid detecting several times the same tree row, each extracted line cannot be close to any previous extracted line. We used Equation (2) to denote the distance between a candidate line (\(c\)) and a previous extracted line (\(i\)) since the angles are similar (\(\pm 1.5^{\mathrm{o}}\)). If this distance is higher than a threshold value (\(\Gamma_{3}\)), the candidate line is extracted. We use Equation (3) to calculate the threshold value according to the difference of angles of the two lines.