title: Efficient way to shift image pixels in python
body: <p>Trying to find a way to efficiently shift image pixels in python. Ultimately want to display the results on screen after each shift. For example, pixel at 1920,1080 becomes pixel at 1920,1079 and 1920,1080 is filled with a new value, at the end pixel at 0,0 is discarded and filled with pixel from 0,1. Looking to achieve 30fps or greater on a slow processor like the raspi 3.</p>
  
  <p>My intuition is to move everything to a 1D array, shift everything "left", add the new pixel at the end and turn back into an image.</p>
  
  <p>Crude drawing of the "Z" shifting effect I'm looking for</p>
  
  <p><img src="https://i.stack.imgur.com/XuW9O.png" alt="Crude drawing of the &quot;Z&quot; shifting effect I&#39;m looking for"></p>
  
  <p>Here is my naive implementation of just the pixel shifting, which is too slow:</p>
  
  <pre><code>from PIL import Image
  im = Image.new("RGBA", (1920, 1080), "black") #create blank image
  pix = im.load() #load image
  #iterate over width and height
  for x in xrange(1,1919):
   pix[x,y] = pix[x+1, y] #shift x
      for y in xrange(1,1079):
          pix[x,y] = pix[x, y+1] #shift y
  pix[1919,1079] = (255,255,255) #set new pixel white
  </code></pre>