Hello,
maybe this question looks stupid, but I try to use Pillows Image.convert()
to convert an image to grayscale. This image I have stored in a variable img
because I already pre-processed it, but not with Pillow (type: numpy.ndarray). So I type:
img = Image.convert('LA')
But it does not seem to work, as it says:
AttributeError: module 'PIL.Image' has no attribute 'convert'
If I type img = Image.open("picture.jpg").convert('LA')
it works, but I want to use it on a variable that already exists. I also do not want to save the preprocessed image just to open and convert it with the previous command because this is even more inefficient (in terms of speed and CPU-power).
So: Is there a proper way to do this?
Thanks for the help in advance!
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…