## 3 Application of the Developed Classical Computer Vision Method to the Bubble Dynamics Problem
### StarDist Method Application for Mask Extraction of the Bubbles  
Application of deep learning networks, e.g., StarDist, normally requires the user to train a model using their peculiar data. Simultaneously in order to train the StarDist model an end-to-end open source platform for machine learning _TensorFlow 2_ was used, allowing researchers to train (and retrain) and validate deep learning networks. Therefore, our approach realization can be divided into four steps:  
1. Ground-truth annotations in order to train the StarDist model. This part requires careful manual annotations of the images for subsequent analysis.
2. StarDist model training and validating.
3. Trained StarDist model application to segment the objects for further analysis.
4. Image augmentation to improve the StarDist model performance.  
Training the StarDist model requires naturally a set of images and their corresponding masks. We started to train StarDist from a small set of training data in order to test and adjust the results and then iterate. The training dataset consisted of 25 images with resolution 1280 \(\times\) 800 pixels taken from 10 different video files. The annotation was carried out in the QuPath program [46]. The training data consists of the corresponding input image as shown in Figure 28a (i.e., original images) and fully annotated label images (Figure 28b) (i.e., each pixel is labeled with a unique object ID--or assigned 0 when background). Each image was sliced into four equal parts of 640 \(\times\) 640 pixels and further augmentation was performed. Augmentation consists of four stages, namely:  
1. Reflection of the image (vertical or horizontal, 50% probability).
2. Rotation of the image 90 degrees (50% probability).
3. Change the pixel intensity: the intensity of each pixel is multiplied by a number from the interval (0.6...1.4) and added to the number from the interval (-7...7) (uniform distribution).
4. Gaussian noise overlay (mean = 0, standard deviation = 2).  
Thus, we got 500 images for training the neural network. The StarDist model was trained on _GTX Titan X_ with our own data set (Table 1).  
The model average precision on the training samples, meaning the area under the precision-recall curve, was achieved at \(AP_{50}=0.731\) based on the IoU = 0.5 threshold and \(AP_{75}=0.544\) based on the IoU = 0.75 threshold. The average precision on the test dataset was also calculated. The test dataset consists of four images that were not used to train the StarDist model network. As a result of a similar slicing and augmentation procedure, 80 test data were obtained. The model average precision on the training dataset was achieved at \(AP_{50}=0.544\) based on the IoU = 0.5 threshold and \(AP_{75}=0.294\) based on the IoU = 0.75 threshold. The processing time of one frame by the trained model is 0.28 seconds: a worthy result that can also be improved by means of parallel processing.  
Application of the trained model to the sample frame is shown in Figure 29b: the algorithm is able to separate the overlapping bubbles. Unlike MaskR-CNN, StarDist does not use axis alignment bounding boxes as a shape representation. Instead, this model predicts a star polygon for each pixel, which allows bubbles to be demarcated. Therefore, we are spared the problem of separating the overlapping bubbles, for which purpose special  
Figure 27: Star-convex polygons (**left** to **right**) parameterized by the radial distances \(r^{k}_{i,j}\) and predicted object probabilities \(d_{i,j}\), using U-Net architecture for density predictions.  
clustering algorithms are implemented in Section 3.3 and we proceed then to the analysis of the resulting bubble masks.