Fork me on Gitee

opencv 仿射变换

 1 import cv2 as cv
 2 import numpy as np
 3 
 4 
 5 img = cv.imread('../images/face.jpg')
 6 h, w = img.shape[:2]
 7 mat_src = np.float32([[0, 0], [0, h-1], [w-1, 0]])
 8 mat_dst = np.float32([[50, 50], [100, h-50], [w-50, 100]])
 9 matAffine = cv.getAffineTransform(mat_src, mat_dst)
10 dst = cv.warpAffine(img, matAffine, (w, h))
11 cv.imshow('dst', dst)
12 cv.waitKey(0)

 

原图

 

效果

 

posted @ 2019-02-16 20:50  MARK+  阅读(366)  评论(0编辑  收藏  举报