def transition(self, src, level):
size = tuple(np.array([src.shape[1], src.shape[0]]))
if random.randint(0, 1) == 0:
move_x = level
else:
move_x = level * -1
if random.randint(0, 1) == 0:
move_y = level
else:
move_y = level * -1
matrix = [
[1, 0, move_x],
[0, 1, move_y]
]
affine_matrix = np.float32(matrix)
img_afn = cv2.warpAffine(src, affine_matrix,
size, flags=cv2.INTER_LINEAR)
return img_afn
评论列表
文章目录