Resize an image but fill the space with black ?
I have a small Image:
Mat myImage;
This image is of Size(100,100)
. Now I would like to enlarge the dimension of this image to Size(1000,1000)
(filling the rest of the space with black)
I could do in this way (but I think there could be a faster solution)
Mat largerImage(Size(1000,1000),myImage.type());
largerImage = Scalar(0);
myImage.copyTo(largerImage(Rect(0,0,myImage.cols,myImage.rows)));
How can I directly "expand" myImage
?
Mat largerImage(Size(1000,1000),myImage.type());
won't fill with zeros(maybe it does for you in DEBUG, but don't rely on that), use:Mat largerImage = Mat::zeros(Size(1000,1000),myImage.type());
insteadYea I forgot to write in the question: largerImage = Scalar(0);