Reputation: 19243
I am reading the image from the disk and I am converting it to a numpy array
im=Image.open(infile)
imdata = scipy.misc.fromimage(im)
but the image is mirrored like it is stored on the disk.
How to read it in a correct order.
Thanks a lot.
Upvotes: 0
Views: 533
Reputation: 7419
If it is upside down:
imagedata = imagedata[::-1, :]
If it is swapped left to right:
imagedata = imagedata[:, ::-1]
And if it is transposed (flipped at the diagonal):
imagedata = imagedata.T
If you have more dimensions more (color, alpha, ...) flipping can be done by
imagedata = imagedata[::-1, ... ]
or
imagedata = imagedata[:, ::-1, ... ]
"..." is not a placeholder for something I do not know, but an implemented feature in numpy.
Upvotes: 2