﻿ 基于LabView的多项式畸变模型图像矫正方法
 计算机系统应用  2001, Vol. 29 Issue (9): 219-224 PDF

Image Correction Method of Polynomial Distortion Model Based on LabView
WU Ya-Shuai, LIU Xin-Mei, YIN Jun-Ling, GAO Zhi-Heng
National Key Laboratory of Electronic Measurement Technology, North University of China, Taiyuan 030051, China
Foundation item: Scientific Research Program for Returned Oversea Scholars of Shanxi Province (2017-090); Key Research and Development Program of Shanxi Province (201903D121058)
Abstract: Correction of image distortion is one of the problems in the field of image processing, especially in the field of automated inspection. A polynomial distortion imaging model is used to establish the conversion relationship between coordinate systems. Based on the LabView platform, the calibration dot matrix is used to calibrate the machine vision system, and the bilinear interpolation algorithm is used to correct the image in different working modes. The experimental results show that the acquired images have been well corrected and the expected results have been achieved.
Key words: distortion correction     machine vision     LabView     calibration     polynomial distortion model     linear interpolation

1 图像畸变模型的建立

1.1 畸变模型的确立

 $\left\{ {\begin{split} & {{x_{\rm corrected}} = x\left( {1 + {k_1}{r^2} + {k_2}{r^4} + \cdots + {k_n}{r^{2n}}} \right)} \\ & {{y_{\rm corrected}} = y\left( {1 + {k_1}{r^2} + {k_2}{r^4} + \cdots + {k_n}{r^{2n}}} \right)} \end{split}} \right.$ (1)

 $\left\{ {\begin{array}{*{20}{c}} {{x_{\rm corrected}} = 2{p_1}xy + {p_2}\left( {{r^2} + 2{x^2}} \right)} \\ {{y_{\rm corrected}} = 2{p_2}xy + {p_1}\left( {{r^2} + 2{y^2}} \right)} \end{array}} \right.$ (2)

 $\left\{ {\begin{array}{*{20}{c}} \begin{split} {x_{\rm corrected}} = &x\left( {1 + {k_1}{r^2} + {k_2}{r^4} + {k_3}{r^6}} \right) \\ &+\left[ {2{p_1}xy + {p_2}\left( {{r^2} + 2{x^2}} \right)} \right] \end{split} \\ \begin{split} {y_{\rm corrected}} =& y\left( {1 + {k_1}{r^2} + {k_2}{r^4} + {k_3}{r^6}} \right) \\ &+\left[ {2{p_2}xy + {p_1}\left( {{r^2} + 2{y^2}} \right)} \right] \\ \end{split} \end{array}} \right.$ (3)

1.2 坐标系的建立

 图 1 坐标系统转换模型示意图

 $\left[ {\begin{array}{*{20}{c}} {{x_c}} \\ {{y_c}} \\ {{{\textit{z}}_c}} \end{array}} \right] = {{R}}\left[ {\begin{array}{*{20}{c}} {{x_w}} \\ {{y_w}} \\ {{{\textit{z}}_w}} \end{array}} \right] + {{T}} = \left[ {\begin{array}{*{20}{c}} \psi &\varphi &\theta \end{array}} \right]\left[ {\begin{array}{*{20}{c}} {{x_w}} \\ {{y_w}} \\ {{{\textit{z}}_w}} \end{array}} \right] + \left[ {\begin{array}{*{20}{c}} {{t_x}} \\ {{t_y}} \\ {{t_{\textit{z}}}} \end{array}} \right]$ (4)

 $\left[ {\begin{array}{*{20}{c}} u \\ v \end{array}} \right] = \frac{f}{{{{\textit{z}}_c}}}\left[ {\begin{array}{*{20}{c}} {{x_c}} \\ {{y_c}} \end{array}} \right]$ (5)

 $\left[ {\begin{array}{*{20}{c}} x\\ y \end{array}} \right] = \frac{f}{{{{\textit{z}}_c}}}\left[ {\begin{array}{*{20}{c}} {\begin{array}{*{20}{c}} {\dfrac{1}{{{s_x}}}}&0&{{x_0}} \end{array}}\\ {\begin{array}{*{20}{c}} 0&{\dfrac{1}{{{s_y}}}}&{{y_0}} \end{array}} \end{array}} \right]\left[ {\begin{array}{*{20}{c}} v\\ u\\ 1 \end{array}} \right],{f_y} = \dfrac{f}{{{s_y}}},{f_x} = \dfrac{f}{{{s_x}}}$ (6)

Ow中的zw = 0, 可以得出:

 $\begin{array}{l} k\left[ {\begin{array}{*{20}{c}} \!\!x\!\!\\ \!\!y\!\!\\ \!\!1\!\! \end{array}} \right] = {{M}}\left[ {\begin{array}{*{20}{c}} \psi\!\!\!\!\! & \varphi\!\!\!\!\! & \theta \!\!\!\!\!&{{T}} \end{array}} \right]\left[ {\begin{array}{*{20}{c}} \!\!{{x_w}}\!\!\\ \!\!{{y_w}}\!\!\\ \!\!0\!\!\\ \!\!1\!\! \end{array}} \right] = {{M}}\left[ {\begin{array}{*{20}{c}} \psi\!\!\!\!\! & \varphi\!\!\!\!\! &{{T}} \end{array}} \right]\left[ {\begin{array}{*{20}{c}} \!\!{{x_w}}\!\!\\ \!\!{{y_w}}\!\!\\ 1 \end{array}} \right] \end{array}$ (7)
 ${{M}} = \left[ {\begin{array}{*{20}{c}} {{f_r}}&\gamma &{{r_0}} \\ 0&{{f_c}}&{{r_c}} \\ 0&0&1 \end{array}} \right]$ (8)

H为单应性矩阵, 令:

 ${{H}} = \left[ {\begin{array}{*{20}{c}} {{h_1}}&{{h_2}}&{{h_3}} \end{array}} \right] = {{M}}\left[ {\begin{array}{*{20}{c}} \psi &\varphi &{{T}} \end{array}} \right]$ (9)

 $\left\{ {\begin{array}{*{20}{l}} {h_1^{\rm T}{{{M}}^{ - {\rm T}}}{{{M}}^{ - 1}}{h_2} = 0} \\ {h_1^{\rm T}{{{M}}^{ - {\rm T}}}{{{M}}^{ - 1}}{h_1} = h_2^{\rm T}{{{M}}^{ - {\rm T}}}{{{M}}^{ - 1}}{h_2}} \end{array}} \right.$ (10)

1.3 坐标转换结果

 图 2 坐标系建立前后图

2 机器视觉系统校准

2.1 系统校准方法分析

2.2 基于LabView平台的系统校准

 图 3 图像校准程序界面

 图 4 图像校准前后对比以及误差参数图

3 图像畸变矫正算法

3.1 图像矫正算法

3.2 基于LabView平台图像畸变矫正

 图 5 图像矫正程序界面

 图 6 PCB电路板图像不同方式下矫正前后对比图

 图 7 校准并矫正后的误差参数图

4 实验结果分析

5 结论

 [1] 卢荣胜, 吴昂, 张腾达, 等. 自动光学(视觉)检测技术及其在缺陷检测中的应用综述. 光学学报, 2018, 38(8): 0815002. [2] 汤勃, 孔建益, 伍世虔. 机器视觉表面缺陷检测综述. 中国图象图形学报, 2017, 22(12): 1640-1663. DOI:10.11834/jig.160623 [3] 乔闹生, 叶玉堂, 莫春华, 等. 印刷电路板光电图像畸变校正研究. 光电子•激光, 2009, 20(11): 1548-1551. [4] 周秀荣, 崔小虹, 邢冀川. 基于LabVIEW平台的图像采集与处理技术研究. 光学技术, 2007, 33(S1): 357-358. [5] 张宝辉, 姚立斌, 张巍伟, 等. 红外图像校正与增强技术研究现状. 红外技术, 2017, 39(6): 481-488. DOI:10.11846/j.issn.1001_8891.201706001 [6] 尹丽华, 李范鸣, 刘士建, 等. 光电全景成像系统的图像校正技术. 光电工程, 2016, 43(8): 53-58. DOI:10.3969/j.issn.1003-501X.2016.08.009 [7] Fitzgibbon AW. Simultaneous linear estimation of multiple view geometry and lens distortion. Proceedings of 2001 IEEE Computer Society Conference on Computer Vision and Pattern Recognition. Kauai, HI, USA. 2001. 120–125. [8] Heikkila J. Geometric camera calibration using circular control points. IEEE Transactions on Pattern Analysis and Machine Intelligence, 2000, 22(10): 1066-1077. DOI:10.1109/34.879788 [9] Brown DC. Close-range camera calibration. Photogrammetric Engineering, 1971, 37(8): 855-866. [10] 李光明, 孙英爽, 党小娟. 基于LabVIEW的几何匹配方法的设计与实现. 计算机工程与设计, 2016, 37(10): 2705-2709. [11] 吕金隆. 基于LabVIEW的机器视觉伺服系统开发平台的研究[硕士学位论文]. 青岛: 青岛大学, 2017. [12] 李彤彤. 双目视觉系统的标定及畸变校正技术研究[硕士学位论文]. 长春: 吉林大学, 2019. [13] Tang ZW, von Gioi RG, Monasse P, et al. A precision analysis of camera distortion models. IEEE Transactions on Image Processing, 2017, 26(6): 2694-2704. DOI:10.1109/TIP.2017.2686001 [14] 张建国, 陈维光, 莘明星, 等. 一种基于LabVIEW的摄像机非线性畸变标定方法. 船舶工程, 2018, 40(12): 64-68, 76. [15] Ronda JI, Valdés A. Geometrical analysis of polynomial lens distortion models. Journal of Mathematical Imaging and Vision, 2019, 61(3): 252-268. DOI:10.1007/s10851-018-0833-x [16] 王赛男, 孟显娇, 鲜鑫. 基于机器视觉的鱼眼镜头畸变校正算法. 数字技术与应用, 2018, 36(10): 141-142, 144. [17] 余芬芬, 金国强, 金一, 等. 基于图像处理的PCB在线检测图像校正. 工业控制计算机, 2018, 31(8): 124-126. DOI:10.3969/j.issn.1001-182X.2018.08.055 [18] Li J, Su J, Zeng X. A solution method for image distortion correction model based on bilinear interpolation. Computer Optics, 2019, 43(1): 99-104. DOI:10.18287/2412-6179-2019-43-1-99-104 [19] 杨高科. 图像处理、分析与机器视觉(基于LabVIEW). 北京: 清华大学出版社, 2018.