
OpenCV2.4.7.0文档翻译:对图像做几何变换,Geometric Image Transformations
计算出与一个二维旋转相对应的仿射矩阵(affine matrix)。
C++: Mat getRotationMatrix2D (Point2f center, double angle, double scale )
Python: cv2.getRotationMatrix2D (center, angle, scale) → retval
C: CvMat* cv2DRotationMatrix (CvPoint2D32f center, double angle, double scale, CvMat* map_matrix )
Python: cv.GetRotationMatrix2D (center, angle, scale, mapMatrix) → None
|
参数: |
|
这个函数会计算以下矩阵:
其中
这个变换矩阵会把旋转中心映射在原地。如果妳不希望这样,那么,可以调整一下偏移量(shift)。
参考
对一张图片应用一个仿射变换。
C++: void warpAffine (InputArray src, OutputArray dst, InputArray M, Size dsize, int flags=INTER_LINEAR, int borderMode=BORDER_CONSTANT, const Scalar& borderValue=Scalar())
Python: cv2.warpAffine (src, M, dsize[, dst[, flags[, borderMode[, borderValue]]]]) → dst
C: void cvWarpAffine (const CvArr* src, CvArr* dst, const CvMat* map_matrix, int flags=CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS, CvScalar fillval=cvScalarAll(0) )
Python: cv.WarpAffine (src, dst, mapMatrix, flags=CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS, fillval=(0, 0, 0, 0)) → None
C: void cvGetQuadrangleSubPix (const CvArr* src, CvArr* dst, const CvMat* map_matrix )
Python: cv.GetQuadrangleSubPix (src, dst, mapMatrix) → None
|
参数: |
|
当设置了标志位WARP_INVERSE_MAP 时,warpAffine函数使用指定的矩阵来对源图片进行变换:
否则,首先会使用 invertAffineTransform() 来将这个变换做反转,然后使用反转后的矩阵来代替M。这个函数无法进行原地操作。
参考
warpPerspective() 、 resize() 、 remap() 、 getRectSubPix() 、 transform()
注意
cvGetQuadrangleSubPix与cvWarpAffine类似,但是那些界外点是使用复制模式来做外插操作的。
英拉
HxLauncher: Launch Android applications by voice commands