## 3 Application of the Developed Classical Computer Vision Method to the Bubble Dynamics Problem
### Investigation of Bubble Sizes at Intersection  
As a result of bubble boundary line detection and clustering them into separate entities, two bubbles might happen to be combined into one cluster in the case where the distance between them is negligible, which might lead to incorrect results of fitting the bubble shape with an ellipse. In order to get rid of, or prevent, this potentially negative effect the following procedure was tested and verified: when the defined quality criterion for fitting with an ellipse exceeds a threshold value, then such a fit should be considered as a \"bad\" one and thus another attempt to fit it with two ellipses (triple overlays are not considered though the approach might be similar) should be made. In order to make a fit with two ellipses a random selection of some continuous arc in the cluster occurs, which is fitted by the first ellipse: then all the points close to the first ellipse are discarded and the remaining points are fitted with the second ellipse. The process should be repeated a few times (up to ten for more accuracy) in order to avoid the random arch selection affecting the result; then a double fit with the best quality criterion is selected. The quality criterion used to determine the threshold value that distinguishes \"bad\" from \"good\" fits was the average distance from the point to the ellipse divided by the sum of the lengths of the semi-axes of the ellipse (the division eliminates the dependence on the size of the criterion). In order to compare a single fit with a double fit, two metrics were used: the absolute average distance from the points to the ellipse, as well as the absolute average distance from the points equidistantly  
Figure 14: Dynamics of changes in observed bubble quantity and their median area in the frame: (**a**) variability in the number of registered bubbles and (**b**) variation of the median bubble area in the view field (frame indexes are indicated on the x-axis). Both the number and median area might be considered as a Gaussian process as expected for a scale of one second. Figure 15: _Successful_ (**left**) and _unsuccessful_ (**right**) frame samples. In the _successful_ frame there are generally more medium-sized bubbles, while the _unsuccessful_ frame is darker. distributed along the ellipse to the nearest point from the cluster to each of them. If a double fit did show an improvement in both metrics, then two ellipses were considered to describe the cluster better than one (Figure 16). The applicability of the method is limited by the following fact: by sifting out fits by the threshold of the average relative distance of points to the ellipse, it is possible to distinguish \"good\" images from \"bad\" ones, but the class of \"bad\" images itself is divided into two subclasses: overlapping bubbles or jerky pieces of some boundaries, along which it is not possible to set the number of ellipses, and it should be noted that the second case is much more common. Another important fact to mention is that the correctness-of-fit metrics definitions require further analysis. The thing is that by fitting almost any set of points with one ellipse we will get metrics associated in one way or another with the distance in between the points and the ellipse which is worse than if we do it with two ellipses, since it is easier to approximate the shape of an object with two entities than one. Perhaps some normalization is required, e.g., to the total perimeter of the figures, or any other option that makes the metric independent of the number of degrees of freedom when fitting. In order to assess the impact of the method on the overall performance the F3 video fragment was analyzed from which every 90 th frame was taken (Figure 17). The average number of bubbles without double fitting was determined as 137.34 while with the method--138.78; thus, the average difference does not exceed one ellipse per frame.