I am having an issue whereby manipulating image pixels is causing a corrupted image to be saved...
So, I open an image using PIL, and then convert it to a NumPy array:
image = Image.open("myimage.png")
np_image = np.asarray(image)
Then, I transpose the image, to convert it from [x][y][channel] to [channel][x][y]:
pixels = np.transpose(np_image, (2, 0, 1))
If I then transpose this image back to [x][y][channel], create a PIL image from this array, and then save the image:
image1 = np.transpose(pixels, (1, 2, 0))
image2 = Image.fromarray(image1, 'RGB')
image2.save('image2.png')
Then the image saved is identical to "myimage.png".
However, if instead of the above code, I first assign pixels to an element in an array of images:
images = np.zeros([10,