(4)
有:
(5)
再由式(3)遞推有:B(2) =(1-a)B(1)+aI(1)
(6)
B(3) = (1-a)B(2)+aI(2)
(7)
B(t) = (1-a)B(t-1)+aI(t-1)
(8)
其中,t≥2。
對上式進行分析,可寫為
+a(1-a)t-2I(1)+a(1-a)t-3I(2)
+…+aI(t-1)
(9)
其中,t≥2,B(t)為對根據第1~t幀視頻采樣圖像生成的背景圖像,I(t)為第t幀前景圖像。
將公式的后半部分a(1-a)t-2I(1)+…+aI(t-1)表示為A(t),其計算可用遞歸算法實現。
令A(1)=0,則有:
A(t)=(1-a)A(t-1)+aI(t-1)
(10)
令S(t)=I(1)+I(2)+…+I(t),則背景生成公式可寫為
(11)
4 實驗結果及分析
對自適應的背景生成算法用Matlab進行編程實現,實驗地點為內江市東桐路,從天橋上拍攝下方道路高清圖像進行算法測試。視頻中在道路行駛的包括機動車、非機動車,路邊人行道有以上課學生為主的行人通過,整段視頻時長1min20s,如圖1顯示了該視頻在第30s和第60s處的截圖。
設置采樣迭代次數為50,分別改變插值系數a和采樣間隔s進行實驗。

圖1 視頻截取圖像
其中插值系數a取值為0~1,插值系數越小,當前幀對背景圖像生成的貢獻越小,如果a=0,則背景圖像退化為所有采樣圖像幀的平均值。固定采樣間隔s=10,改變插值系數a為0.01,0.02,0.03和0.05,得到背景圖像如圖2所示。

圖2 固定采樣間隔s=10, 改變插值系數a的背景生成圖像
由圖2比較可以看出,隨著a增大,停靠在右側路邊白色車輛附近路過的出租車拖影越來越不明顯。但是天橋正下方,過路車輛的拖影則越來越明顯。整個道路背景效果,以a=0.03時為最佳。
固定插值系數a=0.03,改變采樣間隔次數s為2,5,10,20,得到背景圖像如圖3所示。

圖3 固定插值系數a=0.03, 改變采樣間隔s的背景生成圖像
由圖3比較可以看出,采樣間隔s=2時,道路汽車拖影最大,隨著s增大,道路汽車拖影減小,當s=20時,盡管道路上汽車拖影小,但是天橋左下方一輛摩托車的影像顯現,那是因為視頻中段正好有一輛摩托車在天橋左下方做過停留。整個圖像背景效果,以s=10時為最佳。
設置插值系數a=0.03,采樣間隔s=10,改變采樣迭代次數為100。于上述50次迭代計數方式進行對比,得到背景圖像如圖4所示。

圖4 迭代分別為50和100時的 次數的背景生成圖像
由圖4比較可以看出,50次迭代的生成結果優于100次迭代的生成結果,后者對天橋左下方的摩托車處理效果不佳,而且路面處理效果不如前者。
將此算法用于同一天橋另一側道路視頻錄像處理,設置插值系數a=0.03,采樣間隔s=5,改變迭代計數,得到背景圖像如圖5所示。

圖5 天橋另側背景生成圖像
由圖5比較可以看出,算法對背景中運動車輛和行人處理效果較好,能成功提取背景圖像。不同的迭代次數,可能產生不同的處理效果。
由上述實驗可以看出,這種基于高斯分布模型的自適應背景生成法可以很好生成背景圖像,為了得到最佳圖像效果,可以改變迭代次數、插值系數、視頻采樣間隔幀數,不同視頻可能有不同的最佳參數。
5 結語
圖像背景生成在圖像處理中具有非常重要的意義,本文提出的基于高斯分布模型的自適應背景生成法對常用的背景減法進行優化,實現了運算效果和效率的平衡。模型參數簡單,算法實時性好,能夠在較短時間生成較為清晰的交通監控背景圖像。
[1] 王彬,馮遠靜,郭海峰,等.交通場景中車輛的運動檢測與陰影消除[J].中國圖象圖形學報,2012,17(11):1391-1399. WANG Bin, FENG Yuanjing, GUO Haifeng, et al. Adaptive Background Updating and Shadow Detection in Traffic Scenes[J]. Journal of Image and Graphics,2012,17(11):1391-1399.
[2] Tanaka K, Saji H. Vehicle extraction from aerial images using voting process and frame matching[C]//Proceedings of IEEE Intelligent Vehicles Symposium,2007:433-437.
[3] Lin P Q, Xu J M, Bian J Y. Robust vehicle detection in vision systems based on fast wavelet transform and texture analysis[C]//Proceedings of IEEE International Conference on Automation and Logistics,2007:2958-2963.
[4] 王歡,邢麗冬,錢志余,等.基于改進的高斯混合模型的運動物體檢測[J].計算機技術與發展,2012,22(12):139-141. WANG Huan, XING Lidong, QIAN Zhiyu, et al. Moving Target Detection Based on Improved Gaussian Mixture Model[J]. Computer Technology and Development,2012,22(12):139-141.
[5] 許崇博,王美華,譚志標.自適應車流方向的跨道行人檢測[J].計算機工程,2011,37(21):141-143. XU Chongbo, WANG Meihua, TAN Zhibiao. Crossing Pedestrians Detection Adapted to Traffic Flow Direction[J]. Computer Engineering,2011,37(21):141-143.
[6] 溫雯,郝志峰,邵壯豐.結合分水嶺機制的有監督圖像背景分割算法[J].計算機工程與應用,2011,47(21):205-209. WEN Wen, HAO Zhifeng, SHAO Zhuangfeng. Supervised background segmentation algorithm combined with watershed mechanism[J]. Computer Engineering and Applications,2011,47(21):205-209.
[7] 李全民,張運楚.自適應混合高斯背景模型的改進[J].計算機應用,2007,27(8):2014-2017. LI Quanmin, ZHANG Yunchu. Improvement on adaptive mixture Gaussian background model[J]. Computer Applications,2007,27(8):2014-2017.
[8] 陳雷,張榮國,胡靜,等.改進的混合高斯模型及陰影消除方法[J].計算機應用,2013,33(5):1394-1397,1400. CHEN Lei, ZHANG Rongguo, HU Jing, et al. Improved Gaussian Mixture Model and Shadow Elimination Method[J]. Journal of Computer Applications,2013,33(5):1394-1397,1400.
[9] 范文超,李曉宇,魏凱,等.基于改進的高斯混合模型的運動目標檢測[J].計算機科學,2015,42(5):286-288,319. FAN Wenchao, LI Xiaoyu, WEI Kai, et al. Moving Target Detection Based on Improved Gaussian Mixture Model[J]. Computer Science,2015,42(5):286-288,319.
[10] 王正勤,劉富強.自適應背景提取算法的比較[J].計算機工程,2008,34(23):220-223. WANG Zhengqin, LIU Fuqiang. Comparison of Adaptive Extract Algorithm of Object Scene[J]. Computer Engineering,2008,34(23):220-223.
[11] 王愛麗,董寶田,王澤勝.融合光流速度場與背景差分的自適應背景更新方法[J].中國鐵道科學,2014,35(6):131-137. WANG Aili, DONG Baotian, WANG Zesheng, et al. Adaptive Background Updating Based on Optical Flow and Background Difference[J]. China Railway Science,2014,35(6):131-137.
[12] 高曉丹,魏婉華.基于高斯分布的自適應紅外圖像增強算法[J].紅外技術,2014,36(5):381-383. GAO Xiaodan, WEI Wanhua. An Adptive Enhancement Algorithm Based on Gaussian Distribution for Infrared Image[J]. Infrared Technology,2014,36(5):381-383.
An Adaptive Background Generation Algorithm
HUANG Wei1ZHANG Wei2
(1. Neijiang Vocational and Technical College, Neijiang 641100)(2. Beijing Union University, Beijing 100011)
Moving object detection is a key technology of object recognition and analysis, which has great significance in theory and practice. This paper summarizes the current situation of moving object detection technics developing and focuses on the research of background generation algorithm. The background model based on Gaussian distribution is analyzed, according to which an adaptive background generation algorithm is designed. This algorithm which adopts iteration idea is efficient and feasible. The experiment results on vary traffic videos prove the efficiency and robustness of the algorithm.
moving object detection, background generation, Gaussian distribution, background model, adaptive algorithm
2016年7月19日,
2016年8月31日
黃衛,女,碩士,講師,研究方向:通信工程、信息處理。張蔚,女,博士,講師,研究方向:圖像處理、自然語言處理、模式識別與機器學習等。
TP391
10.3969/j.issn.1672-9722.2017.01.036