## 2 Materials and Methods
### Convolutional Neural Network:  
Though the above method works well in detecting separated beads, it encounters challenges when aggregates or clusters of beads are present in the fluid medium. To identify the individual beads in these clusters, i.e., perform segmentation, we use a convolutional neural net (CNN). CNNs have been shown to perform well in various image classification tasks [42]. Image segmentation can be performed by a fully CNN based encoder decoder system [43]. CNNs have also been successfully used in classifying complex datasets such as hand-written numbers [44].  
To solve the problem of segmenting the clusters, we use pixel classification. Since we cannot be sure of the number of beads in any cluster, it is not feasible to predict the coordinates of the beads. The pixel classification approach helps us tackle this issue. Each pixel in an image is either classified as a bead center or not a bead center. The image is first padded by black spaces and then split into smaller images of size \(31\times 31\). Each of these sub images is centered on the pixel from the padded image. These sub images are then used as inputs to the CNN shown in Figure 6. The CNN architecture is modeled after the architecture presented in [44]. Both of the convolution layers are equipped with a commonly-used rectified linear unit (ReLU) activation function. This activation function helps to model nonlinearity in the output of each neuron w.r.t. the input \(x\) as shown in the equation below:  
\[f(x)=max(0,x). \tag{5}\]  
The first convolution layer has seven \(7\times 7\) filters. Filters are an array of weights, whose distribution enables the CNN to model any feature. The first layer also has a stride of 2, which means that the filters are applied by centering them on every other pixel in the input images. The second convolution layer has three filters of size \(3\times 3\) with stride equal to 1, meaning that the filters are applied on every pixel. The convolution layers are both followed by a max pooling layer of size \(2\times 2\). The max pooling layers help prevent over fitting in the CNN by downsampling, which is achieved by selecting the maximum value locally in a \(2\times 2\) grid from the output of the previous layer.  
The final two layers in the CNN architecture are dense or fully connected layers, where all the inputs are connected to all the outputs. The first dense layer is of size 64 with the ReLU activation function. Since we are trying to classify if a pixel is a bead center or not, the final output of the network needs to be its confidence on these two mutually exclusive events. Hence, the final layer of the CNN is a dense layer of size 2 with a Softmax activation function shown in Equation (6). This activation function provides a probability distribution over the outputs in a layer. The actual sizes of the all the layers except the last one are found by trying different sizes and comparing their respective performances. After the CNN predicts the pixel states, those identified as bead centers are averaged with similarly classified neighboring pixels in a \(3\times 3\) grid:  
\[\sigma(x)=\frac{\exp(x_{i})}{\sum\limits_{i=1}^{n}\exp(x_{j}).} \tag{6}\]