Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

Estimating rice yield with the shoelace algorithm

April 28, 2022

1    Motivation

Aerial imaging using drones promises to enable farmers to monitor their crops precisely and effi- ciently.  But farmers need more than pictures; they need measurements of meaningful quantities such as crop yield so they can manage their farm practices and plan when to harvest.

This case study looks at one step in a computational process of turning aerial images into actionable information: the shoelace algorithm for calculating the area of a polygon from its boundary points. This step was used in part of a larger process for estimating the yield of a rice crop from low-altitude colour images as described by Reza et al. (2019).

Put simply, the motivation for the shoelace algorithm is to find the area of a polygon from the coordinates of its vertices.

2    Materials

In this scenario, the raw materials” used in estimating rice yield are colour (RGB: red, green, blue) images captured using a Sony digital camera mounted to a DJI-1000 rotary wing drone. The authors compared two different methods of estimating rice yield (1) an automated K-means clustering with a graph-cut (KCG) algorithm and (2) a manual estimate which they treat as the ground truth. In other words, this is a situation where engineers are trying to see if their automated approach will perform comparably well to a human expert; we could think of the expert’s estimates as another kind of raw material” in this comparison process.

Its important to point out that

1.  The human expert’s ground truth” is not actually the mass or volume of rice in the image; instead, it is the area in pixels of rice grains visible in the image

2.  The authors don’t try to assess how good human experts are at this task. I think if the same expert was asked to estimate the rice yield from the same image multiple time that their estimates would be a little different. This issue was not considered.

3    Method

The authors first use a  10-step process of image filtering,  pre-processing and segmentation to produce a segmented rice grain image, i.e., an image in which nothing but the visible rice grains appears. Then comes the shoelace algorithm (also known as Gausss area formula or the surveyors formula (Braden, 1986)) (see Figure 1). This is the method that converts the points (i.e., vertices) of the polygonal boundary of each segmented cluster of grains into a pixel area according to the following formula:

where A is the area of the polygon, n is the number of sides of the polygon, and (xi, yi) where i = 1, 2, . . . , n are the vertices of the polygon.

As far as I can tell, the authors implemented this algorithm in Matlab; Rosetta Code (n.d.) provides implementations in many languages, including a Python one-liner;  101 Computing gives a more detailed account of the algorithm in Python, including mention of integer overflow.

 

Figure  1:  This diagram from Reza et al. (2019) illustrates the process of taking an image (far left), segmenting the regions corresponding to rice grains, then producing the polygons that bound these regions (left).  The shoelace algorithm is then used to convert the coordinates (right) of the polygon’s vertices into the area of the polygon (far right).

 

Figure  2:  The shoelace algorithm gets its name because the terms and signs of the products in Equation (1) can be laid out like the criss-cross pattern of a shoelace, as shown in this diagram from Weisstein (n.d.).

4    References

•  Reza, Md Nasim, In Seop Na, Sun Wook Baek, and Kyeong-Hwan Lee.  2019.  Rice Yield Estimation Based on K-Means Clustering with Graph-Cut Segmentation Using Low-Altitude UAV Images.  Biosystems Engineering, Intelligent Systems for Environmental Applications, 177 (January): 109–21.

•  Braden, Bart. 1986. The Surveyors Area Formula. The College Mathematics Journal 17 (4): 326–37.

  Weisstein, Eric W. Polygon Area.” From MathWorldA Wolfram Web Resource.

  Shoelace Formula for Polygonal Area - Rosetta Code. n.d. Accessed 22 February 2022.

 The Shoelace Algorithm. 2019.  101 Computing (blog). 5 March 2019.