Homography|单应性

几何变换类型

  • 保距变换 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) a=(x,y,1) a , = ( x , , y , , 1 ) a^,=(x^,, y^,,1) a,=(x,,y,,1)

A h = 0 Ah=0 Ah=0,其中

A = [ − 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 ] 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] A=[x0y0100x0y01xx1xy1yx1yy1x1y1]

h = [ h 11 , h 12 , h 13 , h 21 , h 22 , h 23 , h 31 , h 32 , h 33 ] T h=\left[h_{11}, h_{12}, h_{13}, h_{21}, h_{22}, h_{23}, h_{31}, h_{32}, h_{33}\right]^{T} h=[h11,h12,h13,h21,h22,h23,h31,h32,h33]T

当有n对点时, A ∈ R 2 n × 9 A \in R^{2n\times9} AR2n×9,对A进行SVD分解,即 U ∗ ∑ ∗ V T U * \sum * V^T UVT,取 V V V的最后一列求解h,再转换成 3 ∗ 3 3*3 33矩阵即得到 H H 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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

doubleZ0108

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值