title: Padarray function translating
body: <p>I have to translate from Matlab to C this function:</p>
  
  <pre><code> impadded = padarray(impadded, padSzVec, 'replicate', 'both');
  </code></pre>
  
  <p>Really it pads the array copying the last elements of the object impadded of every row and column(obtening a bigger object).</p>
  
  <p>What I did is: (img is the original image)</p>
  
  <pre><code>Mat padded;
  padded.create(img.rows + padSize, img.cols + padSize,img.type());
  padded.setTo(cv::Scalar::all(0));
  padded(Rect(padSize,padSize,img.rows,img.cols);
  img.copyTo(padded);
  </code></pre>
  
  <p>I suppose I m padding but inserting 0 to have a bigger object. Someone cal help me to improve the code.</p>