
趙 陽(1980-)
女,助教,就職于河南工業(yè)職業(yè)技術(shù)學(xué)院。
摘要:攝像機(jī)線性化技術(shù)是機(jī)器視覺研究中的關(guān)鍵技術(shù)之一。本文針對高速彩色攝像機(jī)的非線性特性導(dǎo)致的圖像畸變問題,分析其產(chǎn)生原因并給出了基于線性化校正的具體實(shí)現(xiàn)方法。在Visual C++6.0環(huán)境下實(shí)現(xiàn)了此算法,并應(yīng)用異性纖維清除系統(tǒng)當(dāng)中。試驗(yàn)結(jié)果表明, 該方法能夠提高系統(tǒng)性能并有效檢測皮棉中的異性纖維。
關(guān)鍵詞:最小二乘法;非線性特性;線性校正
Abstract: The linear technology of the camera is the key technology in the research of
machine vision. In this paper, to solve picture distortion problem, we analyze the nonlinear
characteristic of the colored camera of high speed, and provide the concrete implementation
method based on that linear method of camera calibration. The algorithm have been realized
under the environment of Visual C++6.0 and applied to inspecting system for removal of the
hetero fibers..The experiment result indicates that the method improves the system
performance, and most of the hetero fibers can be detected.
Key words: least square method; nonlinear feature; correct linearly
1 引言
在基于機(jī)器視覺的光學(xué)測量設(shè)備中,物體經(jīng)過光學(xué)系統(tǒng)(鏡頭)成像,通過攝像機(jī)的光電轉(zhuǎn)換和掃描后,將其傳入計(jì)算機(jī),直接在計(jì)算機(jī)中處理數(shù)據(jù)并輸出物體的圖像。但是經(jīng)常會有一些輸出的圖像發(fā)生畸變,這種畸變產(chǎn)生的原因是來自光學(xué)系統(tǒng)設(shè)計(jì)和制造的缺陷,或者圖像傳感器的失真。圖像失真對基于圖像的測量及檢測系統(tǒng)的精確性會產(chǎn)生很大影響。因?yàn)閳D像處理系統(tǒng)需要從圖像中提取物體的空間真實(shí)位置,幾何尺寸及形態(tài),當(dāng)圖像不含任何畸變時(shí),可以通過對空間圖像的測量與分析得到物體物理上精確的對應(yīng)關(guān)系。
如果圖像由于上述原因發(fā)生了畸變,則這種對應(yīng)關(guān)系也發(fā)生了非線性的變化,影響圖像處理系統(tǒng)的測量精度。在作者參與開發(fā)的異性纖維在線檢測系統(tǒng)中圖像非線性畸變嚴(yán)重影響了系統(tǒng)的清除性能,使棉產(chǎn)品質(zhì)量不能夠得到顯著性的提高,所以需要對圖像的非線性進(jìn)行校正,使其能夠以比較理想的狀態(tài)來反映物像之間的對應(yīng)關(guān)系。
2 攝像機(jī)成像模型與鏡頭非線性畸變模型
2.1 理想像機(jī)的成像模型
三維空間中的物體到像平面的投影關(guān)系即為成像模型。理想的投影成像模型是光學(xué)中的中心投影,也稱為針孔模型,即假設(shè)物體表面的反射光都經(jīng)過一個(gè)“針孔”而投影在像平面上,滿足光的直線傳播條件。圖1為針孔模型成像原理圖。
小孔成像由于透光量太小,需要很長的曝光時(shí)間,并且很難得到清晰的圖像,而使用鏡頭可以很好地解決上述問題。因此實(shí)際攝影系統(tǒng)通常是由透鏡或透鏡組組成的。圖2是理想單透鏡成像原理圖。在針孔成像中焦距等于像距,而在透鏡成像中,焦距并不等于像距。但兩者的成像關(guān)系是一致的,即像點(diǎn)是物點(diǎn)和光心的連線與圖像平面的交點(diǎn),所以可以用針孔模型作為攝像機(jī)成像模型。在視覺檢測中攝像機(jī)的成像模型一般用理想透視成像模型來近似。
2.2 像機(jī)非線性產(chǎn)生原因
圖3為CCD線陣像機(jī)獲取圖像數(shù)據(jù)的示意圖。
圖3 成像示意圖
由上圖所知,由于物體反射光通過鏡片進(jìn)入CCD傳感器的角度不同,即使在均勻平行光照射物體的前提下,對于同一材質(zhì)且表面均勻的物體在系統(tǒng)上采集到的圖像也是一個(gè)中間亮兩端暗的圖像。反映在數(shù)據(jù)曲線上基本是一個(gè)兩端對稱的曲線,如圖4所示。
3 非線性問題的校正方法
對攝像機(jī)非線性的校正是基于圖像的精確測量為基礎(chǔ),畸變的校正程度極大地影響測量系統(tǒng)的精度,從而快速、準(zhǔn)確地對攝像機(jī)畸變進(jìn)行校正是不可或缺的一步。常見的校正方法有非線性優(yōu)化法、直接線性變換法等,校正前對原始圖像進(jìn)行噪聲過濾等圖像預(yù)處理,通過抑制中間信號,補(bǔ)償邊緣信號,從而使得像機(jī)邊緣和中心處的圖象信息基本類同。
3.1 最小二乘法擬合算法
從整體上考慮近似函數(shù)




一是誤差




二是誤差絕對值的和


三是誤差平方和


數(shù)據(jù)擬合的具體作法是:對給定數(shù)據(jù)







3.2 像機(jī)非線性參數(shù)的確定
彩色像機(jī)中有三個(gè)傳感器陣列,其三個(gè)傳感器陣列的非線性特性并不完全相同。下面以像機(jī)的R傳感器為例,來說明獲取像機(jī)校正參數(shù)的過程:
對同一材質(zhì)的背板進(jìn)行一次采集,原始數(shù)據(jù)為:





改變光強(qiáng),保持其它條件不變,再一次進(jìn)行圖像采集并分離出R分量,得原始數(shù)據(jù)如下:





分別對兩組數(shù)據(jù)進(jìn)行最小二乘擬合,擬合后得到如下兩組數(shù)據(jù):










作差值運(yùn)算:




選擇一標(biāo)稱點(diǎn),在系統(tǒng)中我們選擇中間點(diǎn)(第2048像素點(diǎn))作為標(biāo)稱點(diǎn),通過比例可以換算出R分量的非線性參數(shù):(標(biāo)稱點(diǎn)的比例系數(shù)為1.0)





得到的數(shù)據(jù)





3.3 閾值上下限的提取
在系統(tǒng)中有三條閾值上下限,仍以R分量的上下限獲取過程為例。
第一步:對標(biāo)準(zhǔn)棉花進(jìn)行一次數(shù)據(jù)采集并分離出R分量,數(shù)據(jù)為:





第二步:將式(8)中數(shù)據(jù)全部乘以式(7)中對應(yīng)的系數(shù)并通過下面的公式:






對數(shù)據(jù)


對MAX按式(7)反算可得上限序列:


相應(yīng)的下限可得到最小值

4 實(shí)驗(yàn)結(jié)果及分析
在系統(tǒng)調(diào)試的過程中,采用本文中的相機(jī)非線性參數(shù)整定能夠有效地克服噪聲以及外界環(huán)境對圖象的干擾,并對圖象質(zhì)量進(jìn)行校正,有效提高檢測質(zhì)量。
將(9)式中所得數(shù)據(jù)作為圖象處理的基本數(shù)據(jù),使得像機(jī)邊緣部分和中間部分的圖象得到一定改善,且經(jīng)過實(shí)驗(yàn)發(fā)現(xiàn)基本能夠滿足實(shí)際要求。圖5為在本系統(tǒng)中對數(shù)據(jù)線進(jìn)行最小二乘擬合后的曲線。圖像曲線較為平滑,利于數(shù)據(jù)分析及算法的優(yōu)化。
5 結(jié)束語
本文通過分析相機(jī)非線性問題的產(chǎn)生原因,結(jié)合數(shù)字圖像的處理方法,通過標(biāo)定像機(jī)參數(shù)的方法克服了由于攝像機(jī)的非線性特性所導(dǎo)致的像機(jī)分辨率下降以及引起的一系列問題。從現(xiàn)場應(yīng)用來看,此方法能達(dá)到優(yōu)化圖像,改進(jìn)異性纖維清除系統(tǒng)性能的要求。試驗(yàn)表明,最終使整機(jī)性能基本滿足棉紡企業(yè)的要求。
參考文獻(xiàn)
[1] Faig W. Calibration of close-range photogrammetric systems mathematical formulation[J]. Photogrammetic engineering& Remot Sensing, 1975,41: 1479~1486.
[2] Camera calibrationwith distortion models and accuracy evaluation-Juyang Weng, member, IEEE,Paul Cohen,and Marc Hernion.IEEE TRANSACTIONS ON PATTERN ANALYSIS
AND MACHINE INTELLIGENCE[J], VOL,14,NO.10,OCTOBER 1992.965-980.
[3] 鄭南寧. 計(jì)算機(jī)視覺與模式識別[M]. 北京: 國防工業(yè)出版社, 1998.
[4] 張艷珍, 歐宗瑛. 一種新的攝像機(jī)線性標(biāo)定方法[J]. 中國圖像學(xué)報(bào), 2001,6(8).
[5] 雷成, 吳福朝, 等.Kruppa方程與攝像機(jī)標(biāo)定[J].自動化學(xué)報(bào),2001,27(5).
[6] 姜大志, 等. 計(jì)算機(jī)視覺中的設(shè)備標(biāo)定和三維圖像重構(gòu)概述[J]. 計(jì)算機(jī)工程與應(yīng)用, 2001.38(13):
53-55.
[7] 丁天懷, 李勇, 苗君哲, 等. 基于BP神經(jīng)網(wǎng)絡(luò)的皮棉雜質(zhì)在線檢測方法[J ]. 農(nóng)業(yè)工程學(xué)報(bào), 2003, 19 (2) .
[8] 石庚堯. 淺議異性纖維在線檢出裝置性能特征[J]. 棉紡織技術(shù) 2004,10 612-615.