## 3 Materials and Methods
### BeePIV
#### 3.3.3 Color Variation  
Since a single flying bee may generate multiple motion points in close proximity as its body parts (e.g., head, thorax, and wings) move through the air, pixels in close proximity (i.e., within a certain distance) whose values are above a certain threshold in smoothed difference frames can be combined into clusters. Such clusters can be reduced to single motion points on a uniform (white or black) background to improve the accuracy of PIV. Our conjecture, based on empirical observations, is that a video's color variation levels and its bee traffic levels are related and that video-specific thresholds and distances for reducing smoothed difference frames to motion points can be obtained from video color variation. Let \(V=(F_{t},\dots,F_{t+k})\) be a video and let \(B^{V}_{t+k,k}\) (see Equation (4)) be the background frame of \(F_{t+k}\) with \(\Delta=k\) (i.e., the number of frames in \(V\)). To put it differently, as Equation (4) implies, \(B^{V}_{t+k,k}\) is the mean frame of the entire video and contains information about regions with little or no variation across all frames in \(V\). A color variation frame, denoted as \(\texttt{VAR}^{V}_{t}\) (see Equation (12)), is computed for each \(F^{V}_{l}\) as the squared smoothed pixelwise difference between \(F^{V}_{l}\) and \(B^{V}_{t+k,k}\) across all image channels. \[\texttt{VAR}^{V}_{l}=\Big{(}H\Big{(}F^{V}_{l}-B^{V}_{t+k,k}\Big{)}\Big{)}^{2} \tag{12}\]  
The color variation values from all individual color variation frames \(\texttt{VAR}^{V}_{l}\) are combined into one maximum color variation frame, denoted as \(\texttt{MYV}^{V}\) (see Equation (13)), for the entire video \(V\). Each position \((r,c)\) in \(\texttt{MYV}^{V}\) holds the maximum value for \((r,c)\) across all color variation frames \(\texttt{VAR}^{V}_{l}\), where \(k=\texttt{argmax}_{k\in(t,\dots,t+k)}\texttt{VAR}^{V}_{k}(r,c)\). In other words, \(\texttt{MYV}^{V}\) contains quantized information for each pixel position on whether there has been any change in that position across all frames in the video. \[\texttt{MXV}^{V}(r,c)=\texttt{VAR}^{V}_{k}(r,c) \tag{13}\]  
Figure 6 gives the background and maximum color variation frames for a low bee traffic video \(V_{1}\) and a high bee traffic video \(V_{2}\). The maximum color variation frames are grayscale images whose pixel values range from 0 (black) to 255 (white). Thus, the white the value of a pixel in a \(\texttt{MYV}^{V}\) is, the greater the color variation at the pixel's position. As can be seen in Figure 6, \(MXV^{V_{1}}\) has fewer whiter pixels compared to \(MXV^{V_{2}}\) and the higher color variation clusters in \(MXV^{V_{1}}\) tend to be larger and more evenly distributed across the frame than the higher color variation clusters in \(MXV^{V_{2}}\). The color variation of a video \(V\), denoted as \(\texttt{CLV}^{V}\), is defined in Equation (14) as the standard deviation of the mean of \(\texttt{MYV}^{V}\). Higher values of \(\texttt{CLV}^{V}\) indicate multiple motions; lower values indicate either relatively few motions or complete lack thereof. We intend to investigate this implication in our future work. \[\texttt{CLV}^{V}=\texttt{STD}(\texttt{MYV}^{V}) \tag{14}\]We postulate in Equation (15) the existence of a function \(\Gamma:\mathbb{R}\rightarrow\mathbb{R}\times\mathbb{R}\) from reals to 2-tuples of reals that maps color variation values for videos (i.e., \(\mathtt{CLV}^{V}\)) to video-specific threshold and distance values that can be used to reduce smoothed difference frames to uniform background frames with motion points. In Section 4.2, we define one such \(\Gamma\) function in Equation (33) and evaluate it in Section 4.3, where we present our experiments on computing the PIV interrogation window size and overlap from color variation. \[\Gamma\left(\mathtt{CLV}^{V}\right)=\left(\Theta^{V},d^{V}\right) \tag{15}\]  
Suppose there is a representative sample of bee traffic videos \(C=\{V_{1},\ldots,V_{n}\}\) obtained from a deployed BeePi monitor.