首页 > 其他分享 >Homography|单应性

Homography|单应性

时间:2023-01-03 19:04:01浏览次数:109  
标签:homography 单应性 变换 points Homography pts


文章目录

  • ​​几何变换类型​​
  • ​​What is Homography?​​
  • ​​How to calculate a Homography ?​​
  • ​​理论推导​​
  • ​​工程实践​​
  • ​​Application​​
  • ​​Reference​​

几何变换类型

  • 保距变换 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|单应性_知乎

  • homography只针对同一平面

How to calculate a Homography ?

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

理论推导

​​单应性(homography)变换的推导 - flyinsky518 - 假设一对对应点Homography|单应性_OpenCV_02Homography|单应性_知乎_03

Homography|单应性_几何变换_04,其中

Homography|单应性_几何变换_05

Homography|单应性_计算机视觉_06

当有n对点时,Homography|单应性_几何变换_07,对A进行SVD分解,即Homography|单应性_知乎_08,取Homography|单应性_几何变换_09的最后一列求解h,再转换成Homography|单应性_知乎_10矩阵即得到Homography|单应性_几何变换_11

[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

相关文章