文章目录
- 几何变换类型
- 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只针对同一平面
How to calculate a Homography ?
摄影变换的自由度为8,一对点能产生两个方程,共需要4对对应点,即可求取H矩阵;如超过4对,通过最小二乘法或RANSAC求取最优参数
理论推导
单应性(homography)变换的推导 - flyinsky518 - 假设一对对应点和
有,其中
当有n对点时,,对A进行SVD分解,即,取的最后一列求解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 Examples using OpenCV ( Python / C ++ ) | Learn OpenCV
- Opencv日常之Homography_liuphahaha的专栏 标签:homography,单应性,变换,points,Homography,pts From: https://blog.51cto.com/doubleZ/5986600