#やりたいこと
連番画像を読み込み、ndarray形式に変換し、テキストファイルに保存したいと考えています。
#試したこと
from PIL import Image import numpy as np import glob file = glob.glob('./Desktop/Cat/*.jpg') for f in file: image = np.array(Image.open(file).convert('RGB')) np.savetxt('./Desktop/image.txt', image, fmt='%.1e')
Traceback (most recent call last): File "/home/hoge/.local/lib/python3.6/site-packages/PIL/Image.py", line 2613, in open fp.seek(0) AttributeError: 'list' object has no attribute 'seek' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "./Desktop/image_data.py", line 7, in <module> image = np.array(Image.open(files).convert('RGB')) File "/home/yudai/.local/lib/python3.6/site-packages/PIL/Image.py", line 2615, in open fp = io.BytesIO(fp.read()) AttributeError: 'list' object has no attribute 'read'
関連質問として下記がありました。
Pythonで複数画像データを配列化して保存する方法
#環境
python 3.6.7
numpy 1.15.4
ubuntu 18.04

回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/12/30 02:36
2018/12/30 02:43 編集