我在文件夹中有5张图片。我想把所有这些图像都转换为灰度。import globcolorIm = []for filename in glob.glob('/content/drive/My Drive/Colab Notebooks/Asplab/Cifar/*.png'): print(filename) img = Image.open(filename) colorIm.append(img) greyIm=colorIm.convert('L')属性错误:“列表”对象没有属性“转换”
1 回答
Smart猫小萌
TA贡献1911条经验 获得超7个赞
您需要转换列表中的每个图像:
import glob
colorIm = []
for filename in glob.glob('/content/drive/My Drive/Colab Notebooks/Asplab/Cifar/*.png'):
print(filename)
img = Image.open(filename)
colorIm.append(img)
greyIm = [img.convert('L') for img in colorIm]
添加回答
举报
0/150
提交
取消