$CODE$
程序员文章站
2022-06-26 13:22:15
...
1.
import numpy as np
import os
from PIL import Image
from matplotlib import pyplot as plt
import scipy.misc as msic
data_dir="E:/experiment/项目记录/2019-1-10-实验四/datasets"
save_dir="E:/experiment/项目记录/2019-1-10-实验四/datasets-argumentation"
data_image=data_dir+"/image"
data_depth=data_dir+"/depth"
data_label=data_dir+"/label"
save_image=save_dir+"/image"
save_depth=save_dir+"/depth"
save_SV=save_dir+"/SV"
save_UV=save_dir+"/UV"
lists=[]
dicts={}
images=os.listdir(data_image)
depths=os.listdir(data_depth)
labels=os.listdir(data_label)
for img in images:
img_num=img.split(".")[0]
dicts["image"]=img
dicts["depth"]="depth_"+img_num.split("_")[0]+img_num.split("_")[1]+".jpg"
dicts["SV"]=img_num+"_SV_1.npy"
dicts["UV"]=img_num+"_UV_1.npy"
lists.append(dicts.copy())
for dict in lists:
img_path=data_image+"/"+dict["image"]
depth_path=data_depth+"/"+dict["depth"]
SV_path=data_label+"/"+dict["SV"]
UV_path=data_label+"/"+dict["UV"]
#source
image=Image.open(img_path).resize([500, 500], Image.ANTIALIAS)
depth=Image.open(depth_path).resize([500, 500], Image.ANTIALIAS)
SV=Image.fromarray(np.load(SV_path)).resize([500, 500], Image.ANTIALIAS)
UV=Image.fromarray(np.load(UV_path)).resize([500, 500], Image.ANTIALIAS)
image_30=image.rotate(30)
depth_30=depth.rotate(30)
SV_30=SV.rotate(30)
UV_30=UV.rotate(30)
#msic.imsave("C:/Users/zy/Desktop/1111.jpg", np.array(UV_30))
image_60=image.rotate(60)
depth_60=depth.rotate(60)
SV_60=SV.rotate(60)
UV_60=UV.rotate(60)
#L-R
LR_image=image.transpose(Image.FLIP_LEFT_RIGHT)
LR_depth=depth.transpose(Image.FLIP_LEFT_RIGHT)
LR_SV=SV.transpose(Image.FLIP_LEFT_RIGHT)
LR_UV=UV.transpose(Image.FLIP_LEFT_RIGHT)
LR_image_30=LR_image.rotate(30)
LR_depth_30=LR_depth.rotate(30)
LR_SV_30=LR_SV.rotate(30)
LR_UV_30=LR_UV.rotate(30)
LR_image_60=LR_image.rotate(60)
LR_depth_60=LR_depth.rotate(60)
LR_SV_60=LR_SV.rotate(60)
LR_UV_60=LR_UV.rotate(60)
#T-D
TD_image=image.transpose(Image.FLIP_TOP_BOTTOM)
TD_depth=depth.transpose(Image.FLIP_TOP_BOTTOM)
TD_SV=SV.transpose(Image.FLIP_TOP_BOTTOM)
TD_UV=UV.transpose(Image.FLIP_TOP_BOTTOM)
TD_image_30=TD_image.rotate(30)
TD_depth_30=TD_depth.rotate(30)
TD_SV_30=TD_SV.rotate(30)
TD_UV_30=TD_UV.rotate(30)
TD_image_60=TD_image.rotate(60)
TD_depth_60=TD_depth.rotate(60)
TD_SV_60=TD_SV.rotate(60)
TD_UV_60=TD_UV.rotate(60)
#**save
#print(dict["image"], "\n",dict["depth"], "\n",dict["SV"], "\n",dict["UV"])
#source
image_30_name=save_image+"/30_"+dict["image"]
depth_30_name=save_depth+"/30_"+dict["depth"]
SV_30_name=save_SV+"/30_"+dict["SV"].split(".")[0]+".jpg"
UV_30_name=save_UV+"/30_"+dict["UV"].split(".")[0]+".jpg"
image_60_name=save_image+"/60_"+dict["image"]
depth_60_name=save_depth+"/60_"+dict["depth"]
SV_60_name=save_SV+"/60_"+dict["SV"].split(".")[0]+".jpg"
UV_60_name=save_UV+"/60_"+dict["UV"].split(".")[0]+".jpg"
#L-R
LR_image_name=save_image+"/LR_"+dict["image"]
LR_depth_name=save_depth+"/LR_"+dict["depth"]
LR_SV_name=save_SV+"/LR_"+dict["SV"].split(".")[0]+".jpg"
LR_UV_name=save_UV+"/LR_"+dict["UV"].split(".")[0]+".jpg"
LR_image_30_name=save_image+"/LR_30_"+dict["image"]
LR_depth_30_name=save_depth+"/LR_30_"+dict["depth"]
LR_SV_30_name=save_SV+"/LR_30_"+dict["SV"].split(".")[0]+".jpg"
LR_UV_30_name=save_UV+"/LR_30_"+dict["UV"].split(".")[0]+".jpg"
LR_image_60_name=save_image+"/LR_60_"+dict["image"]
LR_depth_60_name=save_depth+"/LR_60_"+dict["depth"]
LR_SV_60_name=save_SV+"/LR_60_"+dict["SV"].split(".")[0]+".jpg"
LR_UV_60_name=save_UV+"/LR_60_"+dict["UV"].split(".")[0]+".jpg"
#T-D
TD_image_name=save_image+"/TD_"+dict["image"]
TD_depth_name=save_depth+"/TD_"+dict["depth"]
TD_SV_name=save_SV+"/TD_"+dict["SV"].split(".")[0]+".jpg"
TD_UV_name=save_UV+"/TD_"+dict["UV"].split(".")[0]+".jpg"
TD_image_30_name=save_image+"/TD_30_"+dict["image"]
TD_depth_30_name=save_depth+"/TD_30_"+dict["depth"]
TD_SV_30_name=save_SV+"/TD_30_"+dict["SV"].split(".")[0]+".jpg"
TD_UV_30_name=save_UV+"/TD_30_"+dict["UV"].split(".")[0]+".jpg"
TD_image_60_name=save_image+"/TD_60_"+dict["image"]
TD_depth_60_name=save_depth+"/TD_60_"+dict["depth"]
TD_SV_60_name=save_SV+"/TD_60_"+dict["SV"].split(".")[0]+".jpg"
TD_UV_60_name=save_UV+"/TD_60_"+dict["UV"].split(".")[0]+".jpg"
#-----------
image_30.save(image_30_name)
depth_30.save(depth_30_name)
msic.imsave(SV_30_name, np.array(SV_30))
msic.imsave(UV_30_name, np.array(UV_30))
image_60.save(image_60_name)
depth_60.save(depth_60_name)
msic.imsave(SV_60_name, np.array(SV_60))
msic.imsave(UV_60_name, np.array(UV_60))
LR_image.save(LR_image_name)
LR_depth.save(LR_depth_name)
msic.imsave(LR_SV_name, np.array(LR_SV))
msic.imsave(LR_UV_name, np.array(LR_UV))
LR_image_30.save(LR_image_30_name)
LR_depth_30.save(LR_depth_30_name)
msic.imsave(LR_SV_30_name, np.array(LR_SV_30))
msic.imsave(LR_UV_30_name, np.array(LR_UV_30))
LR_image_60.save(LR_image_60_name)
LR_depth_60.save(LR_depth_60_name)
msic.imsave(LR_SV_60_name, np.array(LR_SV_60))
msic.imsave(LR_UV_60_name, np.array(LR_UV_60))
TD_image.save(TD_image_name)
TD_depth.save(TD_depth_name)
msic.imsave(TD_SV_name, np.array(TD_SV))
msic.imsave(TD_UV_name, np.array(TD_UV))
TD_image_30.save(TD_image_30_name)
TD_depth_30.save(TD_depth_30_name)
msic.imsave(TD_SV_30_name, np.array(TD_SV_30))
msic.imsave(TD_UV_30_name, np.array(TD_UV_30))
TD_image_60.save(TD_image_60_name)
TD_depth_60.save(TD_depth_60_name)
msic.imsave(TD_SV_60_name, np.array(TD_SV_60))
msic.imsave(TD_UV_60_name, np.array(TD_UV_60))
print("***finsh***")
推荐阅读
-
Ubuntu下安装并配置VS Code编译C++的方法
-
成功解决SyntaxError: Non-UTF-8 code starting with xc0 in file but no encoding declared; see http://p
-
Bartender怎么制作一个Code128条码?
-
visual studio code教程 vscode的基础使用和自定义设置方法
-
VS Code有哪些常用的快捷键? Visual Studio Code常用快捷键大全
-
巧用Google Code备份代码以及备份博客的方法分享
-
巧用Google Code备份代码以及备份博客的方法分享
-
VS Code 配置 Python 开发环境
-
更改Web Service部署生成的App_Code.dll名称的方法
-
VS App_Code文件夹下的类文件不能直接被调用的解决方法