import cv2 import numpy as np #旋转 img = cv2.imread('xxx', 1) rows, cols, channel = img.shape M = cv2.getRotationMatrix2D((cols / 2, rows / 3), 90, 0.4) dst = cv2.warpAffine(img, M, (cols, rows)) cv2.imwrite('xxx', dst) #仿射变换 img = cv2.imread('xxx') rows,cols,ch = img.shape pts1 = np.float32([[50,50],[200,50],[50,200]]) pts2 = np.float32([[10,100],[200,50],[100,250]]) M = cv2.getAffineTransform(pts1,pts2) dst = cv2.warpAffine(img,M,(cols,rows)) cv2.imwrite('xxx',dst) #水平翻转 image = cv2.imread("xxx") dst = cv2.flip(image,1) cv2.imwrite('xxx',dst)
利用opencv进行图像变化并保存
最新推荐文章于 2019-12-11 08:57:59 发布