If by resizing you mean scaling an image, use resize () as follows:
resize(src, dst, dst.size(), 0, 0, interpolation);
Otherwise, if you just need to change the number of lines of your mat, use the Mat :: reshape () function. Note that reshape returns a new Mat header:
cv::Mat dst = src.reshape ( 0, newRowVal );
Finally, if you want to arbitrarily change the shape of the Mat (changing rows and columns), you probably need to define a new Mat with destination sizes and copy src Mat to it:
Mat dst(newRowVal, newColVal, src.type()); src.setTo(0); src.copyTo(dst(Rect(Point(0, 0), src.size())));
source share