from PIL import Image
import numpy as np
import cv2
import os
# 单张图片
# img = Image.open(r'C:\Users\znjt\Desktop\huhui\40051.jpg')
# img = Image.fromarray(np.uint8(img))
# t = img.convert('L')
# img=Image.fromarray(np.uint8(t)*255)
# img.save(r'C:\Users\znjt\Desktop\huhui\40051(8).jpg')
path
= r'D:\m_Files\IPI-for-small-target-detection-master\my_images\\'
save_path = r'D:\m_Files\IPI-for-small-target-detection-master\8\\'
for i in os.listdir(path):
img = Image.open(path+i)
img = Image.fromarray(np.uint8(img))
t = img.convert('L')
img = Image.fromarray(np.uint8(t)) # *255
img.save(save_path+i)
批量转换图片位深度
最新推荐文章于 2025-03-03 09:46:16 发布
部署运行你感兴趣的模型镜像
您可能感兴趣的与本文相关的镜像
Python3.11
Conda
Python
Python 是一种高级、解释型、通用的编程语言,以其简洁易读的语法而闻名,适用于广泛的应用,包括Web开发、数据分析、人工智能和自动化脚本
9543

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



