You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
19 lines
523 B
19 lines
523 B
import cv2
|
|
import numpy as np
|
|
|
|
def Affine(img):
|
|
# 图像输入
|
|
src = img
|
|
# 图像放缩
|
|
src = cv2.resize(src, (256, 256))
|
|
# 获取图像shape
|
|
rows, cols = src.shape[: 2]
|
|
|
|
########Begin########
|
|
# 设置图像仿射变化矩阵
|
|
post1 = np.float32([[50, 50], [200, 50], [50, 200]])
|
|
post2 = np.float32([[10, 100], [200, 50], [100, 250]])
|
|
M = cv2.getAffineTransform(post1, post2)
|
|
# 图像仿射变换,及保存
|
|
result = cv2.warpAffine(src, M, (rows, cols))
|
|
return result |