How do I convert a PIL Image
back and forth to a NumPy array so that I can do faster pixel-wise transformations than PIL's PixelAccess
allows? I can convert it to a NumPy array via:
pic = Image.open("foo.jpg")
pix = numpy.array(pic.getdata()).reshape(pic.size[0], pic.size[1], 3)
But how do I load it back into the PIL Image
after I've modified the array? pic.putdata()
isn't working well.