def random_rotate(image):
cols = image.shape[1]
rows = image.shape[0]
mean_color = np.mean(image, axis=(0, 1))
angle = random.uniform(0, 90)
M = cv2.getRotationMatrix2D((cols / 2, rows / 2), angle, 1)
if random.randint(0, 1) == 1:
dst = cv2.warpAffine(image, M, (cols, rows), borderValue=mean_color, borderMode=cv2.BORDER_REFLECT)
else:
dst = cv2.warpAffine(image, M, (cols, rows), borderValue=mean_color)
return dst
a03_augmentation.py 文件源码
python
阅读 27
收藏 0
点赞 0
评论 0
评论列表
文章目录