医学影像离线数据增强——水平翻转
程序员文章站
2022-06-15 12:47:26
医学影像数据增强——水平翻转from PIL import Imageimport numpy as npimport osimport os.pathimport cv2### 水平翻转 ===rootdir = r'1' # 指明被遍历的文件夹,取文件名1下面的全部图片for parent, dirnames, filenames in os.walk(rootdir):for filename in filenames:print('parent is :' + paren...
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
上一篇: PHPExcel实现导入导出功能
下一篇: 利用Matlab提取图片曲线