第 六 章 基 于 特 征 的 图 像 对 准 主要内容图像对准(Image Alignment)位姿估计-增强现实(Augmented Reality)摄像机标定(Camera Calibration) 2 0 2 1 -5 -2 2 CV:Calibration 2 图像对准-Image alignment A look into the past http:/ A look into the past Leningrad during the blockade http:/komen- Bing streetside images http:/ 图像对准的应用全景拼接 Panorama stitching目标识别 图像拼接的困难小区域重叠遮挡,混乱亮度变化 图像对准两大类方法:直接对准(基于像素)以大多数像素匹配为准则对准基于特征的对准以提取的特征匹配为准则对准 可以通过基于像素的方法进行验证 基于拟合的对准之前章节: 在单幅图像内对提取的特征(点、边缘段等)进行拟合,得到轮廓模型i i Mx ),(residualFind model M that minimizesMxi 基于拟合的对准之前章节: 在单幅图像内对提取的特征(点、边缘段等)进行拟合,得到轮廓模型i i Mx ),(residualFind model M that minimizesMxi对准: 对于两幅图像特征对间的变换关系进行数据拟合 i ii xxT ),(residualFind transformation T that minimizesTxi xi 2 D 转换模型 Similarity(translation, scale, rotation) Affine Projective(homography) 从仿射变换开始简单的数据拟合程序(线性最小二乘法)对于近似平面表面的物体和近似正交的相机可以近似看作是视点变化可以作为更复杂模型的初始拟合结果 拟合仿射变换假如已知对应关系,怎样得到转换模型?),( ii yx ),( ii yx 2143 21 ttyxmm mmyx iiii iiiiii yxttmmmmyxyx 2143211000 0100 6个未知数的线性方程组每一对匹配的特征点能够建立两个独立的线性方程:这样就至少需要三对匹配的特征点解出全部参数 iiiiii yxttmmmmyxyx 2143211000 0100拟合仿射变换 基于特征的图像对准的过程 提取特征基于特征的图像对准的过程 提取特征特征匹配基于特征的图像对准的过程 提取特征特征匹配迭代:选择三个特征点对,得到初始变换T基于特征的图像对准的过程 提取特征特征匹配迭代:选择三个特征点对,得到初始变换T利用其它特征点对,验证变换T基于特征的图像对准的过程 提取特征特征匹配迭代:选择三个特征点对,得到初始变换T利用其它特征点对,验证变换T基于特征的图像对准的过程 建立特征点对? 对比兴趣点邻域范围的图像块的特征描述子( ) ( )=?featuredescriptor featuredescriptor?建立特征点对 特征描述子假设每个图像块已经被归一化,怎样描述各个图像块的相似性?特征描述需要具有对光照变化,噪声,图像模式的不变性 最简单的描述子:图像灰度向量怎样比较两个向量的相似性? Sum of squared differences (SSD)不具有光照不变性 Normalized correlation 具有光照仿射不变性 i ii vuvu 2),SSD( j jj ji ii vvuu vvuuvu 22 )()( )(),( 特征描述子 特征描述子直接将图像块作为描述子的不足: 小的改变就会影响匹配结果解决办法: 直方图 0 2p 描述子计算过程:将每个图像块分成4 x4个子块在每个子块内计算方向梯度直方图 (8个参考方向)最终生成的描述子: 4 x4 x8 = 1 2 8 维 David G. Lowe. Distinctive image features from scale-invariant keypoints.” IJCV 60 (2), pp. 91-110, 2004. 特征描述子:SIFT 描述子计算过程:将每个图像块分成4 x4个子块在每个子块内计算方向梯度直方图 (8个参考方向)最终生成的描述子: 4 x4 x8 = 1 2 8 维与直接用像素值相比的优势梯度对于光照变化不敏感实现了对于小变化的鲁棒性, 仍然保留了空间信息 David G. Lowe. Distinctive image features from scale-invariant keypoints.” IJCV 60 (2), pp. 91-110, 2004. 特征描述子:SIFT 特征匹配?生成特征点对: 对于图像中每个子块,在其它图像中找到和它相似的一系列候选匹配块 特征空间内外点的排除怎样判断哪些特征点对是可靠的?启发式: 比较特征空间内最近邻的距离和次近邻的距离对于那些不太明确的特征队而言,最近邻的距离和次近邻的距离的比值通常会比较大 David G. Lowe. Distinctive image features from scale-invariant keypoints.” IJCV 60 (2), pp. 91-110, 2004. Threshold of 0.8 provides good separation 外点的处理几何拟合方法: RANSAC Hough transform RANSAC RANSAC loop:1 . Randomly select a seed group of matches2 . Compute transformation from seed group3 . Find inliers to this transformation 4 . If the number of inliers is sufficiently large, re-compute least-squares estimate of transformation on all of the inliers Keep the transformation with the largest number of inliers RANSAC example: Translation Putative matches Select one match, count inliers RANSAC example: Translation Select one match, count inliers RANSAC example: Translation Select translation with the most inliers RANSAC example: Translation RANSAC的问题在许多实际应用中,外点所占的比例很高 (9 0 % 以上)另一种改进方法: Hough transform Hough transform Recall: Generalized Hough transform B. Leibe, A. Leonardis, and B. Schiele, Combined Object Categorization and Segmentation with an Implicit Shape Model, ECCV Workshop on Statistical Learning in Computer Vision 2004 model visual codeword withdisplacement vectors test image Hough transform假如提取的特征具有尺度和旋转不变性这样单个特征匹配就能提供一种可能的对准 (translation, scale, orientation) David G. Lowe. Distinctive image features from scale-invariant keypoints.” IJCV 60 (2), pp. 91-110, 2004. model 假如提取的特征具有尺度和旋转不变性这样单个特征匹配就能提供一种可能的对准 (translation, scale, orientation)当然这种对准是不可靠的解决办法: 将各种可能的对准映射到Hough 空间中投票,选择得分最高的 David G. Lowe. Distinctive image features from scale-invariant keypoints.” IJCV 60 (2), pp. 91-110, 2004. model Hough transform 基于几何不变量的标注基于不变量描述子的匹配能够生成一个可能的变换关系model index 基于几何不变量的标注model test imageindex基于不变量描述子的匹配能够生成一个可能的变换关系 仿射变换的处理单应性-Homography: 平面射影变换 (使得一个四边形变成另一个任意的四边形) 单应性-Homography单相机不同视角不同相机同一场景 应用: 全景拼接 单应性拟合齐次坐标Converting to homogenenousimage coordinates Converting from homogenenousimage coordinates 11 333231 232221 131211 yxhhh hhh hhhyx 单应性拟合齐次坐标Converting to homogenenousimage coordinates Converting from homogenenousimage coordinates 单应性方程 单应性方程ii xHx 11 333231 232221 131211 iiii yxhhh hhh hhhyx 0 ii xHx iTiiTi iTiiT iTiTiiT iT iTii yx xyyx xhxh xhxh xhxhxh xh xh321 12 31 231 0000 321 hhhxx xx xx TTiiTii TiiTTi TiiTiT xy xy 3 equations, only 2 linearly independent 单应性拟合 直接线性变换 H 有8个自由度 (9 个参数, 但尺度是任意的)一个匹配特征对能够建立两个独立方程最少要4个 匹配特征对一般需要多于4个点对: 通过最小二乘拟合得到最优解000 00 321111 111 hhhxx xx xx xx TnnTTn TnnTnT TTT TTT xyxy 0hA Example: Recognising PanoramasM. Brown and D. Lowe, University of British Columbia Why “Recognising Panoramas”? Why “Recognising Panoramas”? 1 D Rotations (q) Ordering matching images Why “Recognising Panoramas”? 1 D Rotations (q) Ordering matching images Why “Recognising Panoramas”? 1 D Rotations (q) Ordering matching images Why “Recognising Panoramas”? 2D Rotations (q, f) Ordering matching images 1 D Rotations (q) Ordering matching images Why “Recognising Panoramas”? 1 D Rotations (q) Ordering matching images 2D Rotations (q, f) Ordering matching images Why “Recognising Panoramas”? 1 D Rotations (q) Ordering matching images 2D Rotations (q, f) Ordering matching images Why “Recognising Panoramas”? Overview Feature Matching Image Matching Bundle Adjustment Multi-band Blending Results Conclusions RANSAC for Homography RANSAC for Homography RANSAC for Homography Probabilistic model for verification Finding the panoramas Finding the panoramas Finding the panoramas Finding the panoramas Parameterise each camera by rotation and focal length This gives pairwise homographiesHomography for Rotation Bundle Adjustment New images initialised with rotation, focal length of best matching image Bundle Adjustment New images initialised with rotation, focal length of best matching image Multi-band Blending Burt & Adelson 1 9 8 3 Blend frequency bands over range Results 增强现实(Augmented Reality) Demo1 Demo2 Demo3 增强现实 2 0 2 1 -5 -2 2 CV:Calibration 7 4 位姿估计-增强现实 第一次作业: 图像拼接(任选)编写自己的图像拼接程序将程序放在个人信箱的网络硬盘中工具: Matlab or OpenCV时间:课程结束之前 2 0 2 1 -5 -2 2 CV:Calibration 7 6 第一次作业: 增强现实(任选)编写自己的增强现实程序将程序放在个人信箱的网络硬盘中工具: ARTOOLKIT http:/www.hitl.washington.edu/artoolkit/时间:课程结束之前 2 0 2 1 -5 -2 2 CV:Calibration 7 7 。