I want to convert a PIL image to a numpy array. Numpy's asarray
function simply puts the image in a 0-dimensional array.
(Pdb) p img
<PIL.Image._ImageCrop image mode=RGB size=1024x0 at 0x106953560>
(Pdb) img.getdata()
<ImagingCore object at 0x104c97b10>
(Pdb) np.asarray(img.getdata())
array([], dtype=float64)
(Pdb) np.asarray(img)
array(<PIL.Image._ImageCrop image mode=RGB size=1024x0 at 0x106953560>, dtype=object)
(Pdb) np.asarray(img).shape
()
(Pdb) np.asarray(img, np.uint8)
*** SystemError: error return without exception set
The solutions on a similar SO question didn't work.