包括平移,翻转,旋转,调整对比度,高斯噪声,颜色变换
import skimage
import io,os
import matplotlib.pyplot as plt
from PIL import Image,ImageEnhance
import cv2
#root_path为图像根目录,img_name为图像名字
def move(root_path,img_name,off): #平移,平移尺度为off
img = Image.open(os.path.join(root_path, img_name))
offset = img.offset(off,0)
return offset
def flip(root_path,img_name): #翻转图像
img = Image.open(os.path.join(root_path, img_name))
filp_img = img.transpose(Image.FLIP_LEFT_RIGHT)
# filp_img.save(os.path.join(root_path,img_name.split('.')[0] + '_flip.jpg'))
return filp_img
<