# 基于贝叶斯判别准则的机械设备泄露区域全自动检测Automatic Detection of Leak Areas in Mechanical Equipments Based on Bayesian Judging Criterion

Abstract: It is very complex and tedious to install the big mechanical equipments. Leak often happens in the areas in which seal requirement must be met. Traditional leak detection methods are low efficiency and high cost. Therefore, in this paper an automatic leak detection method based on Bayesian judging criterion is proposed. An adaptive dynamic threshold is derived by the means of Bayesian theory which is considered as a criterion to differentiate leak objective areas from background. The experimental results show that the leak areas in the big mechanical equipments can be fast and exactly found using the proposed method.

1. 引言

2. 传统固定阈值检测算法

$E\left(i,j\right)=\left\{\begin{array}{l}1\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{ }\text{ }\text{\hspace{0.17em}}|D\left(i,j\right)|>T\\ 0\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}|D\left(i,j\right)|\le T\end{array}$ (1)

3. 改进的动态阈值检测算法

$\begin{array}{c}R=P\left({H}_{0}\right){r}_{0}+P\left({H}_{1}\right){r}_{1}\\ =P\left({H}_{0}\right)\left[P\left({D}_{0}/{H}_{0}\right){c}_{00}+P\left({D}_{1}/{H}_{0}\right){c}_{10}\right]\\ \text{\hspace{0.17em}}\text{\hspace{0.17em}}+P\left({H}_{1}\right)\left[P\left({D}_{0}/{H}_{1}\right){c}_{01}+P\left({D}_{1}/{H}_{1}\right){c}_{11}\right]\end{array}$ (2)

$R=P\left({H}_{0}\right)P\left({D}_{1}/{H}_{0}\right)+P\left({H}_{1}\right)\left(1-P\left({D}_{1}/{H}_{1}\right)\right)$ (3)

$\begin{array}{l}P\left({D}_{1}/{H}_{0}\right)=\underset{{D}_{1}}{\int }P\left(x/{H}_{0}\right)\text{d}x\\ P\left({D}_{1}/{H}_{1}\right)=\underset{{D}_{1}}{\int }P\left(x/{H}_{1}\right)\text{d}x\end{array}$ (4)

$R=P\left({H}_{1}\right)+\underset{{D}_{1}}{\int }\left(P\left({H}_{0}\right)P\left(x/{H}_{0}\right)-P\left({H}_{1}\right)P\left(x/{H}_{1}\right)\right)\text{d}x$ (5)

$P\left({H}_{1}\right)P\left(x/{H}_{1}\right)\ge P\left({H}_{0}\right)P\left(x/{H}_{0}\right)$ (6)

$\begin{array}{l}P\left(x/{H}_{0}\right)=\frac{1}{\sqrt{2\text{π}{\sigma }_{1}}}{\text{e}}^{-\frac{{\left(x-{m}_{1}\right)}^{2}}{2{\sigma }_{1}^{2}}}\\ P\left(x/{H}_{1}\right)=\frac{1}{\sqrt{2\text{π}{\sigma }_{2}}}{\text{e}}^{-\frac{{\left(x-{m}_{2}\right)}^{2}}{2{\sigma }_{2}^{2}}}\end{array}$ (7)

$\Gamma \left(x\right)=\frac{P\left(x/{H}_{1}\right)}{P\left(x/{H}_{0}\right)}=\frac{{\sigma }_{1}}{{\sigma }_{2}}{\text{e}}^{-\frac{{\left(x-{m}_{2}\right)}^{2}}{2{\sigma }_{2}^{2}}+\frac{{\left(x-{m}_{1}\right)}^{2}}{2{\sigma }_{1}^{2}}}$ (8)

$\Gamma \left(x\right)$ 为输入信号x的单调递增函数，设 $x=\epsilon$ 时， ${\Gamma }_{0}=\frac{P\left({H}_{0}\right)}{P\left({H}_{1}\right)}$ 为阈值，那么，当 $\Gamma \left(x\right)\ge {\Gamma }_{0}$ 时，输入信号x为目标，否则，输入信号为噪声。因此可以用如下公式表示：

$\mathrm{ln}\Gamma \left(x\right)=\mathrm{ln}\frac{{\sigma }_{1}}{{\sigma }_{2}}-\frac{{\left(x-{m}_{2}\right)}^{2}}{2{\sigma }_{2}^{2}}+\frac{{\left(x-{m}_{1}\right)}^{2}}{2{\sigma }_{1}^{2}}\ge \mathrm{ln}{\Gamma }_{0}=\mathrm{ln}\frac{P\left({H}_{0}\right)}{P\left({H}_{1}\right)}$ (9)

$\begin{array}{c}G\left(x\right)=\mathrm{ln}\Gamma \left(x\right)-\mathrm{ln}{\Gamma }_{0}\\ =\frac{1-k}{2k{\sigma }_{2}^{2}}{x}^{2}+\frac{k{m}_{2}-{m}_{1}}{k{\sigma }_{2}^{2}}x+\frac{{m}_{1}^{2}-k{m}_{2}^{2}}{2k{\sigma }_{2}^{2}}+\frac{1}{2}\mathrm{ln}k\ge 0\end{array}$ (10)

$k\ge 1$ ，说明图像中背景区域占优势，利用这种情况下得到的目标区域 ${D}_{1}$ 的边界值，并作为二值图 $E\left(i,j\right)$ 的阈值，可以获得更高的目标检测的稳定性。由式(10)可知，当 $k\ge 1$ 时，目标函数 $G\left(x\right)=0$ 的两个解为：

$\begin{array}{l}{\lambda }_{1}={x}_{0}-\Delta t\\ {\lambda }_{2}={x}_{0}+\Delta t\end{array}$ (11)

$E\left(i,j\right)=\left\{\begin{array}{l}1\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}{\lambda }_{1}<|D\left(i,j\right)|<{\lambda }_{2}\\ 0\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}其它\end{array}$ (12)

4. 实验结果与分析

5. 总结

(a) (b) (c) (d)

Figure 1. Leakage region detection results (left for video source image, middle for fixed threshold T = 1, right for adaptive threshold and parameter k = 15), (a) frame 20; (b) frame 103; (c) frame 396; (d) frame 477

[1] 苑益军, 兰昆艳. 基于腐蚀滤波的运动目标检测的图像处理[J]. 计算机工程与应用, 2008, 44(1): 173-174.

[2] Huang, X.J., Zhou, J.M. and Liu, B.Y. (2010) Moving Objects Detection Approach Based on Adaptive Mixture Gaussian Background Model. Journal of Computer Applications, 30, 71-74.
https://doi.org/10.3724/SP.J.1087.2010.00071

[3] Morelander, M., Kreucher, M.C. and Kastella, K. (2007) A Bayesian Approach to Multiple Target Detection and Tracking. IEEE Transactions on Signal Processing, 55, 1589-1604.
https://doi.org/10.1109/TSP.2006.889470

[4] Huang, K.Q., Wang, L.S., Tan, T.N. and Maybank, S. (2008) A Real-Time Object Detecting and Tracking System for Outdoor Night Surveillance. Pattern Recognition, 41, 432-444.
https://doi.org/10.1016/j.patcog.2007.05.017

[5] Shen, C.H., Kim, J.N. and Wang, H.Z. (2010) Generalized Ker-nel-Based Visual Tracking. IEEE Transactions on Circuits and Systems for Video Technology, 20, 119-130.
https://doi.org/10.1109/TCSVT.2009.2031393

[6] 王春兰. 智能视频监控系统中运动目标检测方法综述[J]. 自动化与仪器仪表, 2017(3): 1-3.

[7] Liu, Y.X. and Chang, F.L. (2011) Detecting Algorithm for Moving Objects Based on Bayesian Judging Criterion. Journal of Computers, 6, 849-855.

Top