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)

 

原图

opencv 仿射变换_第1张图片

 

效果

opencv 仿射变换_第2张图片

 

你可能感兴趣的:(opencv 仿射变换)