Cassava Crop Line Detection

Natthasit Wongsirikul
5 min readOct 11, 2021

--

Previous Post on Cassava Crop Counting

This is the last part of the series about precision agriculture using drone imagining to monitor Cassava plantation field.

During my conversation with farm owners, I realized how difficult it is to look after the field. It is essentially 1 person looking after hundreds over acre of land. It is not practical to scan through the field by foot, that’s where drone can help. Crops are often grown in rows; such pattern is a result of mechanized tools to plough and plant crops. So, I thought that an algorithm that will identify crop rows and linking individual crop to a row will be useful. Following up on the results of my previous post on Cassava crop counting, I have all the information needed to tackle this task.

The key algorithm used here is Hough Transform, with the assumption that crops planted in row have an inherent crop line pattern.

Hough Transform

Using the result from crop counting, I plot all the points onto an empty map equal size to the raster and call it skeleton map. This skeleton map will be the input to my crop row identification algorithm.

The first thing I tried was applying the Hough Transform algorithm onto the skeleton map to see the results. Even though the line pattern is clear to human perspective, the algorithm will find lines in random direction based on the direction with the most points that happened to line up.

To circumvent this issue, I decided to apply the Hough transform on tiles instead of the whole map. I will sample 10% of total tiles, and perform Hough transform on them and record the output theta and rho. For each tile, I will find the mode (most frequent value) theta in the list and record it. So, if I sample 20 tiles, I will have 20 most common theta values and 20 most common rho value. What does these “most common theta” and “most common rho” represent? The “most common theta” represents an estimate of the direction of the crop row for the entire field. The “most common rho” represents an estimate of the average inter-row gap distance.

I then find the mean and standard deviation of these thetas & rhos to get a bound for how many degrees of rotation I will allow my Hough transform to search. This range is the mean theta plus and minus a standard deviation.

Now I can perform a narrowed Hough line search using the above theta range I found on all the tiles. Each tile will now have a record of all crop line. Now as I went through to inspect the results for each tile, I found a very interesting problem.

Limitation of Hough Transform on Crop Line Tile

Within a tile, I found there is lower probability of a successful Hough lines detected on the corner of the tile. This is because there are less points on the corner to generate a strong Hough line candidate.

This will create a problem for my algorithm to join lines throughout the field because there will always be discontinuation of lines over the entire field.

To solve this problem, I create secondary tiles that is offset by half to the primary tiles.

The purpose of the secondary tiles are the catch all the Hough lines that could have been missed by the primary tiles. By off-setting the secondary tiles, all the weak region in the primary tiles will be in the strong region of the secondary tile

What I ended up doing was performed a narrow-hough line search twice (one for primary another for the secondary) then combining the result of the secondary tiles and the primary tiles.

Joining Lines Strategy Over Entire Field

Since every line must belong to a tile, I only have to focus where the line intersects at the tile’s edge. This narrow down the number of potentials joining I have to look for. In a nutshell, end points on a target tile at the left edge will be joined with starting points at the left edge of a right neighbor tile

Two points are joined via minimal Eucliean distance. Two points cannot be join if their distance is more than the averaged inter-row gap distance calculated earlier.

Joining the Lines Between Tiles

I used the same technique as my previous post on crop-counting, using a tile-sweeping algorithm to generate a relational graph linking neighbouring tiles.

I then initialize an ID for all the lines in the first set of tiles then as I sweep to the right I can either join new lines or initialize a new ID for un-joined lines.

The algorithm is not perfect there are some crop line that was missed or were mistakenly joined across different crop line but the overall results looks pretty good.

Output of joining crop lines across tiles

The output of this algorithm is a list of individual crop line that contain a made up of composite lines from individual tile that make up the entire raster of the field.

Each tile has its set of lines. Same color line represented same crop row.

With the crop line defined, we can calculate how many standing crops are there in each crop line. This can help farmer identify which crop row has problem.

--

--

Natthasit Wongsirikul

I'm a computer vision engineer. My interest span from UAV imaging to AI CCTV applications