仿射变换

什么是仿射变换?

Affine Transformation.任意由线性变换(矩阵乘法)+向量加法操作构成的变换操作. 包括平移(Translation), Rescale(放缩), Rotate(旋转).

仿射变换的视觉特点是: 原图中平行的线在变换后图片中仍然平行. (而透视变换Perspective Transformation则是垂直方向的直线一直垂直)

它可以表示为: (f(x) = Ax + b), 其中, (A)是一个(2 imes 2)的矩阵, (b)是一个二维列向量. 若使用增广向量(ar x = [x' , 1]'), 则(f(x) = [A, b] ar x)

Rescaling

图片放缩. 通过插值上采样放大, 下采样缩小.
http://opencv-python-tutroals.readthedocs.io/en/latest/py_tutorials/py_imgproc/py_geometric_transformations/py_geometric_transformations.html#scaling

Translation

[f(x) = [I, b] ar x ]

其中, (I)为单位矩阵.
http://opencv-python-tutroals.readthedocs.io/en/latest/py_tutorials/py_imgproc/py_geometric_transformations/py_geometric_transformations.html#rotation

Rotation

参考 http://opencv-python-tutroals.readthedocs.io/en/latest/py_tutorials/py_imgproc/py_geometric_transformations/py_geometric_transformations.html#rotation
直接按照文档中的方法, 在(frac {kpi} 2)rotate时会出现黑边, 部分图片还可能会被剪掉, 参考https://www.oschina.net/translate/opencv-rotation 可实现无损无黑边rotate

Reference

http://docs.opencv.org/2.4/doc/tutorials/imgproc/imgtrans/warp_affine/warp_affine.html
http://docs.opencv.org/2.4/modules/imgproc/doc/geometric_transformations.html#cv2.warpAffine

原文地址:https://www.cnblogs.com/dengdan890730/p/6121876.html