For example, a 3 pixel by 3 pixel jpeg image of a checkerboard should be something like
[[#000000, #FFFFFF, #000000],
[#FFFFFF, #000000, #FFFFFF],
[#000000, #FFFFFF, #000000]]
I feel like I may need to download PIL, but I cannot tell what the module does from their website. I also need to be able to generate images from these types of arrays. Thank you!
Use the Image.getdata method. The method returns a generator that you can iterate over:
To go the other way you use
Image.putdata. This generates a tiny checkerboard picture:Here I created a grayscale image (only one “luminescence” channel) and so I just used a single integer value for each pixel.