title: Translate image using PIL for Deep Learning
body: <p>I am using Pillow in order to achieve data augmentation on a dataset for a road recognition neural network. I wanted to do a translation (say left to right) on my satellite picture, while transferring the rightmost side of the image (which would be outside of the boundaries) to the leftside, as if you were playing pacman, in order not to lose any information.</p>
  <p>I thought about using <code>PIL.Image.AFFINE</code> transform as such :</p>
  <pre class="lang-py prettyprint-override"><code>    import PIL
  
      def TranslateX(img)
          return img.transform(img.size, PIL.Image.AFFINE, (1, 0, 0, 0, 1, 0)
  </code></pre>
  <p>which does transform the following image <a href="https://i.stack.imgur.com/8O28t.jpg" rel="nofollow noreferrer">the following image</a> into <a href="https://i.imgur.com/8RwTA3F.jpg" rel="nofollow noreferrer">this one</a> (you can see the black border on the left side) but does not give a satisfying result which would rather look <a href="https://i.imgur.com/TmWMXmj.png" rel="nofollow noreferrer">like this</a></p>
  <p>Am I missing something ? Does anyone have any idea as to how I could achieve this ?</p>
  <p>Thank you very much for your time.</p>