I have a 2Darray named C containing pixels in its indexes. How to view the image
that is formed by that pixels value, A image can be represented by array. No w i am trying the reverse process, I wanna see only grayscale image since array named C has only one value per index. Doing programming in python
Here goes my code http://pastebin.com/qmnKrtzu
getting error in this line
ime = Image.fromarray(c)
ime.save("your_file.jpeg")
ime = Image.fromarray(c_array)
arr = obj.__array_interface__
AttributeError: 'list' object has no attribute '__array_interface__'
That's much better with the code; thanks. In the future, please remember to cut down the code to the minimal level and post it in the original question. An external link doesn't get nearly as much attention.
Your problem is that Image.fromarray requires an array as input; you gave it a list. You did originally convert your list, c, to an array, but you didn't keep the array. I think you need this at lines 18 and 41 from your pastebin code, where I've added references to c_array:
c = [[0]*k*im.width for i in range(k*im.height)]
c_array = np.asarray(c)
...
ime = Image.fromarray(c_array)
ime.save("your_file.jpeg")
You can simply use c.values to convert dataframe into an array
ime = Image.fromarray(c.values) ime.save("your_file.jpeg")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With