我在文件夾中有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
提交
取消
