def augmentation(image, imageB, org_width=160,org_height=224, width=190, height=262):
max_angle=20
image=cv2.resize(image,(height,width))
imageB=cv2.resize(imageB,(height,width))
angle=np.random.randint(max_angle)
if np.random.randint(2):
angle=-angle
image=rotate(image,angle,resize=True)
imageB=rotate(imageB,angle,resize=True)
xstart=np.random.randint(width-org_width)
ystart=np.random.randint(height-org_height)
image=image[xstart:xstart+org_width,ystart:ystart+org_height]
imageB=imageB[xstart:xstart+org_width,ystart:ystart+org_height]
if np.random.randint(2):
image=cv2.flip(image,1)
imageB=cv2.flip(imageB,1)
if np.random.randint(2):
image=cv2.flip(image,0)
imageB=cv2.flip(imageB,0)
image=cv2.resize(image,(org_height,org_width))
imageB=cv2.resize(imageB,(org_height,org_width))
return image,imageB
# print(image.shape)
# plt.imshow(image)
# plt.show()
评论列表
文章目录