我想显示 NumPy 数组中的图像,但出现此错误:
Traceback (most recent call last):
File "E:/wittos/python/SVM/witti svm/arraytoimage.py", line 14, in <module>
image = Image.fromarray(arry)
File "C:\Users\MOHAMED-WITTI-ADOU\AppData\Local\Programs\Python\Python35\lib\site-packages\PIL\Image.py", line 2483, in fromarray
arr = obj.__array_interface__
AttributeError: 'list' object has no attribute '__array_interface__'
我希望你能帮我解决这个错误。
import numpy as np
from PIL import Image
# Create a NumPy array
arry = np.array([3,3])
arry= [[25,25,25],[0,0,0],[0,0,0]]
# Create a PIL image from the NumPy array
image = Image.fromarray(arry)
# Save the image
image.save('image.jpg')
绝地无双
陪伴而非守候
相关分类