-1

I have the following numpy array

blackImg = np.zeros((1920, 1080, 3), np.uint8)

I then have another numpy array which is an actual image with a resolution smaller than 1920x1080.

I then want to insert the actual image over the black 1920x1080 image. The image should be inserted centered.

Like this: np_link

licerer
  • 13
  • 3

1 Answers1

0

Assuming:

Img = np.ones((480, 640, 3), np.uint8)

is the image, then:

NewImg = np.pad(Img, [(720, 720), (220, 220),(0,0)], mode='constant')

should add a black padding around the original image. (720, 720) add 720 black pixels at top and bottom (220, 220) adds 220 left and right and (0,0) is to not add padding in the third dimension.

Finn Meyer
  • 89
  • 4