图像变换

OpenCV中提供的函数

Geometric Image Transformations

官方文档2D变换1

  • 避免采样误差:In fact, to avoid sampling artifacts, the mapping is done in the reverse order, from destination to the source. In case when you specify the forward mapping , the OpenCV functions first compute the corresponding inverse mapping and then use the above formula. 即给定src->dst转换矩阵,实际中也会先算reverse矩阵,再map。
  • 原图不存在点的推测(因为即使reverse map,也可能再在原图是float)
    • In the simplest case, the coordinates can be just rounded to the nearest integer coordinates and the corresponding pixel can be used. This is called a nearest-neighbor interpolation. 近邻方法
    • However, a better result can be achieved by using more sophisticated interpolation methods , where a polynomial function. 多项式拟合,具体的方法可以在resize的interpolation参数查到。

getAffineTransform

  • 输入两组三个点,计算仿射变换。
  • 计算的放射矩阵是2*3矩阵,可以从变换公式中看出,dst的x和src的(x,y)均相关,y亦然。
  • 对于点的要求:Given 3 points on one plane(共面很重要) and 3 matching points on another you can calculate affine transform between those planes.
    在这里插入图片描述

getPerspectiveTransform

  • 输入两组四个点,计算透视变换。
  • 透视变换矩阵3*3.

getRotationMatrix2D

  • 根据center,angle,scale获取对应的2*3矩阵。
  • 上面的变换方法是给定src、dst计算变换矩阵,这个是设计变换矩阵。
    在这里插入图片描述

warpAffine

  • 获取了各种2*3的变换矩阵后(比如getAffineTransform、getRotationMatrix2D),用该函数作用于原图,得到变换后的图。
  • non in-place

warpPerspective

  • 同理,使用3*3的透视变换矩阵,得到变换后的图像。

Motion Analysis and Object Tracking

estimateRigidTransform

  • Computes an optimal affine transformation between two 2D point sets. 注意还是2D平面。
  • If you can’t get your points with absolute precision (which is normally the case when you get them from an image) then you need more than 3 pairs of points to reduce the error. 如果使用三个点,那么estimateRigidTransform的结果和getAffineTransform结果一致。
  • fullAffine参数若为True,则无任何限制共6个自由度;反之则有限制,为5个自由度。

Camera Calibration and 3D Reconstruction

findHomography

  • Finds a perspective transformation between two planes.
  • This one is more advanced. Not only it can deal with errors in locations of points, but it can also deal with existence of the outliers. 由于estimateRigidTransform使用的是最小化均方误差(i.e 最小二乘值),那么如果有outlier则效果会很差。
  • It can use RANSAC or LMeDs to test possible matches and eliminate those outliers.
  • It works like(是相似,不是 就是) multiple iterations of estimateRigidTransform: find least square match for different sub-sets of points. If you know that no outliers are present then you can set the ‘method’ argument to 0, and it will work like estimateRigidTransform - by trying to minimize least square error created from match of all points.

其他参考文章2


  1. Geometric Image Transformations: https://docs.opencv.org/2.4/modules/imgproc/doc/geometric_transformations.html?highlight=getaffinetransform ↩︎

  2. 数学求解 http://nghiaho.com/?p=2208 ↩︎

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值