(using python 3.9.1) I'm trying to convert a PNG to a list of RGB values, but I am not sure how to. I've searched online and found that I can convert an image to an array using pillow and numpy. The thing is, I have the data, but I have no idea how to use it.
I was wondering if someone can help me or point me in the right direction.
EDIT:
I was asked by Mr.T to provide an example of the problem i was having. So here it is:
Here is some example code, it opens an image and converts it to a numpy array
from PIL import Image
import numpy
image = Image.open('./Untitled.png')
narray = numpy.array(image)
for i in range(len(narray)):
print(numpy.array_str(narray[i]) + '\n')
The output it gives is:
[0 1 1 1 1 1 1 1 1 0]
[0 1 1 2 1 1 2 1 1 0]
[0 1 1 2 1 1 2 1 1 0]
[0 1 1 2 1 1 2 1 1 0]
[0 1 1 1 1 1 1 1 1 0]
[0 1 2 1 1 1 1 2 1 0]
instead of the RGB values like I thought it would:
[255,233,0,255,233,0,255,233,0,255,233,0,255,233,0,255,233,0,255,233,0,255,233,0,255,233,0,255,233,0,
255,233,0,255,178,0 ...