def randomShift(img, u=0.25, limit=4):
if random.random() < u:
dx = round(random.uniform(-limit, limit)) # pixel
dy = round(random.uniform(-limit, limit)) # pixel
height, width, channel = img.shape
img1 = cv2.copyMakeBorder(img, limit + 1, limit + 1, limit + 1, limit + 1, borderType=cv2.BORDER_REFLECT_101)
y1 = limit + 1 + dy
y2 = y1 + height
x1 = limit + 1 + dx
x2 = x1 + width
img = img1[y1:y2, x1:x2, :]
return img
n06_pytorch_utils.py 文件源码
python
阅读 21
收藏 0
点赞 0
评论 0
评论列表
文章目录