title: opencv warpaffine negative translation
body: <p>I am attempting to use OpenCVs warpAffine to transform an image with a simple translation. The image produced from a negative versus positive translation surprises me.</p>
  
  <pre><code>from skimage import data
  import numpy as np
  import cv2
  from pylab import *
  
  ion()
  fig = figure()
  fig.clear()
  image = data.camera()
  
  # positive translation
  rigid0 = np.float32([[1.0, 0.0, 96.0], [0.0, 1.0, 0.0]])
  w0 = cv2.warpAffine(image,rigid0,(image.shape[1]+int(abs(rigid0[0,2])),image.shape[0]))
  
  # negative translation 
  rigid1 = np.float32([[1.0, 0.0, -96.0], [0.0, 1.0, 0.0]])
  w1 = cv2.warpAffine(image,rigid1,(image.shape[1]+int(abs(rigid1[0,2])),image.shape[0]))
  
  plt.subplot(1, 2, 1)
  imshow(w0, cmap=gray())
  
  plt.subplot(1, 2, 2)
  imshow(w1, cmap=gray())
  </code></pre>
  
  <p>I have inserted the produced figure below, notice how the negative translation on the right appears to eat twice as many pixels off the image. Both images are construced with a translation by 96 pixels, one negative and the other positive.</p>
  
  <p><a href="https://i.stack.imgur.com/3mZ3U.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3mZ3U.png" alt="positive versus negative translation"></a></p>