## 2 Materials and Methods
### Neural Networks Methodology for Bubble Analysis  
As an alternative to the classical method the deep learning (DL) approach was also considered: in the current subsection we discuss image processing methods for analyzing the phase contact area using neural networks. A few methods are compared for processing the results of video filming with a high-speed camera during experimental runs (Table 1), namely the MaskR-CNN [38] and StarDist [39] models. Instance segmentation of bubbles on the frame is carried out on pre-trained weights using the mentioned machine learning models. Final arguments are given in favor of choosing the StarDist model for the further full processing cycle of bubble images.  
Figure 10: Sample images of fitted ellipses on frames from (**a**) F1, (**b**) F2, (**c**) F3, (**d**) F4 and (**e**) F5 videos according to Table 1. Although there are just sample frames, one can still see some patterns. The F1 video has more bubbles than others and also results in a higher density of bubbles making detection more difficult. The F2 video seems to provide the bubble density less than might be visually determined in F1, while the F3—less than in F2. At once the F4 video has an additional object, namely the fluid interface. It does not occur for all frames, however. Finally the F5 video has a greater ratio of out-of-camera-focus bubbles.  
In the subsection above the difficulties associated with the methodology of bubble segmentation in the volume are discussed and some of them were overcome with a trained Mask R-CNN for the spatiotemporal variation in the interfacial shape between gas-liquid phases. An average accuracy of 98% is shown [40]: Mask R-CNN was trained on both experimental and synthetic bubbly flow images obtained from the upward bubbly flows in an expansion pipe and BubGAN algorithm [41], respectively. We applied the MaskR-CNN model pre-trained on data from [41] in order to get the bubble image mask for our own images (Figure 12).  
This trained Mask R-CNN model showed an average accuracy of \(AP_{50}=0.244\) on our test data. In order to improve the performance of Mask R-CNN for our task, it is necessary to retrain the model on our own data, which requires (due to the peculiarities of the architecture) a large size of the training data set and the availability of sufficient computing power, meaning it is also quite expensive. Therefore other neural network methods should be considered.  
Figure 11: Basic distributions of ellipse parameters: (**a**) horizontal distribution of bubble centers; (**b**) vertical distribution of bubble centers; (**c**) distribution according to the angle of inclination of the semi-major axis; (**d**) minor axis distribution; (**e**) major axis distribution; (**f**) eccentricity; (**g**) error distribution.  
The second open-source method that is known to be applicable to detect bubbles is StarDist [39]. It was originally developed as a cell/nuclei detection method for microscopy images with star-convex shape priors which seemed to be relevant for our task in general. In fact the approach has its own benefits and drawbacks. The result of the StarDist mask extraction with pre-trained weights is shown in Figure 13: it misses about half of the total number of bubbles. Such a poor result on our own data is shown due to the fact that it was trained exactly to detect cell nuclei. At the same time as shown in [42] StarDist has still higher accuracy and requires less training data than MaskR-CNN for bubble detection. In addition, in contrast to Mask R-CNN, StarDist has only a few hyper-parameters that do not need careful tuning to achieve good results [43]; therefore, it was chosen to train the model StarDist for bubble instance segmentation as is discussed further in Section 4.