# Revision history [back]

### 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());
myImage.copyTo(largerImage());


How can I directly "expand" myImage ?

### 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());
myImage.copyTo(largerImage());
myImage.copyTo(largerImage(Rect(0,0,myImage.cols,myImage.rows)));


How can I directly "expand" myImage ?

### 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 ?

 4 retagged sturkmen 6772 ●3 ●48 ●79 https://github.com/stu...

### 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 ?