import os
import sys
import cv2
img_path = 'D:/PythonProject/UWGAN_UIE-master/UNetRestoration/data/water/'
gt_path = 'D:/PythonProject/UWGAN_UIE-master/UNetRestoration/data/gt/'
def read_path(file_pathname):
#遍历该目录下的所有图片文件
for filename in os.listdir(file_pathname):
#print(filename)
img = cv2.imread(file_pathname+'/'+filename)
new_image = cv2.resize(img, (256,256), interpolation=cv2.INTER_AREA)
#####保存图片的路径
cv2.imwrite(file_pathname+"/"+filename, new_image)
read_path(img_path)
#print(os.getcwd())
python-opencv批量修改图片大小并保存
最新推荐文章于 2021-08-12 11:32:41 发布