# Resolving Gas Bubbles Ascending in Liquid Metal from Low-SNR Neutron Radiography Images
## 3 Image Processing  
### Assumptions and Considerations for Algorithm Development  
The results obtained via the previous version of our image processing code [8; 43] determined the objectives that must be met here:  
1. Improved bubble edge detection stability--more reliable detection, less artefacts and false positives;
2. Greater bubble shape detection precision;
3. Increased bubble detection rates at the bottom of the FOV.  
The following assumptions regarding the bubbles are in effect:  
* Bubbles have perturbed elliptic/circular shapes, i.e., not necessarily convex.
* Bubble phase boundaries do not exhibit local curvature radii less that a pre-defined fraction of their mean curvature, i.e., smoothness is assumed below a certain length scale due to surface tension.  
Figure 3: Bubble signal analysis for the cropped FOV: width mean of luminance (gray) over the length of (**a**) horizontal and (**b**) vertical patches roughly fitted to the bubble dimensions, spanning the FOV. Note the scale bar in (**a**).  
No coalescence or breakup of bubbles is expected at flow rates <500 sccm considered herein. In addition, the development of the methodology outlined herein was subject to the following considerations:  
* Given the image properties/quality as described in Section 2.2, we do not attempt to perform filtering and segmentation such that argon/gallium volume fraction can be recovered, since low SNR will translate to significant errors in the output if both volume fraction field and shape recovery are attempted.
* Since the 100 FPS frame rate is the lower limit for prevention of considerable motion blur, we do not employ methods that perform spatio-temporal noise filtering--only spatial denoising is used.
* Furthermore, given the above and to make our methods more general, we treat image sequence frames _separately_ at all stages of image processing. As such, it is possible to implement parallelization on the frame level with simultaneous multi-threading enabled to speed up the processing.  
To achieve the above goals, it was decided to separate the bubble segmentation into two stages: _global_ and _local_ filtering/segmentation. That is, one starts by obtaining first estimates for bubble segments within images (the entire cropped FOV), and then uses a separate routine for local filtering/segmentation about the preliminary segments to improve shape detection precision at local scales (i.e., lower-wavelength corrections to first shape estimates) and to resolve false positives.  
The global filtering/segmentation routine, which is essentially a completely over-hauled version of our previous image processing approach [8; 43], was designed and adjusted to maximize bubble detection rates at the cost of reduced shape detection precision and higher false positive rates. Further, to improve edge detection stability, we have opted for _implicit_ edge detection. Global noise filtering is performed in multiple stages, each targeting a certain noise type and/or wavelength range.  
As for the local filtering/segmentation routine, a recursive multi-scale analysis algorithm was implemented that is shown to perform well even for images with especially low SNR and recovers bubble shapes in cases where the first segment estimation outright fails to capture initial bubbles shapes within an acceptable margin of error. The overall structure of the proposed image processing solution is outlined in Algorithm 1.  
```
Input: Raw image sequence
1 Pre-process images (Algorithm 2)
2 Perform global filtering for all images (Algorithm 3)
3 Process images with the multi-scale recursive interrogation filter (MRIF, Algorithm 4) equipped with a local filter (Algorithm 5)
4 Apply the luminance map-based false positive filter to the MRIF output (Algorithm 6)
5 Apply logical filters Output: Centroids and shape parameters for bubbles detected in each image
```  
**Algorithm 1**Overall structure of the new image processing pipeline