resize () with interpolation = INTER_NEAREST.
EDIT
hmmm, what if you write a function yourself?
double factor; int newcols = round(mat.cols*factor); int newrows = round(mat.rows*factor); Mat newmat = Mat(newcol, newrows, mat.type()); for (int i=0;i<mat.cols;i++){ for (int j=0;j<mat.cols;j++){ newmat_<yourtype> (round(i*factor), round(j*factor)) = mat_<yourtype>(i, j); } }
I did not check if the code works or not (most likely not), but you get the idea.
source share