Python Forum
pillow reversing the order of pixels after every row
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
pillow reversing the order of pixels after every row
#3
The pixels variable has shape 32x32x3, it is a numpy array. You can easily manipulate with numpy arrays without pure-Python loops; If you want to invert all rows of the image, just do:
inverted = pixels[:, ::-1, :]
If you want to invert all odd rows, do
inverted = pixels.copy()
inverted[::2,...] = inverted[::2, ::-1, :]
# now inverted var. has desired form
Reply


Messages In This Thread
RE: pillow reversing the order of pixels after every row - by scidam - May-26-2020, 11:07 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  identify not white pixels in bmp flash77 17 2,711 Nov-10-2023, 09:21 PM
Last Post: flash77
  Convert 400 grayscale pixels into RGB python420 1 2,493 Jan-02-2020, 04:19 PM
Last Post: Clunk_Head
  How to extract temperature value of pixels of a thermal image recorded by IR camera hamacvan 1 14,534 Jan-13-2019, 06:06 PM
Last Post: Larz60+
  Reversing word in strings yields unexpected result Dec 4 3,684 May-17-2017, 05:32 PM
Last Post: wavic

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020