## 3 Object Detection in High-Resolution Images Using OPAIs
To address this issue, this paper proposes a highly effective method for reducing the size of high-resolution input images to match the input size that deep learning models can handle, thus optimizing processing efficiency. Figure 6 shows the flowchart for the recognition of foreign particles. Key steps are discussed in the following sections. The steps for preprocessing input frames are based on down-sampling and differentiating consecutive input images to detect candidate objects and reject backgrounds and noise. To reduce the computational burden for preprocessing and subsequent tracking, the two consecutive input frames \(f_{t-1}(i,j)\) and \(f_{t}(i,j)\) of size \(M\times N\), located at coordinates \((i,j)\), are down-sampled by a factor of \(k\), resulting in down-sampled images of \(g_{t-1}(m,n)\) and \(g_{t}(m,n)\) of size \(\frac{M}{k}\times\frac{N}{k}\) at down-sampled coordinates \(\left(m=\frac{i}{k},\ n=\frac{j}{k}\right)\). The differential image with blobs of significant values can then be obtained, where the blobs are thought to be moving objects. \[D_{t}(m,\ n)=|g_{t}(m,n)-g_{t-1}(m,n)| \tag{1}\]  
\[O_{t}(m,n)=g_{t}(m,n)\ \ \ \ if\ D_{t}(m,\ n)>T \tag{2}\]  
\[BK_{t}(m,n)=g_{t}(m,n)\ \ \ \ \ if\ D_{t}(m,\ n)\leq T \tag{3}\]  
where \(D_{t}(m,n)\) is the result of the inter-frame difference, \(O_{t}(m,\ n)\) is the object area, \(BK_{t}(m,\ n)\) is the background area, and \(T\) is a threshold value that is greater than the noise level in input images. When we examine \(O_{t}(m,\ n)\), the object area can consist of various components, such as moving particles, moving bubbles, locally moving backgrounds, and noise. Thus, \(O_{t}(m,\ n)\) can be defined as the union of all these sets. \[O_{t}=MP_{t-1}\cup MP_{t}\cup MB_{t-1}\cup MB_{t}\cup WBK_{t-1}\cup WBK_{t}\cup N _{t-1}\cup N_{t} \tag{4}\]  
where \(MP_{t}\) is moving particles observed at time \(t\), \(MB_{t}\) is moving bubbles observed at time \(t\), \(WBK_{t}\) is wobbling background observed at time \(t\), and \(N_{t}\) is noise observed at time \(t\). In order to determine if a fluid bag is contaminated by particles, we need to verify the existence of \(MP_{t}\) only, as all the other components act as performance degradation factors that make detection harder. Thus, we apply several filters that remove these performance-degrading factors for more precise detection in our algorithm. For a wobbling background, \(WBK_{t-1}\) and \(WBK_{t}\) result from the non-uniform movement due to the flexibility of fluid bags, which leads to very short movements, such as \(\pm 1\) to \(\pm 3\) pixels, in diverse directions. Based on this,  
Figure 6: Flowchart of detecting foreign particle using a deep learning model on OPAIs: (**a**) preprocessing of input frames; (**b**) tracking and constructing OPAI; (**c**) detection of particles or bubbles. we apply a similarity measurement, such as the normalized correlation coefficient (NCC), to \(O_{t}\), to detect and filter out \(WBK_{t-1}\) and \(WBK_{t}\), resulting in moving objects, \(MO_{t}\), as shown below:  
\[MO_{t}=O_{t}-\widehat{WBK}_{t}-\widehat{WBK}_{t-1} \tag{5}\]  
where \(W\widehat{B}K_{t}\) is an estimation of the wobbling background at time \(t\) and can be defined as follows:  
\[W\widehat{B}K_{t}=\left\{g_{t}(m,\ n)\left|r \begin{array}{c}(m,\ n)\in \arg(O_{t}),\\ O_{t-1}(m-dx,n-dy))>T_{WBK},\\ dx\in[-3,\ 3],\\ dy\in[-3,\ 3]\end{array} \right.\right\} \tag{6}\]  
where \(T_{WBK}\) is the threshold for wobbling background and the normalized correlation coefficient r between two images is defined as follows:  
\[r=\frac{\sum\bigl{(}A(m,\ n)-\overline{A}\bigr{)}\left(B(m,\ n)-\overline{B} \right)}{\sqrt{\sum\bigl{(}A(m,\ n)-\overline{A}\bigr{)}^{2}\sum\bigl{(}B(m,\ n)- \overline{B}\bigr{)}^{2}}} \tag{7}\]  
where \(\overline{A}\) and \(\overline{B}\) are the mean values of images \(A\) and \(B\), respectively. In the case of moving objects, \(MP_{t-1}(m,n)\) and \(MB_{t-1}(m,n)\) are kinds of fake objects that do not exist in the current input frame \(g_{t}(m,n)\).