title: Is there an efficient way to pad a matrix with zeros on all sides?
body: <p>I'm performing texture synthesis on images using the <a href="http://graphics.cs.cmu.edu/people/efros/research/synthesis.html" rel="nofollow">Efros and Leung Algorithm</a>.  My goal is to grow the size of my current textured image and, to do it, I'd like to pad the current image matrix with zeros on all sides.</p>
  
  <p>My current plan given an original image matrix of size MxN and a desired growth size of P:<br>
  (1)  Create a target matrix of size (M+2P)x(N+2P)<br>
  (2)  Set the value of target(i+P,j+P) = original(i,j)<br>
  (3)  Run Efros and Leung</p>
  
  <p>Is there a way I can eliminate (1) and (2) and just operate on the original image to pad it in all directions with P zeros?  </p>