当前位置: 移动技术网 > IT编程>脚本编程>Python > 医学影像离线数据增强——水平翻转

医学影像离线数据增强——水平翻转

2020年07月30日  | 移动技术网IT编程  | 我要评论
from PIL import Image
import numpy as np
import os
import os.path
import cv2
### 水平翻转 ===
rootdir = r'1'  # 指明被遍历的文件夹,取文件名1下面的全部图片
for parent, dirnames, filenames in os.walk(rootdir):
	for filename in filenames:
		print('parent is :' + parent)
		print('filename is :' + filename)
		currentPath = os.path.join(parent, filename)
		print('the fulll name of the file is :' + currentPath)
		im = Image.open(currentPath)
		out = im.transpose(Image.FLIP_LEFT_RIGHT)
		newname = r"1pre" + '/' + filename + "_sym.jpg" #保存为"1pre/原文件名__sym.jpg" 
		out.save(newname)

本文地址:https://blog.csdn.net/oneday0821/article/details/107643732

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网