将需要处理的图片放在同一个文件夹中
from PIL import Image
import os
source_path = "D:\\work\\test_image\\"
target_path = "D:\\work\\poly_out\\"
image_list = os.listdir(source_path)
for file in image_list:
in_filename = source_path+file
img = Image.open(in_filename)
data = np.array(img).astype(np.int32)
## 一系列图像处理操作
img_out = Image.fromarray(np.uint8(data))
out_filename = target_path+"图片10_1366_768.png"
print("Write", out_filename)
img_out.save(out_filename)
这段代码用于批量读取D:work est_image文件夹中的图片,将它们转换为numpy数组进行图像处理,然后保存到D:workpoly_out目录下,文件名为'图片10_1366_768.png'。
3508

被折叠的 条评论
为什么被折叠?



