Hi, I have to pad an array, obtain a bigger one with latest element array of every rows and cols of a Mat object around original array.

What I have to do is transalte form Matlab to C this line:

impadded=padarray(impadded,padVect, 'replicate','both');

I was using this code to obtain it:


Code:

 Mat padded;
 int padding = padSize;

 padded.create(img.rows+padding,img.cols+padding,img.type());
 padded.setTo(cv::Scalar::all(0));
 img.copyTo(padded(Rect(padding,padding,img.rows,img.cols);
I have 2 problems:
1) with setTo i m padding with zero element the original matrix and not with last element
2) in copyto(last line) I have an error:
no matching function for call to 'cv::Mat::copyTo(cv::Mat)'