# Resolving Gas Bubbles Ascending in Liquid Metal from Low-SNR Neutron Radiography Images
## 3 Image Processing
### Multi-Scale Recursive Interrogation Filter (MRIF)
#### 3.4.1 MRIF Core
Here \(\varphi=\varphi(\vec{r},t)\) with \(|\varphi|=1\), \(\vec{n}\) is the outward boundary normal, and \(\delta(\epsilon,\varphi)\) is the level set regularization function

\[\delta(\epsilon,\varphi)=\frac{\epsilon}{\pi(\epsilon^{2}+\varphi^{2})} \tag{14}\]

\(\varphi(\vec{r},t)\) is initialized as

\[\varphi(\vec{r},0)=\sin\left(\frac{\pi x}{\lambda_{\varphi}}\right)\cdot\sin \left(\frac{\pi y}{\lambda_{\varphi}}\right) \tag{15}\]

where \(\lambda_{\varphi}\) determines the wavelength of the initialized checkerboard pattern. Equation (12) with (13) and (15) is then solved iteratively by alternating between updates for \(\langle I\rangle_{D_{1}}\) and \(\langle I\rangle_{D_{2}}\), and \(\varphi\). In our case \(\mu=0.03\), \(\
u=0\), \(\lambda_{1}=\lambda_{2}=1\) and \(\epsilon=1\). As indicated in [72], (15) with \(\lambda_{\varphi}=5\) is a good initialization strategy leading to fast convergence, but we have observed that \(\lambda_{\varphi}\in[2;5)\) yields faster convergence without perceivable quality degradation in our cases. The reason Chan-Vese instead of Otsu or hysteresis binarization is used is that the former exhibits much stabler edge halo detection in IWs and is not explicitly tied to image histograms (i.e., does not _only_ minimize inter-class and maximize intra-class variance for the level sets like the Otsu method) which can be very different across IWs. Once binarization is complete, one performs the same sequence of operations as with the global filter (Algorithm 3, Steps 7-12). For local filtering, erosion for segments is performed with 1- to 5-pixel radius disk elements and the mean filtering (cleanup) radius is 1-3 pixels. #### 3.4.4 Mapping Updated Segments to Original Images

Centroids are mapped from converged IWs onto original images (full FOV) using the following transformation:

\[L=\lfloor s\cdot\sqrt{S/\pi}\rceil \tag{8}\]0

where \(\vec{r}\,^{\prime}\) is the updated centroid location in the FOV, \(\vec{r}\) are the updated centroid coordinates from MRIF in the IW coordinate system, \(\vec{r}_{\text{IW}}\) is the location of the virtual IW center in the FOV, \(\vec{r}_{0}(L)\) is the center of the virtual IW in its coordinate system and \(\vec{\Lambda}(L,\vec{r}_{\text{iw}})\) is the IW crop correction for \(\vec{r}_{0}(L)\). The mapping is illustrated in \[L=\lfloor s\cdot\sqrt{S/\pi}\rceil \tag{8}\]1 Since IW and IW\({}^{\prime}\) both always contain the segment (if any detected) and their centers are always within the FOV, for an IW fully within the bounds of the FOV one simply extends a radius vector \(\vec{r}_{\rm{iw}}\) (stored by MRIF, Algorithm 4) to the IW center and then from that to the bubble centroid via \(\vec{r}-\vec{r_{0}}(L)\) (Figure 5a, the red vector). If the virtual IW is partially out of bounds, then the actual IW\({}^{\prime}\) (Figure 5b) has a different center coordinate \(\vec{r}_{0}^{\prime}=\vec{r}_{0}+\vec{\Lambda}(L,\vec{r}_{\rm{iw}})\) since it is displaced when the IW is cropped (10). The crop correction given an image \(z\) is as follows:

\[ \begin{split}\vec{\Lambda}(L,\vec{r}_{\rm{iw}})=\vec{\varepsilon} _{x}\cdot\begin{cases}x_{\rm{min}}/2,&x_{\rm{min}}<0\\ 0,&x_{\rm{min}}\geq 0\end{cases}+\vec{\varepsilon}_{x}\cdot\begin{cases}0,&x_{\rm{ max}}\leq w\\ -(x_{\rm{max}}-w)/2,&x_{\rm{max}}>w\end{cases}\\ +\vec{\varepsilon}_{y}\cdot\begin{cases}y_{\rm{min}}/2,&y_{\rm{ min}}<0\\ 0,&y_{\rm{min}}\geq 0\end{cases}+\vec{\varepsilon}_{y}\cdot\begin{cases}0,&y_{\rm{ max}}\leq h\\ -(y_{\rm{max}}-h)/2,&y_{\rm{max}}>h\end{cases}\end{split} \end{split} \tag{17}\]

where \(x_{\rm{min}}\), \(x_{\rm{max}}\), \(y_{\rm{min}}\) and \(y_{\rm{min}}\) are given by \(L\) and \(\vec{r_{\rm{iw}}}\) via (9) and \(\dim(z)=(w,h)\). The IW crop correction is required as a separate step because the IW coordinate system origin is not necessarily within the FOV.