## 3 Materials and Methods
### BeePIV
#### 3.3.5 Difference Maxima Erosion  
Let \(P\) be the sequence of \((r,c)\) positions of all maxima points in the frame \(M_{n}(S_{t,\Delta}^{\Theta^{V}})\). For example, in Figure 9, \(P=((1,1),(1,3),(3,2),(4,4))\). We define an erosion operator \(E_{d^{V}}(S_{b_{t,\Delta}}^{V})\) that, given a distance \(d^{V}\), constructs the set \(P\), sorts the positions \((r,c)\) in \(P\) by their \(i\) coordinates, and, for every position \((r,c)\) such that \(S_{b_{t,\Delta}}^{V}(r,c)=1\), sets the pixel values of all the positions that are within \(d^{V}\) pixels of \((r,c)\) in \(S_{b_{t,\Delta}}^{V}\) to \(0\) (i.e., erodes them). We let \(R_{b_{t,\Delta}}^{V}\) refer to the smoothed and eroded binary difference frame obtained from \(S_{b_{t,\Delta}}\) after erosion and define the erosion operator \(E\) in Equation (21). \[E_{d^{V}}\Big{(}S_{b_{t,\Delta}}^{V}\Big{)}=R_{b_{t,\Delta}}^{V} \tag{21}\]  
The application of the erosion operator is best described algorithmically. Consider the \(4\times 4\) binary difference frame in Figure 10a. Recall that this frame is the frame in Figure 9b obtained by applying the maxima operator \(M_{4}\) to the frame in Figure 9a. After \(M_{4}\) is applied, the sequence of the local maxima positions is \(P=((1,1),(1,3),(3,2),(4,4))\). Let us set the distance parameter \(d^{V}\) of the erosion operator to 4 and compute \(E_{4}(S_{b_{t,\Delta}})\). As the erosion operator scans \(S_{b_{t,\Delta}}\) left to right, the positions of the eroded maxima are saved in a dynamic lookup array (let us call it \(I\)) so that the previously eroded positions are never processed more than once. The array \(I\) holds the index positions of the sorted pixel values at the positions in \(P\). Initially, in our example, \(I=[4,1,3,2]\), because the pixel values at the positions in \(P\), sorted from lowest to highest, are \([125.50,134.00,136.00,143.00]\) so that the value \(125.50\) is at position \(4\) in \(P\), the value \(134.00\) at position \(1\), the value \(136.00\) at position \(3\), and the value \(143\) at position \(2\). In other words, the pixel value at \((4,4)\) is the lowest and the pixel value at \((1,3)\) the highest. For each value in \(I\) which has not yet been processed, the erosion operator computes the euclidean distance between its coordinates and the coordinates of each point to the right of it in \(I\) that has not yet been processed. For example, in the beginning, when the index position is at \(1\), the operator computes the distances between the coordinates of position \(1\) and the coordinates of positions \(2\), \(3\), and \(4\). \[\left[ \begin{array}{cccc}\mathbf{134.00}&71.75&\mathbf{143.00}&64.34\\ 93.64&102.96&107.66&100.70\\ 99.10&\mathbf{136.00}&126.89&124.69\\ 83.48&103.32&120.09&\mathbf{125.50}\end{array} \right]\qquad\qquad\left[ \begin{array}{cccc}\mathbf{1}&0&\mathbf{1}&0\\ 0&0&0&0\\ 0&\mathbf{1}&0&0\\ 0&0&0&\mathbf{1}\end{array} \right]\]  
\(\mathbf{(a)}\). \(S_{t,\Delta}^{\Theta^{V}}\)  
\(\mathbf{(b)}\). \(S_{b_{t,\Delta}}^{V}\)  
\(\mathbf{(a)}\). \(S_{b_{t,\Delta}}^{V}\)  
\(\mathbf{(b)}\). \(S_{b_{t,\Delta}}^{V}\)  
\(\mathbf{(a)}\). \(S_{b_{t,\Delta}}\)  
\(\mathbf{(b)}\). \(R_{b_{t,\Delta}}\)  
If the current point in \(I\) is at \((r_{1},c_{1})\), a point to the left of it in \(I\) is at \((r_{2},c_{2})\), then \(d^{\prime}=\sqrt{\left(r_{1}-r_{2}\right)^{2}+\left(c_{1}-c_{2}\right)^{2}}\) is the distance between them. If \(d^{\prime}<d^{\prime}\), the point at \((r_{2},c_{2})\) is eroded and is marked as such. The erosion operator continues to loop through \(I\), skipping the indices of the points that have been eroded. In this example, the positions \(2\) and \(3\) in \(P\) are eroded. Thus, the frame \(R_{b_{t,\Delta}}\) shown in Figure 9(b), has \(1\)'s at positions \((1,1)\) and \((4,4)\) and \(0\)'s everywhere else. Since the erosion operator is greedy, it does not necessarily ensure the largest pixel values are always selected, because their corresponding positions may be within the distance \(d^{\prime}\) of a given point whose value may be lower.