美文网首页
Homography|单应性

Homography|单应性

作者: doubleZ0108 | 来源:发表于2020-12-27 22:24 被阅读0次

几何变换类型

  • 保距变换 isometry
  • 相似变换 similarity
  • 仿射变换 affine
  • 射影变换 projective -> homography

What is Homography?

A Homography is a transformation ( a 3×3 matrix ) that maps the points in one image to the corresponding points in the other image.

单应性矩阵
  • homography只针对同一平面

How to calculate a Homography ?

摄影变换的自由度为8,一对点能产生两个方程,共需要4对对应点,即可求取H矩阵;如超过4对,通过最小二乘法或RANSAC求取最优参数

理论推导

单应性(homography)变换的推导 - flyinsky518 - 博客园

假设一对对应点a = (x,y,1)a^,=(x^,, y^,,1)

Ah=0,其中

A=\left[\begin{array}{ccccccccc}-x & -y & -1 & 0 & 0 & 0 & x x_{1} & y x_{1} & x_{1} \\ 0 & 0 & 0 & -x & -y & -1 & x y_{1} & y y_{1} & y_{1}\end{array}\right]

h=\left[h_{11}, h_{12}, h_{13}, h_{21}, h_{22}, h_{23}, h_{31}, h_{32}, h_{33}\right]^{T}

当有n对点时,A \in R^{2n\times9},对A进行SVD分解,即U * \sum * V^T,取V的最后一列求解h,再转换成3*3矩阵即得到H

[U,S,V]=svd(A);
h=V(:,9);
H= reshape(h,3,3);

工程实践

If you have more than 4 corresponding points, it is even better. OpenCV will robustly estimate a homography that best fits all corresponding points.
Usually, these point correspondences are found automatically by matching features like SIFT or SURF between the images.

'''
pts_src and pts_dst are numpy arrays of points
in source and destination images. We need at least
4 corresponding points.
'''
h, status = cv2.findHomography(pts_src, pts_dst)
'''
The calculated homography can be used to warp
the source image to destination. Size is the
size (width,height) of im_dst
'''
im_dst = cv2.warpPerspective(im_src, h, size)

Application

  • 图像矫正
  • 图像扫描
  • 虚拟广告牌 虚拟广告牌

Reference

相关文章

网友评论

      本文标题:Homography|单应性

      本文链接:https://www.haomeiwen.com/subject/szuanktx.html